From e7c085205178b3b6ba1e1cd5730fa4e620023550 Mon Sep 17 00:00:00 2001 From: davidcanonieto Date: Mon, 19 Aug 2019 15:29:16 +0100 Subject: [PATCH] [ADF-4816] Refactor About component (#5000) * [ADF-4816] Refactor About component * Update package.json --- angular.json | 6 +- .../app/components/about/about.component.html | 6 +- .../app/components/about/about.component.ts | 5 + demo-shell/tsconfig.json | 1 + lib/core/about/about.component.html | 118 +++++---- lib/core/about/about.component.ts | 225 +++++++++--------- lib/core/i18n/en.json | 1 + package.json | 3 +- 8 files changed, 196 insertions(+), 169 deletions(-) diff --git a/angular.json b/angular.json index a562a5e39d..29961bc3a4 100644 --- a/angular.json +++ b/angular.json @@ -227,7 +227,8 @@ "./demo-shell/src/tsconfig.app.json" ], "exclude": [ - "**/node_modules/**/*" + "**/node_modules/**/*", + "package.json" ] } } @@ -525,7 +526,8 @@ "./demo-shell/src/tsconfig.app.json" ], "exclude": [ - "**/node_modules/**/*" + "**/node_modules/**/*", + "package.json" ] } } diff --git a/demo-shell/src/app/components/about/about.component.html b/demo-shell/src/app/components/about/about.component.html index a0ef038ca4..b2723bf895 100644 --- a/demo-shell/src/app/components/about/about.component.html +++ b/demo-shell/src/app/components/about/about.component.html @@ -1 +1,5 @@ - + + diff --git a/demo-shell/src/app/components/about/about.component.ts b/demo-shell/src/app/components/about/about.component.ts index 93d5093a99..e8ed612ac5 100644 --- a/demo-shell/src/app/components/about/about.component.ts +++ b/demo-shell/src/app/components/about/about.component.ts @@ -16,6 +16,7 @@ */ import { Component } from '@angular/core'; +import { name, version, commit, dependencies } from '../../../../../package.json'; @Component({ selector: 'app-about-page', @@ -24,6 +25,10 @@ import { Component } from '@angular/core'; }) export class AboutComponent { + githubUrlCommitAlpha = `https://github.com/Alfresco/${name}/commits/${commit}`; + version = version; + dependencies = dependencies; + constructor() { } diff --git a/demo-shell/tsconfig.json b/demo-shell/tsconfig.json index f18fbd25c0..c7ca5b1060 100644 --- a/demo-shell/tsconfig.json +++ b/demo-shell/tsconfig.json @@ -1,6 +1,7 @@ { "compileOnSave": false, "compilerOptions": { + "resolveJsonModule": true, "outDir": "./dist/out-tsc", "baseUrl": "src", "sourceMap": true, diff --git a/lib/core/about/about.component.html b/lib/core/about/about.component.html index 95098efa4f..8d9eae91d5 100644 --- a/lib/core/about/about.component.html +++ b/lib/core/about/about.component.html @@ -1,4 +1,74 @@
+

{{ application }}

+ +
+

{{ 'ABOUT.SOURCE_CODE.TITLE' | translate }}

+ +

{{ 'ABOUT.VERSION' | translate }}: {{ version }}

+ +
+ {{ 'ABOUT.SOURCE_CODE.DESCRIPTION' | translate }} + +
+
+
+ +

{{ 'ABOUT.SERVER_SETTINGS.TITLE' | translate }}

+ {{ 'ABOUT.SERVER_SETTINGS.DESCRIPTION' | translate }} + +

+ {{ 'ABOUT.SERVER_SETTINGS.PROCESS_SERVICE_HOST' | translate: { value: bpmHost } }} +

+

+ {{ 'ABOUT.SERVER_SETTINGS.CONTENT_SERVICE_HOST' | translate: { value: ecmHost } }} +

+
+ + +

{{ 'ABOUT.VERSIONS.TITLE' | translate }}

+
+ +
+

{{ 'ABOUT.VERSIONS.PROCESS_SERVICE' | translate }}

+

+ {{ 'ABOUT.VERSIONS.LABELS.EDITION' | translate }}: {{ bpmVersion.edition }} +

+

+ {{ 'ABOUT.VERSIONS.LABELS.VERSION' | translate }}: {{ bpmVersion.majorVersion }}.{{ + bpmVersion.minorVersion }}.{{ bpmVersion.revisionVersion }} +

+
+ +
+

{{ 'ABOUT.VERSIONS.CONTENT_SERVICE' | translate }}

+

+ {{ 'ABOUT.VERSIONS.LABELS.EDITION' | translate }}: {{ ecmVersion.edition }} +

+

+ {{ 'ABOUT.VERSIONS.LABELS.VERSION' | translate }}: {{ ecmVersion.version.display }} +

+ +
+
+
+ +
+

{{ 'ABOUT.VERSIONS.LABELS.LICENSE' | translate }}

+ + +

{{ 'ABOUT.VERSIONS.LABELS.STATUS' | translate }}

+ + +

{{ 'ABOUT.VERSIONS.LABELS.MODULES' | translate }}

+ +
+ +

{{ 'ABOUT.PACKAGES.TITLE' | translate }}

+ {{ 'ABOUT.PACKAGES.DESCRIPTION' | translate }} + +

{{ 'ABOUT.TITLE' | translate }}

@@ -48,52 +118,4 @@
-

{{ 'ABOUT.SERVER_SETTINGS.TITLE' | translate }}

- - {{ 'ABOUT.SERVER_SETTINGS.DESCRIPTION' | translate }} - -

{{ 'ABOUT.SERVER_SETTINGS.PROCESS_SERVICE_HOST' | translate: { value: bpmHost } }}

-
- - -

{{ 'ABOUT.SERVER_SETTINGS.CONTENT_SERVICE_HOST' | translate: { value: ecmHost } }}

-
-
- -

{{ 'ABOUT.VERSIONS.TITLE' | translate }}

-
-

{{ 'ABOUT.VERSIONS.PROCESS_SERVICE' | translate }}

-
{{ 'ABOUT.VERSIONS.divS.EDITION' | translate }}
{{ bpmVersion.edition }} -

-
{{ 'ABOUT.VERSIONS.divS.VERSION' | translate }}
{{ bpmVersion.majorVersion }}.{{ - bpmVersion.minorVersion }}.{{ bpmVersion.revisionVersion }} -
-
-

{{ 'ABOUT.VERSIONS.CONTENT_SERVICE' | translate }}

-
{{ 'ABOUT.VERSIONS.divS.EDITION' | translate }}
{{ ecmVersion.edition }} -

-
{{ 'ABOUT.VERSIONS.divS.VERSION' | translate }}
{{ ecmVersion.version.display }} -

-

{{ 'ABOUT.VERSIONS.divS.LICENSE' | translate }}

- - -

{{ 'ABOUT.VERSIONS.divS.STATUS' | translate }}

- - -

{{ 'ABOUT.VERSIONS.divS.MODULES' | translate }}

- - -
- -
-

{{ 'ABOUT.SOURCE_CODE.TITLE' | translate }}

- {{ 'ABOUT.SOURCE_CODE.DESCRIPTION' | translate }} -
- {{githubUrlCommitAlpha}} -
-
- -

{{ 'ABOUT.PACKAGES.TITLE' | translate }}

- {{ 'ABOUT.PACKAGES.DESCRIPTION' | translate }} -
diff --git a/lib/core/about/about.component.ts b/lib/core/about/about.component.ts index e70fd64782..da62ef66c1 100644 --- a/lib/core/about/about.component.ts +++ b/lib/core/about/about.component.ts @@ -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(AppConfigValues.ECMHOST); + this.bpmHost = this.appConfig.get(AppConfigValues.BPMHOST); + this.application = this.appConfig.get('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(AppConfigValues.ECMHOST); - this.bpmHost = this.appConfig.get(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; - } - } } } diff --git a/lib/core/i18n/en.json b/lib/core/i18n/en.json index af0fe90868..9937d1ead5 100644 --- a/lib/core/i18n/en.json +++ b/lib/core/i18n/en.json @@ -386,6 +386,7 @@ } }, "ABOUT": { + "VERSION": "Version", "SERVER_SETTINGS": { "TITLE": "Server settings", "DESCRIPTION": "The values below are taken from the AppConfigService", diff --git a/package.json b/package.json index 11108dd138..5fedae0490 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { - "name": "alfresco-components", + "name": "alfresco-ng2-components", + "commit": "b644b39d17396330d2a67509f58c5b9e890b9b13", "description": "Alfresco Angular components", "version": "3.4.0", "author": "Alfresco Software, Ltd.",