mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-10766] presentational and reusable About (#7969)
This commit is contained in:
@@ -15,142 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { AppExtensionService, ExtensionRef } from '@alfresco/adf-extensions';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
|
||||
import { BpmProductVersionModel } from '../models/product-version.model';
|
||||
import { AuthenticationService } from '../services/authentication.service';
|
||||
import { DiscoveryApiService } from '../services/discovery-api.service';
|
||||
import { LicenseData, PackageInfo, StatusData } from './interfaces';
|
||||
import { ObjectUtils } from '../utils/object-utils';
|
||||
import { StringUtils } from '../utils/string-utils';
|
||||
|
||||
interface RepositoryInfo {
|
||||
status: {
|
||||
isReadOnly: boolean;
|
||||
isAuditEnabled: boolean;
|
||||
isQuickShareEnabled: boolean;
|
||||
isThumbnailGenerationEnabled: boolean;
|
||||
isDirectAccessUrlEnabled: boolean;
|
||||
};
|
||||
edition: string;
|
||||
version: {
|
||||
display: string;
|
||||
};
|
||||
license?: {
|
||||
issuedAt: Date;
|
||||
expiresAt: Date;
|
||||
remainingDays: number;
|
||||
holder: string;
|
||||
mode: string;
|
||||
entitlements?: {
|
||||
maxUsers?: number;
|
||||
maxDocs?: number;
|
||||
isClusterEnabled?: boolean;
|
||||
isCryptodocEnabled?: boolean;
|
||||
};
|
||||
};
|
||||
modules?: Array<{
|
||||
title: string;
|
||||
version: string;
|
||||
}>;
|
||||
}
|
||||
import { Component, ContentChildren, QueryList, ViewEncapsulation } from '@angular/core';
|
||||
import { AboutPanelDirective } from './about-panel.directive';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-about',
|
||||
templateUrl: './about.component.html',
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class AboutComponent implements OnInit {
|
||||
|
||||
repository: RepositoryInfo = null;
|
||||
bpmVersion: BpmProductVersionModel = null;
|
||||
|
||||
statusEntries: StatusData[];
|
||||
licenseEntries: LicenseData[];
|
||||
|
||||
dependencyEntries: PackageInfo[] = [];
|
||||
version: string;
|
||||
dependencies: string;
|
||||
application: string;
|
||||
|
||||
/** If active show more information about the app and the platform useful in debug. */
|
||||
@Input() dev: boolean = false;
|
||||
|
||||
/** pkg json. */
|
||||
@Input() pkg: any;
|
||||
|
||||
/** Regular expression for filtering dependencies packages. */
|
||||
@Input() regexp = '^(@alfresco)';
|
||||
|
||||
extensions$: Observable<ExtensionRef[]>;
|
||||
|
||||
constructor(private authService: AuthenticationService,
|
||||
private discovery: DiscoveryApiService,
|
||||
private appExtensions: AppExtensionService,
|
||||
private appConfigService: AppConfigService) {
|
||||
this.extensions$ = this.appExtensions.references$;
|
||||
this.application = this.appConfigService.get<string>(
|
||||
'application.name'
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.version = this.pkg?.version;
|
||||
this.dependencies = this.pkg?.dependencies;
|
||||
|
||||
if (this.dependencies) {
|
||||
const alfrescoPackages = Object.keys(this.dependencies).filter((val) => new RegExp(this.regexp).test(val));
|
||||
|
||||
alfrescoPackages.forEach((val) => {
|
||||
this.dependencyEntries.push({
|
||||
name: val,
|
||||
version: (this.dependencies[val])
|
||||
});
|
||||
});
|
||||
}
|
||||
if (this.authService.isEcmLoggedIn()) {
|
||||
this.setECMInfo();
|
||||
}
|
||||
|
||||
if (this.authService.isBpmLoggedIn()) {
|
||||
this.setBPMInfo();
|
||||
}
|
||||
}
|
||||
|
||||
setECMInfo() {
|
||||
this.discovery.getEcmProductInfo().subscribe((repository) => {
|
||||
this.repository = repository as RepositoryInfo;
|
||||
|
||||
this.statusEntries = Object.keys(repository.status).map((key) => ({
|
||||
property: key,
|
||||
value: repository.status[key]
|
||||
}));
|
||||
|
||||
if (repository.license) {
|
||||
this.licenseEntries = Object.keys(repository.license).map((key) => {
|
||||
if (ObjectUtils.isObject(repository.license[key])) {
|
||||
return {
|
||||
property: key,
|
||||
value: ObjectUtils.booleanPrettify(repository.license[key], StringUtils.prettifyBooleanEnabled)
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
property: key,
|
||||
value: repository.license[key]
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setBPMInfo() {
|
||||
this.discovery.getBpmProductInfo().subscribe((bpmVersion) => {
|
||||
this.bpmVersion = bpmVersion;
|
||||
});
|
||||
}
|
||||
|
||||
export class AboutComponent {
|
||||
@ContentChildren(AboutPanelDirective)
|
||||
panels: QueryList<AboutPanelDirective>;
|
||||
}
|
||||
|
Reference in New Issue
Block a user