RED-6889: Fixed license view
This commit is contained in:
parent
c9c124bf7a
commit
db7a8fab33
@ -21,12 +21,6 @@ export class LicenseChartComponent {
|
||||
readonly lineChartSeries$ = this.#licenseChartSeries$;
|
||||
barChart = [];
|
||||
|
||||
constructor(
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _licenseService: LicenseService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
) {}
|
||||
|
||||
get #licenseChartSeries$(): Observable<Series[]> {
|
||||
return this._licenseService.selectedLicense$.pipe(
|
||||
tap(() => this._loadingService.start()),
|
||||
@ -35,9 +29,16 @@ export class LicenseChartComponent {
|
||||
);
|
||||
}
|
||||
|
||||
constructor(
|
||||
private readonly _translateService: TranslateService,
|
||||
private readonly _licenseService: LicenseService,
|
||||
private readonly _loadingService: LoadingService,
|
||||
) {}
|
||||
|
||||
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);
|
||||
@ -111,7 +115,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) {
|
||||
|
||||
@ -58,15 +58,6 @@ export class LicenseService extends GenericService<ILicenseReport> {
|
||||
readonly #licenseData$ = new BehaviorSubject<ILicenses | undefined>(undefined);
|
||||
readonly #selectedLicense$ = new BehaviorSubject<ILicense | undefined>(undefined);
|
||||
|
||||
constructor(private readonly _logger: NGXLogger) {
|
||||
super();
|
||||
this.selectedLicense$ = this.#selectedLicense$.pipe(filter(license => !!license));
|
||||
this.licenseData$ = this.#licenseData$.pipe(
|
||||
filter(licenses => !!licenses),
|
||||
tap(data => (this.activeLicenseId = data.activeLicense)),
|
||||
);
|
||||
}
|
||||
|
||||
get selectedLicense() {
|
||||
return this.#selectedLicense$.value;
|
||||
}
|
||||
@ -84,6 +75,15 @@ export class LicenseService extends GenericService<ILicenseReport> {
|
||||
return this.activeLicense.features.find(f => f.name === 'pdftron').value;
|
||||
}
|
||||
|
||||
constructor(private readonly _logger: NGXLogger) {
|
||||
super();
|
||||
this.selectedLicense$ = this.#selectedLicense$.pipe(filter(license => !!license));
|
||||
this.licenseData$ = this.#licenseData$.pipe(
|
||||
filter(licenses => !!licenses),
|
||||
tap(data => (this.activeLicenseId = data.activeLicense)),
|
||||
);
|
||||
}
|
||||
|
||||
wipeStoredReportsAndReloadSelectedLicenseData() {
|
||||
this._logger.info('[LICENSE] Wiping stored reports and reloading license data');
|
||||
this.storedReports = {};
|
||||
|
||||
@ -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