License info screen

This commit is contained in:
Adina Țeudan 2021-01-25 00:44:50 +02:00
parent f2edb42f3e
commit a368ce0344
8 changed files with 238 additions and 3 deletions

View File

@ -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({

View File

@ -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,

View File

@ -17,6 +17,15 @@
*ngIf="root && userPreferenceService.areDevFeaturesEnabled"
></a>
<a
class="breadcrumb"
[routerLink]="'/ui/admin/license-info'"
[routerLinkActiveOptions]="{ exact: true }"
routerLinkActive="active"
translate="license-information"
*ngIf="root && userPreferenceService.areDevFeaturesEnabled"
></a>
<ng-container *ngIf="appStateService.activeRuleSet">
<mat-icon svgIcon="red:arrow-right"></mat-icon>
<a

View File

@ -0,0 +1,99 @@
<section>
<div class="page-header">
<redaction-admin-breadcrumbs [root]="true" class="flex-1"></redaction-admin-breadcrumbs>
<div class="actions">
<redaction-circle-button
*ngIf="permissionsService.isUser()"
[routerLink]="['/ui/projects/']"
class="ml-6"
icon="red:close"
tooltip="common.close"
tooltipPosition="before"
></redaction-circle-button>
</div>
</div>
<div class="red-content-inner">
<div class="left-container">
<div class="grid-container">
<div class="row">
<div translate="license-info-screen.backend-version"></div>
<div>{{ appConfigService.getConfig('BACKEND_APP_VERSION', '-') }}</div>
</div>
<div class="row">
<div translate="license-info-screen.frontend-version"></div>
<div>{{ appConfigService.getConfig('FRONTEND_APP_VERSION', '-') }}</div>
</div>
<div class="row">
<div translate="license-info-screen.custom-app-title"></div>
<div>{{ appConfigService.getConfig('APP_NAME', '-') }}</div>
</div>
<div class="row">
<div translate="license-info-screen.copyright-claim-title"></div>
<div>{{ 'license-info-screen.copyright-claim-text' | translate: { currentYear: currentYear } }}</div>
</div>
<div class="row">
<div translate="license-info-screen.end-user-license-title"></div>
<div translate="license-info-screen.end-user-license-text"></div>
</div>
<!-- TODO-->
<!-- <div class="row">-->
<!-- <div translate="license-info-screen.3rd-party-title"></div>-->
<!-- <div>Future feature: we will provide that with the /info endpoint</div>-->
<!-- </div>-->
<div class="section-title all-caps-label" translate="license-info-screen.licensing-details"></div>
<div class="row">
<div translate="license-info-screen.licensed-to"></div>
<div>{{ appConfigService.getConfig('LICENSEE', '-') }}</div>
</div>
<div class="row">
<div translate="license-info-screen.licensing-period"></div>
<div>{{ appConfigService.getConfig('LICENSING_START', '-') }} / {{ appConfigService.getConfig('LICENSING_END', '-') }}</div>
</div>
<div class="row">
<div translate="license-info-screen.analyzed-pages"></div>
<div>{{ currentInfo.numberOfAnalyzedPages }}</div>
</div>
<div class="section-title all-caps-label" translate="license-info-screen.usage-details"></div>
<div class="row">
<div>{{ 'license-info-screen.total-analyzed' | translate: { date: totalInfo.startDate | date: 'longDate' } }}</div>
<div>{{ totalInfo.numberOfAnalyzedPages }}</div>
</div>
<div class="row">
<div translate="license-info-screen.current-analyzed"></div>
<div>
{{ currentInfo.numberOfAnalyzedPages }} ({{
(currentInfo.numberOfAnalyzedPages / totalInfo.numberOfAnalyzedPages) * 100 | number: '1.0-2'
}}%)
</div>
</div>
<div class="row" *ngIf="!!unlicensedInfo">
<div translate="license-info-screen.unlicensed-analyzed"></div>
<div>{{ unlicensedInfo.numberOfAnalyzedPages }}</div>
</div>
<!-- TODO-->
<!-- <div class="row">-->
<!-- <div>Progress bar</div>-->
<!-- <div></div>-->
<!-- </div>-->
</div>
</div>
</div>
</section>
<redaction-full-page-loading-indicator [displayed]="!viewReady"></redaction-full-page-loading-indicator>

View File

@ -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;
}
}

View File

@ -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();
}
}

View File

@ -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"
}

View File

@ -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"
}
}