diff --git a/apps/red-ui/src/app/modules/admin/screens/license/components/license-select/license-select.component.html b/apps/red-ui/src/app/modules/admin/screens/license/components/license-select/license-select.component.html index 27c4dc26a..54246338d 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/components/license-select/license-select.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/license/components/license-select/license-select.component.html @@ -16,7 +16,7 @@
{{ license.name }}
-
+
{{ getStatus(license.id) | translate | uppercase }}
diff --git a/apps/red-ui/src/app/modules/admin/screens/license/components/license-select/license-select.component.ts b/apps/red-ui/src/app/modules/admin/screens/license/components/license-select/license-select.component.ts index ab46c24cf..30f1a4cb6 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/components/license-select/license-select.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/license/components/license-select/license-select.component.ts @@ -29,7 +29,7 @@ export class LicenseSelectComponent { constructor(readonly licenseService: LicenseService, private readonly _permissionsService: IqserPermissionsService) {} getStatus(id) { - return id === this.licenseService.activeLicenseId ? translations.active : translations.inactive; + return id === this.licenseService.activeLicense.id ? translations.active : translations.inactive; } async licenseChanged(license: ILicense) { diff --git a/apps/red-ui/src/app/modules/admin/screens/license/components/license-storage/license-capacity.component.html b/apps/red-ui/src/app/modules/admin/screens/license/components/license-storage/license-capacity.component.html index 66f61dd5c..369317970 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/components/license-storage/license-capacity.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/license/components/license-storage/license-capacity.component.html @@ -19,15 +19,15 @@
{{ licenseService.currentLicenseReport.totalFilesUploadedBytes | size }} - - ({{ uploadedBytesCapacityPercentage | number : '1.0-2' }}%) + + ({{ licenseService.uploadedFilesBytesForCurrentLicensePercentage | number : '1.0-2' }}%)
- + {{ 'license-info-screen.capacity.storage-capacity' | translate }} diff --git a/apps/red-ui/src/app/modules/admin/screens/license/components/license-storage/license-capacity.component.ts b/apps/red-ui/src/app/modules/admin/screens/license/components/license-storage/license-capacity.component.ts index 912c03c6a..a1943b15f 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/components/license-storage/license-capacity.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/license/components/license-storage/license-capacity.component.ts @@ -16,12 +16,10 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; }) export class LicenseCapacityComponent { readonly formatSize = size; - uploadedBytesCapacityPercentage = -1; donutChartConfig: DonutChartConfig[] = []; readonly data$ = this.licenseService.selectedLicense$.pipe( map(() => this.licenseService.currentLicenseReport), tap(license => { - this.uploadedBytesCapacityPercentage = this.#getUploadedBytesCapacityPercentage(license); this.donutChartConfig = this.#getDonutChartConfig(license); }), map(license => ({ @@ -33,12 +31,6 @@ export class LicenseCapacityComponent { constructor(readonly licenseService: LicenseService, private readonly _translateService: TranslateService) {} - #getUploadedBytesCapacityPercentage(license: ILicenseReport): number { - return this.licenseService.uploadedBytesCapacity - ? (license.totalFilesUploadedBytes / this.licenseService.uploadedBytesCapacity) * 100 - : -1; - } - #getDonutChartConfig(license: ILicenseReport): DonutChartConfig[] { return [ { diff --git a/apps/red-ui/src/app/modules/admin/screens/license/components/license-usage/license-usage.component.html b/apps/red-ui/src/app/modules/admin/screens/license/components/license-usage/license-usage.component.html index 6f979cc53..774875526 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/components/license-usage/license-usage.component.html +++ b/apps/red-ui/src/app/modules/admin/screens/license/components/license-usage/license-usage.component.html @@ -2,10 +2,29 @@
-
+
- {{ licenseService.analyzedPagesInCurrentLicensingPeriod }} - ({{ analysisPercentageOfLicense$ | async | number : '1.0-2' }}%) + {{ licenseService.currentLicenseReport.analysedFilesBytes | size }} + + ({{ licenseService.analyzedFilesBytesForCurrentLicensePercentage | number : '1.0-2' }}%) + +
+
+ +
+
+
+ {{ licenseService.allLicensesReport.analysedFilesBytes | size }} +
+
+ +
+
+
+ {{ licenseService.currentLicenseReport.numberOfAnalyzedPages }} + + ({{ licenseService.analyzedPagesPercentageForCurrentLicensePercentage | number : '1.0-2' }}%) +
diff --git a/apps/red-ui/src/app/modules/admin/screens/license/components/license-usage/license-usage.component.ts b/apps/red-ui/src/app/modules/admin/screens/license/components/license-usage/license-usage.component.ts index 0da63b972..e562e8d66 100644 --- a/apps/red-ui/src/app/modules/admin/screens/license/components/license-usage/license-usage.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/license/components/license-usage/license-usage.component.ts @@ -13,7 +13,6 @@ import { TranslateService } from '@ngx-translate/core'; styleUrls: ['./license-usage.component.scss'], }) export class LicenseUsageComponent { - readonly analysisPercentageOfLicense$ = this.licenseService.selectedLicense$.pipe(map(() => this.getAnalysisPercentageOfLicense())); readonly data$ = this.licenseService.selectedLicense$.pipe( map(() => this.licenseService.currentLicenseReport), map(license => ({ @@ -24,12 +23,6 @@ export class LicenseUsageComponent { constructor(readonly licenseService: LicenseService, private readonly _translateService: TranslateService) {} - getAnalysisPercentageOfLicense() { - const totalLicensedNumberOfPages = this.licenseService.totalLicensedNumberOfPages; - const numberOfAnalyzedPages = this.licenseService.analyzedPagesInCurrentLicensingPeriod; - return totalLicensedNumberOfPages > 0 ? (numberOfAnalyzedPages / totalLicensedNumberOfPages) * 100 : 100; - } - #getDatasets(license: ILicenseReport): ChartDataset[] { const monthlyData = license.monthlyData; diff --git a/apps/red-ui/src/app/services/license.service.ts b/apps/red-ui/src/app/services/license.service.ts index fbcd8d306..ea13361b9 100644 --- a/apps/red-ui/src/app/services/license.service.ts +++ b/apps/red-ui/src/app/services/license.service.ts @@ -2,7 +2,7 @@ import { inject, Injectable } from '@angular/core'; import { GenericService, Toaster } from '@iqser/common-ui'; import { ILicense, ILicenseReport, ILicenseReportRequest, ILicenses } from '@red/domain'; import { BehaviorSubject, firstValueFrom, Observable, of } from 'rxjs'; -import { catchError, filter, tap } from 'rxjs/operators'; +import { catchError, filter } from 'rxjs/operators'; import dayjs from 'dayjs'; import { NGXLogger } from 'ngx-logger'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; @@ -42,12 +42,8 @@ const defaultOnError: ILicenses = { export class LicenseService extends GenericService { readonly licenseData$: Observable; readonly selectedLicense$: Observable; - activeLicenseId: string; - totalLicensedNumberOfPages = 0; currentLicenseReport: ILicenseReport = {}; allLicensesReport: ILicenseReport = {}; - unlicensedPages = 0; - analyzedPagesInCurrentLicensingPeriod = 0; protected readonly _defaultModelPath = 'report'; readonly #licenseData$ = new BehaviorSubject(undefined); readonly #selectedLicense$ = new BehaviorSubject(undefined); @@ -81,47 +77,53 @@ export class LicenseService extends GenericService { return activeLicense.features.find(f => f.name === 'pdftron').value; } + get totalLicensedNumberOfPages(): number { + const processingPagesFeature = this.selectedLicense.features?.find(f => f.name === 'processingPages'); + return Number(processingPagesFeature?.value ?? '0'); + } + + get analyzedPagesPercentageForCurrentLicensePercentage(): number { + return this.totalLicensedNumberOfPages + ? (this.currentLicenseReport.numberOfAnalyzedPages / this.totalLicensedNumberOfPages) * 100 + : -1; + } + + get totalBytesCapacity(): number { + const capacityFeature = this.selectedLicense.features?.find(f => f.name === 'uploadedBytesCapacity'); + return Number(capacityFeature?.value ?? '0'); + } + + get analyzedFilesBytesForCurrentLicensePercentage(): number { + return this.totalBytesCapacity ? (this.currentLicenseReport.analysedFilesBytes / this.totalBytesCapacity) * 100 : -1; + } + + get uploadedFilesBytesForCurrentLicensePercentage(): number { + return this.totalBytesCapacity ? (this.currentLicenseReport.totalFilesUploadedBytes / this.totalBytesCapacity) * 100 : -1; + } + + get unlicensedPages(): number { + return Math.max(0, this.currentLicenseReport.numberOfAnalyzedPages - this.totalLicensedNumberOfPages); + } + constructor() { super(); this.selectedLicense$ = this.#selectedLicense$.pipe(filter(license => !!license)); - this.licenseData$ = this.#licenseData$.pipe( - filter(licenses => !!licenses), - tap(data => (this.activeLicenseId = data.activeLicense)), - ); + this.licenseData$ = this.#licenseData$.pipe(filter(licenses => !!licenses)); } async loadLicenseData(license: ILicense = this.selectedLicense) { - this.totalLicensedNumberOfPages = this.getTotalLicensedNumberOfPages(license); - const startDate = dayjs(license.validFrom); const endDate = dayjs(license.validUntil); - const currentLicenseConfig = { + this.currentLicenseReport = await this.getReport({ startDate: startDate.toDate(), endDate: endDate.toDate(), - }; + }); - const allLicensesConfig = { + this.allLicensesReport = await this.getReport({ startDate: '2020-01-01T00:00:00.000Z', endDate: '2023-12-31T00:00:00.000Z', - }; - - const configs = [currentLicenseConfig, allLicensesConfig]; - const reports = configs.map(config => this.getReport(config)); - - [this.currentLicenseReport, this.allLicensesReport] = await Promise.all(reports); - - if (this.currentLicenseReport.numberOfAnalyzedPages > this.totalLicensedNumberOfPages) { - this.unlicensedPages = this.currentLicenseReport.numberOfAnalyzedPages - this.totalLicensedNumberOfPages; - } else { - this.unlicensedPages = 0; - } - this.analyzedPagesInCurrentLicensingPeriod = this.currentLicenseReport.numberOfAnalyzedPages; - } - - getTotalLicensedNumberOfPages(license: ILicense) { - const processingPagesFeature = license.features?.find(f => f.name === 'processingPages'); - return Number(processingPagesFeature?.value ?? '0'); + }); } setDefaultSelectedLicense() { diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index cc5cea4ca..a2651baa0 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -1650,7 +1650,8 @@ }, "copyright-claim-text": "Copyright © 2020 - {currentYear} knecon AG (powered by IQSER)", "copyright-claim-title": "Copyright", - "current-analyzed": "In aktuellem Lizenzzeitraum analysierte Seiten", + "current-analyzed-pages": "In aktuellem Lizenzzeitraum analysierte Seiten", + "current-volume-analyzed": "", "custom-app-title": "Name der Anwendung", "email-report": "E-Mail-Bericht", "email": { @@ -1680,6 +1681,7 @@ }, "total-analyzed": "Seit {date} insgesamt analysierte Seiten", "total-ocr-analyzed": "", + "total-volume-analyzed": "", "unlicensed-analyzed": "Über Lizenz hinaus analysierte Seiten", "usage-details": "Nutzungsdetails" }, diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 8cc21d464..c3a6bedf4 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -1650,7 +1650,8 @@ }, "copyright-claim-text": "Copyright © 2020 - {currentYear} knecon AG (powered by IQSER)", "copyright-claim-title": "Copyright Claim", - "current-analyzed": "Analyzed Pages in Licensing Period", + "current-analyzed-pages": "Analyzed Pages in Licensing Period", + "current-volume-analyzed": "Data Volume Analyzed in Licensing Period", "custom-app-title": "Custom Application Title", "email-report": "Email Report", "email": { @@ -1680,6 +1681,7 @@ }, "total-analyzed": "Total Analyzed Pages", "total-ocr-analyzed": "Total OCR Processed Pages", + "total-volume-analyzed": "Total Data Volume Analyzed", "unlicensed-analyzed": "Unlicensed Analyzed Pages", "usage-details": "Page Usage Details" }, diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index 6039ec1e7..99a3c0e82 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -1650,7 +1650,8 @@ }, "copyright-claim-text": "Copyright © 2020 - {currentYear} knecon AG (powered by IQSER)", "copyright-claim-title": "Copyright", - "current-analyzed": "In aktuellem Lizenzzeitraum analysierte Seiten", + "current-analyzed-pages": "In aktuellem Lizenzzeitraum analysierte Seiten", + "current-volume-analyzed": "", "custom-app-title": "Name der Anwendung", "email-report": "E-Mail-Bericht", "email": { @@ -1680,6 +1681,7 @@ }, "total-analyzed": "Seit {date} insgesamt analysierte Seiten", "total-ocr-analyzed": "", + "total-volume-analyzed": "", "unlicensed-analyzed": "Über Lizenz hinaus analysierte Seiten", "usage-details": "Nutzungsdetails" }, diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index 62b8845b5..e404de678 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -1650,7 +1650,8 @@ }, "copyright-claim-text": "Copyright © 2020 - {currentYear} knecon AG (powered by IQSER)", "copyright-claim-title": "Copyright Claim", - "current-analyzed": "Analyzed Pages in Licensing Period", + "current-analyzed-pages": "Analyzed Pages in Licensing Period", + "current-volume-analyzed": "Data Volume Analyzed in Licensing Period", "custom-app-title": "Custom Application Title", "email-report": "Email Report", "email": { @@ -1680,6 +1681,7 @@ }, "total-analyzed": "Total Analyzed Pages Since {date}", "total-ocr-analyzed": "Total OCR Processed Pages Since {date}", + "total-volume-analyzed": "Total Data Volume Analyzed", "unlicensed-analyzed": "Unlicensed Analyzed Pages", "usage-details": "Page Usage Details" }, diff --git a/libs/red-domain/src/lib/reports/license-report.ts b/libs/red-domain/src/lib/reports/license-report.ts index 969ff4dcb..7986bdd1f 100644 --- a/libs/red-domain/src/lib/reports/license-report.ts +++ b/libs/red-domain/src/lib/reports/license-report.ts @@ -5,6 +5,7 @@ export interface ILicenseData { trashFilesUploadedBytes?: number; numberOfAnalyzedPages?: number; numberOfOcrPages?: number; + analysedFilesBytes?: number; startDate?: Date; endDate?: Date; } @@ -15,6 +16,5 @@ export interface ILicenseReport extends ILicenseData { numberOfAnalyzedFiles?: number; numberOfDossiers?: number; numberOfOcrFiles?: number; - offset?: number; monthlyData?: ILicenseData[]; }