mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-487] added discovery information to about component (#2102)
* [ADF-487] - added discovery service to core * [ADF-487]- added activiti about call * [ADF-487] added discovery info into about component * [ADF-487] removed wrong console log * [ADF-487] fixed problem on index
This commit is contained in:
@@ -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';
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -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
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
@@ -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<any> {
|
||||
return Observable.throw(error);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user