Pull request #116: Email license report

Merge in RED/ui from RED-1081 to master

* commit '061314b5ea38cb500b8c92ed6f61abb248e1e558':
  Email license report
This commit is contained in:
Timo Bejan 2021-02-23 15:48:11 +01:00
commit ccb22bca47
5 changed files with 25 additions and 2 deletions

View File

@ -20,6 +20,7 @@ export enum AppConfigKey {
FRONTEND_APP_VERSION = 'FRONTEND_APP_VERSION',
EULA_URL = 'EULA_URL',
LICENSE_CUSTOMER = 'LICENSE_CUSTOMER',
LICENSE_EMAIL = 'LICENSE_EMAIL',
LICENSE_START = 'LICENSE_START',
LICENSE_END = 'LICENSE_END',
LICENSE_PAGE_COUNT = 'LICENSE_PAGE_COUNT'

View File

@ -3,6 +3,7 @@
<redaction-admin-breadcrumbs [root]="true" class="flex-1"></redaction-admin-breadcrumbs>
<div class="actions">
<button (click)="sendMail()" color="primary" mat-flat-button translate="license-info-screen.email-report"></button>
<redaction-circle-button
*ngIf="permissionsService.isUser()"
[routerLink]="['/ui/projects/']"

View File

@ -3,6 +3,7 @@ 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';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'redaction-license-information-screen',
@ -20,7 +21,8 @@ export class LicenseInformationScreenComponent {
constructor(
public readonly permissionsService: PermissionsService,
private readonly _licenseReportController: LicenseReportControllerService,
public readonly appConfigService: AppConfigService
public readonly appConfigService: AppConfigService,
private readonly _translateService: TranslateService
) {
this.totalLicensedNumberOfPages = this.appConfigService.getConfig('LICENSE_PAGE_COUNT', 0);
const startDate = moment(this.appConfigService.getConfig('LICENSE_START'), 'DD-MM-YYYY');
@ -49,4 +51,14 @@ export class LicenseInformationScreenComponent {
get currentYear(): number {
return new Date().getFullYear();
}
sendMail(): void {
const licenseCustomer = this.appConfigService.getConfig('LICENSE_CUSTOMER');
const subject = this._translateService.instant('license-info-screen.email.title', { licenseCustomer });
const body = [
this._translateService.instant('license-info-screen.email.body.analyzed', { pages: this.currentInfo.numberOfAnalyzedPages }),
this._translateService.instant('license-info-screen.email.body.licensed', { pages: this.totalLicensedNumberOfPages })
].join('%0D%0A');
window.location.href = `mailto:${this.appConfigService.getConfig('LICENSE_EMAIL')}?subject=${subject}&body=${body}`;
}
}

View File

@ -6,6 +6,7 @@
"FRONTEND_APP_VERSION": "1.0",
"EULA_URL": "EULA_URL",
"LICENSE_CUSTOMER": "Development License",
"LICENSE_EMAIL": "todo-license@email.com",
"LICENSE_START": "01-01-2021",
"LICENSE_END": "31-12-2021",
"LICENSE_PAGE_COUNT": 1000000

View File

@ -764,7 +764,15 @@
"total-analyzed": "Total Analyzed Pages Since {{date}}",
"licensed-page-count": "Number of licensed pages",
"current-analyzed": "Analyzed Pages in Current Licensing Period",
"unlicensed-analyzed": "Unlicensed Analyzed Pages"
"unlicensed-analyzed": "Unlicensed Analyzed Pages",
"email-report": "Email Report",
"email": {
"title": "License Report {{licenseCustomer}}",
"body": {
"analyzed": "Total Analyzed Pages in current license period: {{pages}}.",
"licensed": "Licensed Pages: {{pages}}."
}
}
},
"default-colors": "Default Colors",
"default-colors-screen": {