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