mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4816] Refactor About component (#5000)
* [ADF-4816] Refactor About component * Update package.json
This commit is contained in:
committed by
Maurizio Vitale
parent
f5c5e7cf9e
commit
e7c0852051
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import { Component, OnInit, ViewEncapsulation, Input } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { AuthenticationService } from '../services/authentication.service';
|
||||
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
|
||||
import { DiscoveryApiService } from '../services/discovery-api.service';
|
||||
@@ -33,7 +32,7 @@ import { ExtensionRef, AppExtensionService } from '@alfresco/adf-extensions';
|
||||
})
|
||||
export class AboutComponent implements OnInit {
|
||||
|
||||
data: ObjectDataTableAdapter;
|
||||
dependencyEntries: ObjectDataTableAdapter;
|
||||
status: ObjectDataTableAdapter;
|
||||
license: ObjectDataTableAdapter;
|
||||
modules: ObjectDataTableAdapter;
|
||||
@@ -51,150 +50,142 @@ export class AboutComponent implements OnInit {
|
||||
/** Regular expression for filtering dependencies packages. */
|
||||
@Input() regexp = '^(@alfresco)';
|
||||
|
||||
/** Current version of the app running */
|
||||
@Input() version: string;
|
||||
|
||||
/** Current version of the app running */
|
||||
@Input() dependencies: any;
|
||||
|
||||
ecmHost = '';
|
||||
bpmHost = '';
|
||||
application: string;
|
||||
|
||||
ecmVersion: EcmProductVersionModel = null;
|
||||
bpmVersion: BpmProductVersionModel = null;
|
||||
|
||||
constructor(private http: HttpClient,
|
||||
private appConfig: AppConfigService,
|
||||
constructor(private appConfig: AppConfigService,
|
||||
private authService: AuthenticationService,
|
||||
private discovery: DiscoveryApiService,
|
||||
appExtensions: AppExtensionService) {
|
||||
this.extensions$ = appExtensions.references$;
|
||||
this.ecmHost = this.appConfig.get<string>(AppConfigValues.ECMHOST);
|
||||
this.bpmHost = this.appConfig.get<string>(AppConfigValues.BPMHOST);
|
||||
this.application = this.appConfig.get<string>('application.name');
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
if (this.authService.isEcmLoggedIn()) {
|
||||
this.discovery.getEcmProductInfo().subscribe((ecmVers) => {
|
||||
this.ecmVersion = ecmVers;
|
||||
|
||||
this.modules = new ObjectDataTableAdapter(this.ecmVersion.modules, [
|
||||
{ type: 'text', key: 'id', title: 'ABOUT.TABLE_HEADERS.MODULES.ID', sortable: true },
|
||||
{ type: 'text', key: 'title', title: 'ABOUT.TABLE_HEADERS.MODULES.TITLE', sortable: true },
|
||||
{ type: 'text', key: 'version', title: 'ABOUT.TABLE_HEADERS.MODULES.DESCRIPTION', sortable: true },
|
||||
{
|
||||
type: 'text',
|
||||
key: 'installDate',
|
||||
title: 'ABOUT.TABLE_HEADERS.MODULES.INSTALL_DATE',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'installState',
|
||||
title: 'ABOUT.TABLE_HEADERS.MODULES.INSTALL_STATE',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'versionMin',
|
||||
title: 'ABOUT.TABLE_HEADERS.MODULES.VERSION_MIN',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'versionMax',
|
||||
title: 'ABOUT.TABLE_HEADERS.MODULES.VERSION_MAX',
|
||||
sortable: true
|
||||
}
|
||||
]);
|
||||
|
||||
this.status = new ObjectDataTableAdapter([this.ecmVersion.status], [
|
||||
{ type: 'text', key: 'isReadOnly', title: 'ABOUT.TABLE_HEADERS.STATUS.READ_ONLY', sortable: true },
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isAuditEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.STATUS.AUDIT_ENABLED',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isQuickShareEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.STATUS.QUICK_SHARE_ENABLED',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isThumbnailGenerationEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.STATUS.THUMBNAIL_ENABLED',
|
||||
sortable: true
|
||||
}
|
||||
]);
|
||||
|
||||
this.license = new ObjectDataTableAdapter([this.ecmVersion.license], [
|
||||
{ type: 'text', key: 'issuedAt', title: 'ABOUT.TABLE_HEADERS.LICENSE.ISSUES_AT', sortable: true },
|
||||
{ type: 'text', key: 'expiresAt', title: 'ABOUT.TABLE_HEADERS.LICENSE.EXPIRES_AT', sortable: true },
|
||||
{
|
||||
type: 'text',
|
||||
key: 'remainingDays',
|
||||
title: 'ABOUT.TABLE_HEADERS.LICENSE.REMAINING_DAYS',
|
||||
sortable: true
|
||||
},
|
||||
{ type: 'text', key: 'holder', title: 'ABOUT.TABLE_HEADERS.LICENSE.HOLDER', sortable: true },
|
||||
{ type: 'text', key: 'mode', title: 'ABOUT.TABLE_HEADERS.LICENSE.MODE', sortable: true },
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isClusterEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.LICENSE.CLUSTER_ENABLED',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isCryptodocEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.LICENSE.CRYPTODOC_ENABLED',
|
||||
sortable: true
|
||||
}
|
||||
]);
|
||||
});
|
||||
this.setECMInfo();
|
||||
}
|
||||
|
||||
if (this.authService.isBpmLoggedIn()) {
|
||||
this.discovery.getBpmProductInfo().subscribe((bpmVers) => {
|
||||
this.bpmVersion = bpmVers;
|
||||
});
|
||||
this.setBPMInfo();
|
||||
}
|
||||
|
||||
this.http.get('./versions.json?' + new Date()).subscribe((response: any) => {
|
||||
const alfrescoPackages = Object.keys(this.dependencies).filter((val) => {
|
||||
return new RegExp(this.regexp).test(val);
|
||||
});
|
||||
|
||||
const alfrescoPackages = Object.keys(response.dependencies).filter((val) => {
|
||||
return new RegExp(this.regexp).test(val);
|
||||
const alfrescoPackagesTableRepresentation = [];
|
||||
alfrescoPackages.forEach((val) => {
|
||||
alfrescoPackagesTableRepresentation.push({
|
||||
name: val,
|
||||
version: (this.dependencies[val])
|
||||
});
|
||||
});
|
||||
|
||||
const alfrescoPackagesTableRepresentation = [];
|
||||
alfrescoPackages.forEach((val) => {
|
||||
alfrescoPackagesTableRepresentation.push({
|
||||
name: val,
|
||||
version: (response.dependencies[val].version || response.dependencies[val].required.version)
|
||||
});
|
||||
});
|
||||
this.dependencyEntries = new ObjectDataTableAdapter(alfrescoPackagesTableRepresentation, [
|
||||
{ type: 'text', key: 'name', title: 'Name', sortable: true },
|
||||
{ type: 'text', key: 'version', title: 'Version', sortable: true }
|
||||
]);
|
||||
}
|
||||
|
||||
this.gitHubLinkCreation(alfrescoPackagesTableRepresentation);
|
||||
setECMInfo() {
|
||||
this.discovery.getEcmProductInfo().subscribe((ecmVers) => {
|
||||
this.ecmVersion = ecmVers;
|
||||
|
||||
this.data = new ObjectDataTableAdapter(alfrescoPackagesTableRepresentation, [
|
||||
{ type: 'text', key: 'name', title: 'Name', sortable: true },
|
||||
{ type: 'text', key: 'version', title: 'Version', sortable: true }
|
||||
this.modules = new ObjectDataTableAdapter(this.ecmVersion.modules, [
|
||||
{ type: 'text', key: 'id', title: 'ABOUT.TABLE_HEADERS.MODULES.ID', sortable: true },
|
||||
{ type: 'text', key: 'title', title: 'ABOUT.TABLE_HEADERS.MODULES.TITLE', sortable: true },
|
||||
{ type: 'text', key: 'version', title: 'ABOUT.TABLE_HEADERS.MODULES.DESCRIPTION', sortable: true },
|
||||
{
|
||||
type: 'text',
|
||||
key: 'installDate',
|
||||
title: 'ABOUT.TABLE_HEADERS.MODULES.INSTALL_DATE',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'installState',
|
||||
title: 'ABOUT.TABLE_HEADERS.MODULES.INSTALL_STATE',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'versionMin',
|
||||
title: 'ABOUT.TABLE_HEADERS.MODULES.VERSION_MIN',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'versionMax',
|
||||
title: 'ABOUT.TABLE_HEADERS.MODULES.VERSION_MAX',
|
||||
sortable: true
|
||||
}
|
||||
]);
|
||||
|
||||
});
|
||||
this.status = new ObjectDataTableAdapter([this.ecmVersion.status], [
|
||||
{ type: 'text', key: 'isReadOnly', title: 'ABOUT.TABLE_HEADERS.STATUS.READ_ONLY', sortable: true },
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isAuditEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.STATUS.AUDIT_ENABLED',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isQuickShareEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.STATUS.QUICK_SHARE_ENABLED',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isThumbnailGenerationEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.STATUS.THUMBNAIL_ENABLED',
|
||||
sortable: true
|
||||
}
|
||||
]);
|
||||
|
||||
this.ecmHost = this.appConfig.get<string>(AppConfigValues.ECMHOST);
|
||||
this.bpmHost = this.appConfig.get<string>(AppConfigValues.BPMHOST);
|
||||
this.license = new ObjectDataTableAdapter([this.ecmVersion.license], [
|
||||
{ type: 'text', key: 'issuedAt', title: 'ABOUT.TABLE_HEADERS.LICENSE.ISSUES_AT', sortable: true },
|
||||
{ type: 'text', key: 'expiresAt', title: 'ABOUT.TABLE_HEADERS.LICENSE.EXPIRES_AT', sortable: true },
|
||||
{
|
||||
type: 'text',
|
||||
key: 'remainingDays',
|
||||
title: 'ABOUT.TABLE_HEADERS.LICENSE.REMAINING_DAYS',
|
||||
sortable: true
|
||||
},
|
||||
{ type: 'text', key: 'holder', title: 'ABOUT.TABLE_HEADERS.LICENSE.HOLDER', sortable: true },
|
||||
{ type: 'text', key: 'mode', title: 'ABOUT.TABLE_HEADERS.LICENSE.MODE', sortable: true },
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isClusterEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.LICENSE.CLUSTER_ENABLED',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
key: 'isCryptodocEnabled',
|
||||
title: 'ABOUT.TABLE_HEADERS.LICENSE.CRYPTODOC_ENABLED',
|
||||
sortable: true
|
||||
}
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
private gitHubLinkCreation(alfrescoPackagesTableRepresentation): void {
|
||||
const corePackage = alfrescoPackagesTableRepresentation.find((packageUp) => {
|
||||
return packageUp.name === '@alfresco/adf-core';
|
||||
setBPMInfo() {
|
||||
this.discovery.getBpmProductInfo().subscribe((bpmVersion) => {
|
||||
this.bpmVersion = bpmVersion;
|
||||
});
|
||||
|
||||
if (corePackage) {
|
||||
const commitIsh = corePackage.version.split('-');
|
||||
if (commitIsh.length > 1) {
|
||||
this.githubUrlCommitAlpha = this.githubUrlCommitAlpha + commitIsh[1];
|
||||
} else {
|
||||
this.githubUrlCommitAlpha = this.githubUrlCommitAlpha + corePackage.version;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user