diff --git a/demo-shell-ng2/app/components/about/about.component.css b/demo-shell-ng2/app/components/about/about.component.css
index bafc1e6a63..9b9217de42 100644
--- a/demo-shell-ng2/app/components/about/about.component.css
+++ b/demo-shell-ng2/app/components/about/about.component.css
@@ -1,3 +1,8 @@
.about-container {
padding: 10px;
}
+
+.adf-table-version {
+ width: 60%;
+ text-align: center;
+}
diff --git a/demo-shell-ng2/app/components/about/about.component.html b/demo-shell-ng2/app/components/about/about.component.html
index 13424e064f..55254a4980 100644
--- a/demo-shell-ng2/app/components/about/about.component.html
+++ b/demo-shell-ng2/app/components/about/about.component.html
@@ -10,6 +10,93 @@
Alfresco Content Services URL: {{ ecmHost }}
+
Source code
You are running the project based on the following commit:
diff --git a/demo-shell-ng2/app/components/about/about.component.ts b/demo-shell-ng2/app/components/about/about.component.ts
index b485c82a10..3cb2547bb1 100644
--- a/demo-shell-ng2/app/components/about/about.component.ts
+++ b/demo-shell-ng2/app/components/about/about.component.ts
@@ -17,7 +17,7 @@
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
-import { AppConfigService, LogService } from 'ng2-alfresco-core';
+import { AlfrescoAuthenticationService, AppConfigService, BpmProductVersionModel, DiscoveryApiService, EcmProductVersionModel, LogService } from 'ng2-alfresco-core';
import { ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
@Component({
@@ -42,10 +42,21 @@ export class AboutComponent implements OnInit {
constructor(private http: Http,
private appConfig: AppConfigService,
- private logService: LogService) {
+ private authService: AlfrescoAuthenticationService,
+ private logService: LogService,
+ private discovery: DiscoveryApiService) {
}
ngOnInit() {
+
+ this.discovery.getEcmProductInfo().subscribe((ecmVers) => {
+ this.ecmVersion = ecmVers;
+ });
+
+ this.discovery.getBpmProductInfo().subscribe((bpmVers) => {
+ this.bpmVersion = bpmVers;
+ });
+
this.http.get('/versions.json').subscribe(response => {
let regexp = new RegExp('^(ng2-activiti|ng2-alfresco|alfresco-)');
diff --git a/ng2-components/ng2-alfresco-core/index.ts b/ng2-components/ng2-alfresco-core/index.ts
index 2372b0a69b..3014dd2d13 100644
--- a/ng2-components/ng2-alfresco-core/index.ts
+++ b/ng2-components/ng2-alfresco-core/index.ts
@@ -58,6 +58,7 @@ import { PeopleApiService } from './src/services/people-api.service';
import { SearchApiService } from './src/services/search-api.service';
import { SharedLinksApiService } from './src/services/shared-links-api.service';
import { SitesApiService } from './src/services/sites-api.service';
+import { DiscoveryApiService } from './src/services/discovery-api.service';
export { ContentService } from './src/services/content.service';
export { StorageService } from './src/services/storage.service';
@@ -91,6 +92,7 @@ export { PeopleApiService } from './src/services/people-api.service';
export { SearchApiService } from './src/services/search-api.service';
export { SharedLinksApiService } from './src/services/shared-links-api.service';
export { SitesApiService } from './src/services/sites-api.service';
+export { DiscoveryApiService } from './src/services/discovery-api.service';
import { DataColumnListComponent } from './src/components/data-column/data-column-list.component';
import { DataColumnComponent } from './src/components/data-column/data-column.component';
@@ -121,6 +123,7 @@ export * from './src/models/card-view-dateitem.model';
export * from './src/models/file.model';
export * from './src/models/permissions.enum';
export * from './src/models/site.model';
+export * from './src/models/product-version.model';
export * from './src/models/index';
diff --git a/ng2-components/ng2-alfresco-core/src/models/product-version.model.ts b/ng2-components/ng2-alfresco-core/src/models/product-version.model.ts
new file mode 100644
index 0000000000..526f1904a0
--- /dev/null
+++ b/ng2-components/ng2-alfresco-core/src/models/product-version.model.ts
@@ -0,0 +1,141 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export class BpmProductVersionModel {
+ edition: string;
+ majorVersion: string;
+ revisionVersion: string;
+ minorVersion: string;
+ type: string;
+
+ constructor(obj?: any) {
+ if (obj) {
+ this.edition = obj.edition || null;
+ this.majorVersion = obj.majorVersion || null;
+ this.revisionVersion = obj.revisionVersion || null;
+ this.minorVersion = obj.minorVersion || null;
+ this.type = obj.type || null;
+ }
+ }
+}
+
+export class EcmProductVersionModel {
+ edition: string;
+ version: VersionModel;
+ license: LicenseModel;
+ status: VersionStatusModel;
+ modules: VersionModuleModel[] = [];
+
+ constructor(obj?: any) {
+ if (obj && obj.entry && obj.entry.repository) {
+ this.edition = obj.entry.repository.edition || null;
+ this.version = new VersionModel(obj.entry.repository.version);
+ this.license = new LicenseModel(obj.entry.repository.license);
+ this.status = new VersionStatusModel(obj.entry.repository.status);
+ if (obj.entry.repository.modules) {
+ obj.entry.repository.modules.forEach((module) => {
+ this.modules.push(new VersionModuleModel(module));
+ });
+ }
+ }
+ }
+
+}
+
+export class VersionModel {
+ major: string;
+ minor: string;
+ patch: string;
+ hotfix: string;
+ schema: number;
+ label: string;
+ display: string;
+
+ constructor(obj?: any) {
+ if (obj) {
+ this.major = obj.major || null;
+ this.minor = obj.minor || null;
+ this.patch = obj.patch || null;
+ this.hotfix = obj.hotfix || null;
+ this.schema = obj.schema || null;
+ this.label = obj.label || null;
+ this.display = obj.display || null;
+ }
+ }
+}
+
+export class LicenseModel {
+ issuedAt: string;
+ expiresAt: string;
+ remainingDays: number;
+ holder: string;
+ mode: string;
+ isClusterEnabled: boolean;
+ isCryptodocEnabled: boolean;
+
+ constructor(obj?: any) {
+ if (obj) {
+ this.issuedAt = obj.issuedAt || null;
+ this.expiresAt = obj.expiresAt || null;
+ this.remainingDays = obj.remainingDays || null;
+ this.holder = obj.holder || null;
+ this.mode = obj.mode || null;
+ this.isClusterEnabled = obj.isClusterEnabled ? true : false;
+ this.isCryptodocEnabled = obj.isCryptodocEnabled ? true : false;
+ }
+ }
+}
+
+export class VersionStatusModel {
+ isReadOnly: boolean;
+ isAuditEnabled: boolean;
+ isQuickShareEnabled: boolean;
+ isThumbnailGenerationEnabled: boolean;
+
+ constructor(obj?: any) {
+ if (obj) {
+ this.isReadOnly = obj.isReadOnly ? true : false;
+ this.isAuditEnabled = obj.isAuditEnabled ? true : false;
+ this.isQuickShareEnabled = obj.isQuickShareEnabled ? true : false;
+ this.isThumbnailGenerationEnabled = obj.isThumbnailGenerationEnabled ? true : false;
+ }
+ }
+}
+
+export class VersionModuleModel {
+ id: string;
+ title: string;
+ description: string;
+ version: string;
+ installDate: string;
+ installState: string;
+ versionMin: string;
+ versionMax: string;
+
+ constructor(obj?: any) {
+ if (obj) {
+ this.id = obj.id || null;
+ this.title = obj.title || null;
+ this.description = obj.description || null;
+ this.version = obj.version || null;
+ this.installDate = obj.installDate || null;
+ this.installState = obj.installState || null;
+ this.versionMin = obj.versionMin || null;
+ this.versionMax = obj.versionMax || null;
+ }
+ }
+}
diff --git a/ng2-components/ng2-alfresco-core/src/services/discovery-api.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/discovery-api.service.spec.ts
new file mode 100644
index 0000000000..6775c76d43
--- /dev/null
+++ b/ng2-components/ng2-alfresco-core/src/services/discovery-api.service.spec.ts
@@ -0,0 +1,190 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { async, TestBed } from '@angular/core/testing';
+import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
+import { AlfrescoApiService } from './alfresco-api.service';
+import { AlfrescoSettingsService } from './alfresco-settings.service';
+import { AppConfigModule } from './app-config.service';
+import { AuthenticationService } from './authentication.service';
+import { DiscoveryApiService } from './discovery-api.service';
+import { StorageService } from './storage.service';
+import { UserPreferencesService } from './user-preferences.service';
+
+declare let jasmine: any;
+
+let fakeEcmDiscoveryResponse: any = {
+ 'entry': {
+ 'repository': {
+ 'edition': 'FAKE',
+ 'version': {
+ 'major': '5',
+ 'minor': '2',
+ 'patch': '0',
+ 'hotfix': '0',
+ 'schema': 999999,
+ 'label': 'r134899-b26',
+ 'display': '5.2.0.0 (r134899-b26) schema 10005'
+ },
+ 'license': {
+ 'issuedAt': '2017-06-22T10:56:45.796+0000',
+ 'expiresAt': '2017-07-22T00:00:00.000+0000',
+ 'remainingDays': 4,
+ 'holder': 'Trial User',
+ 'mode': 'ENTERPRISE',
+ 'entitlements': {
+ 'isClusterEnabled': false,
+ 'isCryptodocEnabled': false
+ }
+ },
+ 'status': {
+ 'isReadOnly': false,
+ 'isAuditEnabled': true,
+ 'isQuickShareEnabled': true,
+ 'isThumbnailGenerationEnabled': true
+ },
+ 'modules': [
+ {
+ 'id': 'alfresco-fake-services',
+ 'title': 'Alfresco Share Services AMP',
+ 'description': 'Module to be applied to alfresco.war, containing APIs for Alfresco Share',
+ 'version': '5.2.0',
+ 'installDate': '2017-03-07T08:48:14.161+0000',
+ 'installState': 'INSTALLED',
+ 'versionMin': '5.1',
+ 'versionMax': '999'
+ },
+ {
+ 'id': 'alfresco-trashcan-fake',
+ 'title': 'alfresco-trashcan-cleaner project',
+ 'description': 'The Alfresco Trash Can Cleaner (Alfresco Module)',
+ 'version': '2.2',
+ 'installState': 'UNKNOWN',
+ 'versionMin': '0',
+ 'versionMax': '999'
+ }
+ ]
+ }
+ }
+};
+
+let fakeBPMDiscoveryResponse: any = {
+ 'revisionVersion': '2',
+ 'edition': 'SUPER FAKE EDITION',
+ 'type': 'bpmSuite',
+ 'majorVersion': '1',
+ 'minorVersion': '6'
+ };
+
+fdescribe('Discovery Api Service', () => {
+
+ let service;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ AppConfigModule.forRoot('app.config.json', {
+ ecmHost: 'http://localhost:9876/ecm'
+ })
+ ],
+ providers: [
+ DiscoveryApiService,
+ AlfrescoApiService,
+ UserPreferencesService,
+ AuthenticationService,
+ AlfrescoSettingsService,
+ StorageService
+ ]
+ }).compileComponents();
+ }));
+
+ beforeEach(() => {
+ service = TestBed.get(DiscoveryApiService);
+ jasmine.Ajax.install();
+ });
+
+ afterEach(() => {
+ jasmine.Ajax.uninstall();
+ });
+
+ describe('For ECM', () => {
+ it('Should retrieve the info about the product for ECM', (done) => {
+ service.getEcmProductInfo().subscribe((data: EcmProductVersionModel) => {
+ expect(data).not.toBeNull();
+ expect(data.edition).toBe('FAKE');
+ expect(data.version.schema).toBe(999999);
+ expect(data.license.isClusterEnabled).toBeFalsy();
+ expect(data.status.isQuickShareEnabled).toBeTruthy();
+ expect(data.modules.length).toBe(2);
+ expect(data.modules[0].id).toBe('alfresco-fake-services');
+ expect(data.modules[1].id).toBe('alfresco-trashcan-fake');
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ status: 200,
+ contentType: 'json',
+ responseText: fakeEcmDiscoveryResponse
+ });
+ });
+
+ it('getEcmProductInfo catch errors call', (done) => {
+ service.getEcmProductInfo().subscribe(
+ () => {
+ },
+ () => {
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ status: 403
+ });
+ });
+ });
+
+ describe('For BPM', () => {
+ it('Should retrieve the info about the product for BPM', (done) => {
+ service.getBpmProductInfo().subscribe((data: BpmProductVersionModel) => {
+ expect(data).not.toBeNull();
+ expect(data.edition).toBe('SUPER FAKE EDITION');
+ expect(data.revisionVersion).toBe('2');
+ expect(data.type).toBe('bpmSuite');
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ status: 200,
+ contentType: 'json',
+ responseText: fakeBPMDiscoveryResponse
+ });
+ });
+
+ it('getBpmProductInfo catch errors call', (done) => {
+ service.getBpmProductInfo().subscribe(
+ () => {
+ },
+ () => {
+ done();
+ });
+
+ jasmine.Ajax.requests.mostRecent().respondWith({
+ status: 403
+ });
+ });
+ });
+
+});
diff --git a/ng2-components/ng2-alfresco-core/src/services/discovery-api.service.ts b/ng2-components/ng2-alfresco-core/src/services/discovery-api.service.ts
new file mode 100644
index 0000000000..9f4c397eca
--- /dev/null
+++ b/ng2-components/ng2-alfresco-core/src/services/discovery-api.service.ts
@@ -0,0 +1,45 @@
+/*!
+ * @license
+ * Copyright 2016 Alfresco Software, Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs/Rx';
+import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
+import { AlfrescoApiService } from './alfresco-api.service';
+
+@Injectable()
+export class DiscoveryApiService {
+
+ constructor(private apiService: AlfrescoApiService) { }
+
+ public getEcmProductInfo() {
+ return Observable.fromPromise(
+ this.apiService.getInstance().discovery.discoveryApi.getRepositoryInformation())
+ .map(res => new EcmProductVersionModel(res))
+ .catch(this.handleError);
+ }
+
+ public getBpmProductInfo() {
+ return Observable.fromPromise(
+ this.apiService.getInstance().activiti.aboutApi.getAppVersion())
+ .map(res => new BpmProductVersionModel(res))
+ .catch(this.handleError);
+ }
+
+ private handleError(error): Observable
{
+ return Observable.throw(error);
+ }
+}