HotFix - license screen
This commit is contained in:
parent
101e8b8860
commit
4d761adc0d
@ -38,6 +38,7 @@ export class LicenseChartComponent {
|
|||||||
async #getLicenseData(license: ILicense): Promise<Series[]> {
|
async #getLicenseData(license: ILicense): Promise<Series[]> {
|
||||||
const startDate = dayjs(license.validFrom);
|
const startDate = dayjs(license.validFrom);
|
||||||
const endDate = dayjs(license.validUntil);
|
const endDate = dayjs(license.validUntil);
|
||||||
|
const startDay: number = startDate.date();
|
||||||
const startMonth: number = startDate.month();
|
const startMonth: number = startDate.month();
|
||||||
const startYear: number = startDate.year();
|
const startYear: number = startDate.year();
|
||||||
|
|
||||||
@ -48,6 +49,9 @@ export class LicenseChartComponent {
|
|||||||
dateRanges.push({ startMonth: dt.month(), startYear: dt.year(), endMonth: end.month(), endYear: end.year() });
|
dateRanges.push({ startMonth: dt.month(), startYear: dt.year(), endMonth: end.month(), endYear: end.year() });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dateRanges.length > 0) {
|
||||||
|
dateRanges[0].startDay = startDay;
|
||||||
|
}
|
||||||
const reports = await this.#getReports(dateRanges, license.id);
|
const reports = await this.#getReports(dateRanges, license.id);
|
||||||
|
|
||||||
return this.#mapRangesToReports(startMonth, startYear, dateRanges, reports);
|
return this.#mapRangesToReports(startMonth, startYear, dateRanges, reports);
|
||||||
@ -101,6 +105,7 @@ export class LicenseChartComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#getReports(dateRanges: List<IDateRange>, id: string) {
|
#getReports(dateRanges: List<IDateRange>, id: string) {
|
||||||
|
console.log(dateRanges);
|
||||||
const reports = dateRanges.map(range => {
|
const reports = dateRanges.map(range => {
|
||||||
const startMonth = range.startMonth + 1;
|
const startMonth = range.startMonth + 1;
|
||||||
const endMonth = range.endMonth + 1;
|
const endMonth = range.endMonth + 1;
|
||||||
@ -111,7 +116,7 @@ export class LicenseChartComponent {
|
|||||||
return existingReport;
|
return existingReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
const startDate = toDate(startMonth, range.startYear);
|
const startDate = toDate(startMonth, range.startYear, range.startDay);
|
||||||
const endDate = toDate(endMonth, range.endYear);
|
const endDate = toDate(endMonth, range.endYear);
|
||||||
const requestedReport = this._licenseService.getReport({ startDate, endDate });
|
const requestedReport = this._licenseService.getReport({ startDate, endDate });
|
||||||
return requestedReport.then(report => this.#storeReportIfNotCurrentMonth(range, report, key));
|
return requestedReport.then(report => this.#storeReportIfNotCurrentMonth(range, report, key));
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { IDateRange } from '@red/domain';
|
import { IDateRange } from '@red/domain';
|
||||||
|
|
||||||
export function toDate(month: number, year: number) {
|
export function toDate(month: number, year: number, day: number = 1) {
|
||||||
return dayjs(`01-${month}-${year}`, 'D-M-YYYY').toDate();
|
return dayjs(`${day}-${month}-${year}`, 'D-M-YYYY').toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCurrentMonth(month: number, year: number) {
|
export function isCurrentMonth(month: number, year: number) {
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { GenericService, QueryParam, RequiredParam, Validate } from '@iqser/common-ui';
|
import { GenericService, QueryParam } from '@iqser/common-ui';
|
||||||
import { ILicense, ILicenseReport, ILicenseReportRequest, ILicenses } from '@red/domain';
|
import { ILicense, ILicenseReport, ILicenseReportRequest, ILicenses } from '@red/domain';
|
||||||
import { BehaviorSubject, firstValueFrom, Observable, of } from 'rxjs';
|
import { BehaviorSubject, firstValueFrom, Observable, of } from 'rxjs';
|
||||||
import { catchError, filter, tap } from 'rxjs/operators';
|
import { catchError, filter, tap } from 'rxjs/operators';
|
||||||
import { LICENSE_STORAGE_KEY } from '../modules/admin/screens/license/utils/constants';
|
import { LICENSE_STORAGE_KEY } from '../modules/admin/screens/license/utils/constants';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
|
import { UI } from '@pdftron/webviewer';
|
||||||
|
import off = UI.Hotkeys.off;
|
||||||
|
|
||||||
export function getStoredReports() {
|
export function getStoredReports() {
|
||||||
const rawStoredReports = localStorage.getItem(LICENSE_STORAGE_KEY);
|
const rawStoredReports = localStorage.getItem(LICENSE_STORAGE_KEY);
|
||||||
@ -90,7 +92,11 @@ export class LicenseService extends GenericService<ILicenseReport> {
|
|||||||
this.setSelectedLicense(this.selectedLicense);
|
this.setSelectedLicense(this.selectedLicense);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
x = null;
|
||||||
async loadLicenseData(license: ILicense = this.selectedLicense) {
|
async loadLicenseData(license: ILicense = this.selectedLicense) {
|
||||||
|
if (this.x) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.totalLicensedNumberOfPages = this.getTotalLicensedNumberOfPages(license);
|
this.totalLicensedNumberOfPages = this.getTotalLicensedNumberOfPages(license);
|
||||||
|
|
||||||
const startDate = dayjs(license.validFrom);
|
const startDate = dayjs(license.validFrom);
|
||||||
@ -117,6 +123,7 @@ export class LicenseService extends GenericService<ILicenseReport> {
|
|||||||
this.unlicensedPages = 0;
|
this.unlicensedPages = 0;
|
||||||
}
|
}
|
||||||
this.analyzedPagesInCurrentLicensingPeriod = this.currentLicenseInfo.numberOfAnalyzedPages;
|
this.analyzedPagesInCurrentLicensingPeriod = this.currentLicenseInfo.numberOfAnalyzedPages;
|
||||||
|
this.x = '100';
|
||||||
}
|
}
|
||||||
|
|
||||||
getTotalLicensedNumberOfPages(license: ILicense) {
|
getTotalLicensedNumberOfPages(license: ILicense) {
|
||||||
@ -128,8 +135,7 @@ export class LicenseService extends GenericService<ILicenseReport> {
|
|||||||
this.setSelectedLicense(this.activeLicense);
|
this.setSelectedLicense(this.activeLicense);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validate()
|
getReport(body: ILicenseReportRequest, limit?: number, offset?: number) {
|
||||||
getReport$(@RequiredParam() body: ILicenseReportRequest, limit?: number, offset?: number) {
|
|
||||||
const queryParams: QueryParam[] = [];
|
const queryParams: QueryParam[] = [];
|
||||||
if (limit) {
|
if (limit) {
|
||||||
queryParams.push({ key: 'limit', value: limit });
|
queryParams.push({ key: 'limit', value: limit });
|
||||||
@ -139,19 +145,14 @@ export class LicenseService extends GenericService<ILicenseReport> {
|
|||||||
queryParams.push({ key: 'offset', value: offset });
|
queryParams.push({ key: 'offset', value: offset });
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._post(body, `${this._defaultModelPath}/license`, queryParams);
|
return firstValueFrom(this._post(body, `${this._defaultModelPath}/license`, queryParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
getReport(body: ILicenseReportRequest, limit?: number, offset?: number) {
|
async loadLicenses() {
|
||||||
return firstValueFrom(this.getReport$(body, limit, offset));
|
const licenses$ = this._http.get<ILicenses>('/license').pipe(catchError(() => of(defaultOnError)));
|
||||||
}
|
const licenses = await firstValueFrom(licenses$);
|
||||||
|
this.#licenseData$.next(licenses);
|
||||||
loadLicense() {
|
this.setDefaultSelectedLicense();
|
||||||
return this._http.get<ILicenses>('/license').pipe(
|
|
||||||
catchError(() => of(defaultOnError)),
|
|
||||||
tap(licenses => this.#licenseData$.next(licenses)),
|
|
||||||
tap(() => this.setDefaultSelectedLicense()),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelectedLicense($event: ILicense) {
|
setSelectedLicense($event: ILicense) {
|
||||||
|
|||||||
@ -51,7 +51,7 @@ export function configurationInitializer(
|
|||||||
lastDossierTemplateRedirect(baseHref.replace('/', ''), userPreferenceService);
|
lastDossierTemplateRedirect(baseHref.replace('/', ''), userPreferenceService);
|
||||||
}),
|
}),
|
||||||
switchMap(() => languageService.setInitialLanguage()),
|
switchMap(() => languageService.setInitialLanguage()),
|
||||||
switchMap(() => licenseService.loadLicense()),
|
switchMap(() => licenseService.loadLicenses()),
|
||||||
);
|
);
|
||||||
return () => firstValueFrom(setup);
|
return () => firstValueFrom(setup);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ADMIN_CONTACT_NAME": null,
|
"ADMIN_CONTACT_NAME": null,
|
||||||
"ADMIN_CONTACT_URL": null,
|
"ADMIN_CONTACT_URL": null,
|
||||||
"API_URL": "https://red-staging.iqser.cloud/redaction-gateway-v1",
|
"API_URL": "https://basf.redactmanager.com/redaction-gateway-v1",
|
||||||
"APP_NAME": "RedactManager",
|
"APP_NAME": "RedactManager",
|
||||||
"AUTO_READ_TIME": 3,
|
"AUTO_READ_TIME": 3,
|
||||||
"BACKEND_APP_VERSION": "4.4.40",
|
"BACKEND_APP_VERSION": "4.4.40",
|
||||||
@ -11,7 +11,7 @@
|
|||||||
"MAX_RETRIES_ON_SERVER_ERROR": 3,
|
"MAX_RETRIES_ON_SERVER_ERROR": 3,
|
||||||
"OAUTH_CLIENT_ID": "redaction",
|
"OAUTH_CLIENT_ID": "redaction",
|
||||||
"OAUTH_IDP_HINT": null,
|
"OAUTH_IDP_HINT": null,
|
||||||
"OAUTH_URL": "https://red-staging.iqser.cloud/auth/realms/redaction",
|
"OAUTH_URL": "https://basf.redactmanager.com/auth/realms/redaction",
|
||||||
"RECENT_PERIOD_IN_HOURS": 24,
|
"RECENT_PERIOD_IN_HOURS": 24,
|
||||||
"SELECTION_MODE": "structural",
|
"SELECTION_MODE": "structural",
|
||||||
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",
|
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
export interface IDateRange {
|
export interface IDateRange {
|
||||||
|
readonly startDay: number;
|
||||||
readonly startMonth: number;
|
readonly startMonth: number;
|
||||||
readonly startYear: number;
|
readonly startYear: number;
|
||||||
readonly endMonth: number;
|
readonly endMonth: number;
|
||||||
readonly endYear: number;
|
readonly endYear: number;
|
||||||
|
readonly endDay: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user