From a368ce034441b9158456e6ced99f62eecb5e2b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Mon, 25 Jan 2021 00:44:50 +0200 Subject: [PATCH] License info screen --- .../src/app/app-config/app-config.service.ts | 10 +- apps/red-ui/src/app/app.module.ts | 12 ++- .../admin-breadcrumbs.component.html | 9 ++ .../license-information-screen.component.html | 99 +++++++++++++++++++ .../license-information-screen.component.scss | 37 +++++++ .../license-information-screen.component.ts | 47 +++++++++ apps/red-ui/src/assets/config/config.json | 8 +- apps/red-ui/src/assets/i18n/en.json | 19 ++++ 8 files changed, 238 insertions(+), 3 deletions(-) create mode 100644 apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.html create mode 100644 apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.scss create mode 100644 apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.ts diff --git a/apps/red-ui/src/app/app-config/app-config.service.ts b/apps/red-ui/src/app/app-config/app-config.service.ts index 63206700c..fa020e725 100644 --- a/apps/red-ui/src/app/app-config/app-config.service.ts +++ b/apps/red-ui/src/app/app-config/app-config.service.ts @@ -12,7 +12,15 @@ export enum AppConfigKey { ADMIN_CONTACT_URL = 'ADMIN_CONTACT_URL', AUTO_READ_TIME = 'AUTO_READ_TIME', MAX_FILE_SIZE_MB = 'MAX_FILE_SIZE_MB', - APP_NAME = 'APP_NAME' + APP_NAME = 'APP_NAME', + + // TODO + BACKEND_APP_VERSION = 'BACKEND_APP_VERSION', + FRONTEND_APP_VERSION = 'FRONTEND_APP_VERSION', + EULA_URL = 'EULA_URL', + LICENSEE = 'LICENSEE', + LICENSING_START = 'LICENSING_START', + LICENSING_END = 'LICENSING_END' } @Injectable({ diff --git a/apps/red-ui/src/app/app.module.ts b/apps/red-ui/src/app/app.module.ts index 32cb2d4e9..55655d7ed 100644 --- a/apps/red-ui/src/app/app.module.ts +++ b/apps/red-ui/src/app/app.module.ts @@ -107,6 +107,7 @@ import { PendingChangesGuard } from './utils/can-deactivate.guard'; import { OverwriteFilesDialogComponent } from './dialogs/overwrite-files-dialog/overwrite-files-dialog.component'; import { KeycloakService } from 'keycloak-angular'; import { FileDownloadBtnComponent } from './components/buttons/file-download-btn/file-download-btn.component'; +import { LicenseInformationScreenComponent } from './screens/admin/license-information-screen/license-information-screen.component'; export function HttpLoaderFactory(httpClient: HttpClient) { return new TranslateHttpLoader(httpClient, '/assets/i18n/', '.json'); @@ -241,6 +242,14 @@ const routes = [ data: { routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard] } + }, + { + path: 'license-info', + component: LicenseInformationScreenComponent, + canActivate: [CompositeRouteGuard], + data: { + routeGuards: [AuthGuard, RedRoleGuard, AppStateGuard] + } } ] } @@ -334,7 +343,8 @@ const matImports = [ FileDownloadBtnComponent, ProjectListingActionsComponent, RuleSetActionsComponent, - RuleSetViewSwitchComponent + RuleSetViewSwitchComponent, + LicenseInformationScreenComponent ], imports: [ BrowserModule, diff --git a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html index f1958e01c..5752f40a6 100644 --- a/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html +++ b/apps/red-ui/src/app/components/admin-page-header/admin-breadcrumbs.component.html @@ -17,6 +17,15 @@ *ngIf="root && userPreferenceService.areDevFeaturesEnabled" > + + + + +
+
+
+
+
+
{{ appConfigService.getConfig('BACKEND_APP_VERSION', '-') }}
+
+ +
+
+
{{ appConfigService.getConfig('FRONTEND_APP_VERSION', '-') }}
+
+ +
+
+
{{ appConfigService.getConfig('APP_NAME', '-') }}
+
+ +
+
+
{{ 'license-info-screen.copyright-claim-text' | translate: { currentYear: currentYear } }}
+
+ +
+
+
+
+ + + + + + + +
+ +
+
+
{{ appConfigService.getConfig('LICENSEE', '-') }}
+
+ +
+
+
{{ appConfigService.getConfig('LICENSING_START', '-') }} / {{ appConfigService.getConfig('LICENSING_END', '-') }}
+
+ +
+
+
{{ currentInfo.numberOfAnalyzedPages }}
+
+ +
+ +
+
{{ 'license-info-screen.total-analyzed' | translate: { date: totalInfo.startDate | date: 'longDate' } }}
+
{{ totalInfo.numberOfAnalyzedPages }}
+
+ +
+
+
+ {{ currentInfo.numberOfAnalyzedPages }} ({{ + (currentInfo.numberOfAnalyzedPages / totalInfo.numberOfAnalyzedPages) * 100 | number: '1.0-2' + }}%) +
+
+ +
+
+
{{ unlicensedInfo.numberOfAnalyzedPages }}
+
+ + + + + + +
+
+
+ + + diff --git a/apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.scss b/apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.scss new file mode 100644 index 000000000..85b8c4784 --- /dev/null +++ b/apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.scss @@ -0,0 +1,37 @@ +@import '../../../../assets/styles/red-mixins'; +@import '../../../../assets/styles/red-variables'; + +.left-container { + width: 100vw; + @include inset-shadow; +} + +.grid-container { + grid-template-columns: 1fr 2fr; + margin: 20px; + + .row { + display: contents; + + > div { + padding: 8px 20px; + + &:first-of-type { + font-weight: 600; + } + } + + &:hover { + > div { + background-color: $grey-2; + } + } + } + + .section-title { + grid-column: span 2; + padding: 20px 20px 8px; + margin-bottom: 8px; + border-bottom: 1px solid $separator; + } +} diff --git a/apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.ts b/apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.ts new file mode 100644 index 000000000..6d5ecb7aa --- /dev/null +++ b/apps/red-ui/src/app/screens/admin/license-information-screen/license-information-screen.component.ts @@ -0,0 +1,47 @@ +import { Component } from '@angular/core'; +import { PermissionsService } from '../../../common/service/permissions.service'; +import { LicenseReport, LicenseReportControllerService } from '@redaction/red-ui-http'; +import { AppConfigService } from '../../../app-config/app-config.service'; +import * as moment from 'moment'; + +@Component({ + selector: 'redaction-license-information-screen', + templateUrl: './license-information-screen.component.html', + styleUrls: ['./license-information-screen.component.scss'] +}) +export class LicenseInformationScreenComponent { + public currentInfo: LicenseReport = {}; + public totalInfo: LicenseReport = {}; + public unlicensedInfo: LicenseReport = {}; + public viewReady = false; + + constructor( + public readonly permissionsService: PermissionsService, + private readonly _licenseReportController: LicenseReportControllerService, + public readonly appConfigService: AppConfigService + ) { + const startDate = moment(this.appConfigService.getConfig('LICENSING_START'), 'DD-MM-YYYY'); + const endDate = moment(this.appConfigService.getConfig('LICENSING_END'), 'DD-MM-YYYY'); + const currentConfig = { + startDate: startDate.toDate(), + endDate: endDate.toDate() + }; + const promises = [this._licenseReportController.licenseReport(currentConfig).toPromise(), this._licenseReportController.licenseReport({}).toPromise()]; + + if (endDate.isBefore(moment())) { + const unlicensedConfig = { + startDate: endDate.toDate() + }; + promises.push(this._licenseReportController.licenseReport(unlicensedConfig).toPromise()); + } + + Promise.all(promises).then((reports) => { + [this.currentInfo, this.totalInfo, this.unlicensedInfo] = reports; + this.viewReady = true; + }); + } + + get currentYear(): number { + return new Date().getFullYear(); + } +} diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index d447e7e9e..f41cbe83d 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,5 +1,11 @@ { "OAUTH_URL": "https://redkc-staging.iqser.cloud/auth/realms/redaction", "OAUTH_CLIENT_ID": "redaction", - "API_URL": "https://redapi-staging.iqser.cloud" + "API_URL": "https://redapi-staging.iqser.cloud", + "BACKEND_APP_VERSION": "1.0", + "FRONTEND_APP_VERSION": "1.0", + "EULA_URL": "EULA_URL", + "LICENSEE": "Timo Bejan", + "LICENSING_START": "06-01-2021", + "LICENSING_END": "20-01-2021" } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index c00d022e7..ba44e6e16 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -716,6 +716,7 @@ }, "dictionaries": "Dictionaries", "user-management": "User Management", + "license-information": "License Information", "notifications": { "today": "Today", "yesterday": "Yesterday", @@ -736,5 +737,23 @@ "cancel": "Cancel", "remember": "Apply for all uploads" } + }, + "license-info-screen": { + "backend-version": "Backend Application Version", + "frontend-version": "Frontend Application Version", + "custom-app-title": "Custom Application Title", + "copyright-claim-title": "Copyright Claim", + "copyright-claim-text": "Copyright © 2020 - {{currentYear}} IQSER Technologie GmbH", + "end-user-license-title": "End User License Agreement", + "end-user-license-text": "The use of this product is subject to the terms of the Atlassian End User Agreement, unless other specified therein.", + "3rd-party-title": "Reference to 3rd Party Licenses", + "licensing-details": "Licensing Details", + "licensed-to": "Licensed to", + "licensing-period": "Licensing Period", + "analyzed-pages": "Analyzed Pages", + "usage-details": "Usage Details", + "total-analyzed": "Total Analyzed Pages Since {{date}}", + "current-analyzed": "Analyzed Pages in Current Licensing Period", + "unlicensed-analyzed": "Unlicensed Analyzed Pages" } }