From 9772b2308aac21bad85523c17bf27194a896f0b5 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Thu, 17 May 2018 09:58:22 +0100 Subject: [PATCH] about component (#3337) --- .../app/components/about/about.component.html | 50 +------ .../app/components/about/about.component.ts | 117 +-------------- docs/core/about.component.md | 20 +++ lib/core/about/about.component.html | 49 +++++++ .../core/about/about.component.scss | 0 lib/core/about/about.component.ts | 135 ++++++++++++++++++ lib/core/about/about.module.ts | 41 ++++++ lib/core/about/index.ts | 18 +++ lib/core/about/public-api.ts | 20 +++ lib/core/core.module.ts | 5 + lib/core/index.ts | 1 + 11 files changed, 293 insertions(+), 163 deletions(-) create mode 100644 docs/core/about.component.md create mode 100644 lib/core/about/about.component.html rename demo-shell/src/app/components/about/about.component.css => lib/core/about/about.component.scss (100%) create mode 100644 lib/core/about/about.component.ts create mode 100644 lib/core/about/about.module.ts create mode 100644 lib/core/about/index.ts create mode 100644 lib/core/about/public-api.ts diff --git a/demo-shell/src/app/components/about/about.component.html b/demo-shell/src/app/components/about/about.component.html index 77adea7267..a0ef038ca4 100644 --- a/demo-shell/src/app/components/about/about.component.html +++ b/demo-shell/src/app/components/about/about.component.html @@ -1,49 +1 @@ -
-

Server settings

- - The values below are taken from the AppConfigService - -

Alfresco Process Services URL: {{ bpmHost }}

-
- - -

Alfresco Content Services URL: {{ ecmHost }}

-
-
- -

Product Versions

-
-

BPM

- {{ bpmVersion.edition }} -

- {{ bpmVersion.majorVersion }}.{{ bpmVersion.minorVersion }}.{{ bpmVersion.revisionVersion }} -
-
-

ECM

- {{ ecmVersion.edition }} -

- {{ ecmVersion.version.display }} -

-

License

- - -

Status

- - -

Modules

- - -
- -
-

Source code

- You are running the project based on the following commit: -
- {{githubUrlCommitAlpha}} -
-
- -

Packages

- Current project is using the following ADF libraries: - -
+ diff --git a/demo-shell/src/app/components/about/about.component.ts b/demo-shell/src/app/components/about/about.component.ts index 6b10c4d163..d3df258841 100644 --- a/demo-shell/src/app/components/about/about.component.ts +++ b/demo-shell/src/app/components/about/about.component.ts @@ -15,123 +15,12 @@ * limitations under the License. */ -import { Component, OnInit } from '@angular/core'; -import { Http } from '@angular/http'; -import { - AuthenticationService, - AppConfigService, - BpmProductVersionModel, - DiscoveryApiService, - EcmProductVersionModel, - ObjectDataTableAdapter -} from '@alfresco/adf-core'; +import { Component } from '@angular/core'; @Component({ selector: 'app-about-page', - templateUrl: './about.component.html', - styleUrls: ['./about.component.css'] + templateUrl: './about.component.html' }) -export class AboutComponent implements OnInit { +export class AboutComponent { - data: ObjectDataTableAdapter; - status: ObjectDataTableAdapter; - license: ObjectDataTableAdapter; - modules: ObjectDataTableAdapter; - githubUrlCommitAlpha = 'https://github.com/Alfresco/alfresco-ng2-components/commits/'; - - ecmHost = ''; - bpmHost = ''; - - ecmVersion: EcmProductVersionModel = null; - bpmVersion: BpmProductVersionModel = null; - - constructor(private http: Http, - private appConfig: AppConfigService, - private authService: AuthenticationService, - private discovery: DiscoveryApiService) { - } - - 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: 'ID', sortable: true }, - { type: 'text', key: 'title', title: 'Title', sortable: true }, - { type: 'text', key: 'version', title: 'Description', sortable: true }, - { type: 'text', key: 'installDate', title: 'Install Date', sortable: true }, - { type: 'text', key: 'installState', title: 'Install State', sortable: true }, - { type: 'text', key: 'versionMin', title: 'Version Minor', sortable: true }, - { type: 'text', key: 'versionMax', title: 'Version Max', sortable: true } - ]); - - this.status = new ObjectDataTableAdapter([this.ecmVersion.status], [ - { type: 'text', key: 'isReadOnly', title: 'ReadOnly', sortable: true }, - { type: 'text', key: 'isAuditEnabled', title: 'Is Audit Enable', sortable: true }, - { type: 'text', key: 'isQuickShareEnabled', title: 'Is quick shared enable', sortable: true }, - { type: 'text', key: 'isThumbnailGenerationEnabled', title: 'Thumbnail Generation', sortable: true } - ]); - - this.license = new ObjectDataTableAdapter([this.ecmVersion.license], [ - { type: 'text', key: 'issuedAt', title: 'Issued At', sortable: true }, - { type: 'text', key: 'expiresAt', title: 'Expires At', sortable: true }, - { type: 'text', key: 'remainingDays', title: 'Remaining Days', sortable: true }, - { type: 'text', key: 'holder', title: 'Holder', sortable: true }, - { type: 'text', key: 'mode', title: 'Mode', sortable: true }, - { type: 'text', key: 'isClusterEnabled', title: 'Is Cluster Enabled', sortable: true }, - { type: 'text', key: 'isCryptodocEnabled', title: 'Is Cryptodoc Enable', sortable: true } - ]); - }); - } - - if (this.authService.isBpmLoggedIn()) { - this.discovery.getBpmProductInfo().subscribe((bpmVers) => { - this.bpmVersion = bpmVers; - }); - } - - this.http.get('/versions.json?' + new Date()).subscribe(response => { - const regexp = new RegExp('^(@alfresco)'); - - const alfrescoPackages = Object.keys(response.json().dependencies).filter((val) => { - return regexp.test(val); - }); - - const alfrescoPackagesTableRepresentation = []; - alfrescoPackages.forEach((val) => { - alfrescoPackagesTableRepresentation.push({ - name: val, - version: response.json().dependencies[val].version - }); - }); - - this.gitHubLinkCreation(alfrescoPackagesTableRepresentation); - - this.data = new ObjectDataTableAdapter(alfrescoPackagesTableRepresentation, [ - { type: 'text', key: 'name', title: 'Name', sortable: true }, - { type: 'text', key: 'version', title: 'Version', sortable: true } - ]); - - }); - - this.ecmHost = this.appConfig.get('ecmHost'); - this.bpmHost = this.appConfig.get('bpmHost'); - } - - private gitHubLinkCreation(alfrescoPackagesTableRepresentation): void { - const corePackage = alfrescoPackagesTableRepresentation.find((packageUp) => { - return packageUp.name === '@alfresco/adf-core'; - }); - - 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/docs/core/about.component.md b/docs/core/about.component.md new file mode 100644 index 0000000000..4fc27bac6c --- /dev/null +++ b/docs/core/about.component.md @@ -0,0 +1,20 @@ +--- +Added: v2.4.0 +Status: Experimental +Last reviewed: 2018-05-16 +--- + +# About Component + +This component allow you to have a general overview of the version of ADF installed and the status of the Content service and Process service +Note at the moment this component is mostly for internal use and it require: + +- create a version file : npm list --depth=0 --json=true --prod=true > versions.json +- provide this version file in the dist folder + +### Basic Usage + +```html + +``` + diff --git a/lib/core/about/about.component.html b/lib/core/about/about.component.html new file mode 100644 index 0000000000..77adea7267 --- /dev/null +++ b/lib/core/about/about.component.html @@ -0,0 +1,49 @@ +
+

Server settings

+ + The values below are taken from the AppConfigService + +

Alfresco Process Services URL: {{ bpmHost }}

+
+ + +

Alfresco Content Services URL: {{ ecmHost }}

+
+
+ +

Product Versions

+
+

BPM

+ {{ bpmVersion.edition }} +

+ {{ bpmVersion.majorVersion }}.{{ bpmVersion.minorVersion }}.{{ bpmVersion.revisionVersion }} +
+
+

ECM

+ {{ ecmVersion.edition }} +

+ {{ ecmVersion.version.display }} +

+

License

+ + +

Status

+ + +

Modules

+ + +
+ +
+

Source code

+ You are running the project based on the following commit: + +
+ +

Packages

+ Current project is using the following ADF libraries: + +
diff --git a/demo-shell/src/app/components/about/about.component.css b/lib/core/about/about.component.scss similarity index 100% rename from demo-shell/src/app/components/about/about.component.css rename to lib/core/about/about.component.scss diff --git a/lib/core/about/about.component.ts b/lib/core/about/about.component.ts new file mode 100644 index 0000000000..b322d8adc4 --- /dev/null +++ b/lib/core/about/about.component.ts @@ -0,0 +1,135 @@ +/*! + * @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 { Component, OnInit, ViewEncapsulation } from '@angular/core'; +import { Http } from '@angular/http'; +import { AuthenticationService } from '../services/authentication.service'; +import { AppConfigService } from '../app-config/app-config.service'; +import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model'; +import { DiscoveryApiService } from '../services/discovery-api.service'; +import { ObjectDataTableAdapter } from '../datatable/data/object-datatable-adapter'; + +@Component({ + selector: 'adf-about', + templateUrl: './about.component.html', + styleUrls: ['./about.component.scss'], + encapsulation: ViewEncapsulation.None +}) +export class AboutComponent implements OnInit { + + data: ObjectDataTableAdapter; + status: ObjectDataTableAdapter; + license: ObjectDataTableAdapter; + modules: ObjectDataTableAdapter; + githubUrlCommitAlpha = 'https://github.com/Alfresco/alfresco-ng2-components/commits/'; + + ecmHost = ''; + bpmHost = ''; + + ecmVersion: EcmProductVersionModel = null; + bpmVersion: BpmProductVersionModel = null; + + constructor(private http: Http, + private appConfig: AppConfigService, + private authService: AuthenticationService, + private discovery: DiscoveryApiService) { + } + + 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: 'ID', sortable: true }, + { type: 'text', key: 'title', title: 'Title', sortable: true }, + { type: 'text', key: 'version', title: 'Description', sortable: true }, + { type: 'text', key: 'installDate', title: 'Install Date', sortable: true }, + { type: 'text', key: 'installState', title: 'Install State', sortable: true }, + { type: 'text', key: 'versionMin', title: 'Version Minor', sortable: true }, + { type: 'text', key: 'versionMax', title: 'Version Max', sortable: true } + ]); + + this.status = new ObjectDataTableAdapter([this.ecmVersion.status], [ + { type: 'text', key: 'isReadOnly', title: 'ReadOnly', sortable: true }, + { type: 'text', key: 'isAuditEnabled', title: 'Is Audit Enable', sortable: true }, + { type: 'text', key: 'isQuickShareEnabled', title: 'Is quick shared enable', sortable: true }, + { type: 'text', key: 'isThumbnailGenerationEnabled', title: 'Thumbnail Generation', sortable: true } + ]); + + this.license = new ObjectDataTableAdapter([this.ecmVersion.license], [ + { type: 'text', key: 'issuedAt', title: 'Issued At', sortable: true }, + { type: 'text', key: 'expiresAt', title: 'Expires At', sortable: true }, + { type: 'text', key: 'remainingDays', title: 'Remaining Days', sortable: true }, + { type: 'text', key: 'holder', title: 'Holder', sortable: true }, + { type: 'text', key: 'mode', title: 'Mode', sortable: true }, + { type: 'text', key: 'isClusterEnabled', title: 'Is Cluster Enabled', sortable: true }, + { type: 'text', key: 'isCryptodocEnabled', title: 'Is Cryptodoc Enable', sortable: true } + ]); + }); + } + + if (this.authService.isBpmLoggedIn()) { + this.discovery.getBpmProductInfo().subscribe((bpmVers) => { + this.bpmVersion = bpmVers; + }); + } + + this.http.get('/versions.json?' + new Date()).subscribe(response => { + const regexp = new RegExp('^(@alfresco)'); + + const alfrescoPackages = Object.keys(response.json().dependencies).filter((val) => { + return regexp.test(val); + }); + + const alfrescoPackagesTableRepresentation = []; + alfrescoPackages.forEach((val) => { + alfrescoPackagesTableRepresentation.push({ + name: val, + version: response.json().dependencies[val].version + }); + }); + + this.gitHubLinkCreation(alfrescoPackagesTableRepresentation); + + this.data = new ObjectDataTableAdapter(alfrescoPackagesTableRepresentation, [ + { type: 'text', key: 'name', title: 'Name', sortable: true }, + { type: 'text', key: 'version', title: 'Version', sortable: true } + ]); + + }); + + this.ecmHost = this.appConfig.get('ecmHost'); + this.bpmHost = this.appConfig.get('bpmHost'); + } + + private gitHubLinkCreation(alfrescoPackagesTableRepresentation): void { + const corePackage = alfrescoPackagesTableRepresentation.find((packageUp) => { + return packageUp.name === '@alfresco/adf-core'; + }); + + 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/about/about.module.ts b/lib/core/about/about.module.ts new file mode 100644 index 0000000000..17cfa33210 --- /dev/null +++ b/lib/core/about/about.module.ts @@ -0,0 +1,41 @@ +/*! + * @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 { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { TranslateModule } from '@ngx-translate/core'; +import { MaterialModule } from '../material.module'; +import { AboutComponent } from './about.component'; +import { DataTableModule } from '../datatable/datatable.module'; +import { DataColumnModule } from '../data-column/data-column.module'; + +@NgModule({ + imports: [ + CommonModule, + MaterialModule, + TranslateModule, + DataTableModule, + DataColumnModule + ], + declarations: [ + AboutComponent + ], + exports: [ + AboutComponent + ] +}) +export class AboutModule {} diff --git a/lib/core/about/index.ts b/lib/core/about/index.ts new file mode 100644 index 0000000000..4c6ac1d58f --- /dev/null +++ b/lib/core/about/index.ts @@ -0,0 +1,18 @@ +/*! + * @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 * from './public-api'; diff --git a/lib/core/about/public-api.ts b/lib/core/about/public-api.ts new file mode 100644 index 0000000000..2d725cb762 --- /dev/null +++ b/lib/core/about/public-api.ts @@ -0,0 +1,20 @@ +/*! + * @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 * from './about.component'; + +export * from './about.module'; diff --git a/lib/core/core.module.ts b/lib/core/core.module.ts index 6b66a8ce54..610d9f773c 100644 --- a/lib/core/core.module.ts +++ b/lib/core/core.module.ts @@ -22,6 +22,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { MaterialModule } from './material.module'; +import { AboutModule } from './about/about.module'; import { AppConfigModule } from './app-config/app-config.module'; import { CardViewModule } from './card-view/card-view.module'; import { CollapsableModule } from './collapsable/collapsable.module'; @@ -127,6 +128,7 @@ export function providers() { @NgModule({ imports: [ + AboutModule, ViewerModule, SidenavLayoutModule, PipeModule, @@ -161,6 +163,7 @@ export function providers() { }) ], exports: [ + AboutModule, ViewerModule, SidenavLayoutModule, PipeModule, @@ -194,6 +197,7 @@ export class CoreModuleLazy { @NgModule({ imports: [ + AboutModule, ViewerModule, SidenavLayoutModule, PipeModule, @@ -231,6 +235,7 @@ export class CoreModuleLazy { EmptyContentComponent ], exports: [ + AboutModule, ViewerModule, SidenavLayoutModule, PipeModule, diff --git a/lib/core/index.ts b/lib/core/index.ts index 26249a4d00..332048bc4e 100644 --- a/lib/core/index.ts +++ b/lib/core/index.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +export * from './about/index'; export * from './viewer/index'; export * from './userinfo/index'; export * from './toolbar/index';