Merge branch 'RED-9993' into 'master'

RED-9993: fixed license information.

See merge request redactmanager/red-ui!569
This commit is contained in:
Dan Percic 2024-09-13 10:04:40 +02:00
commit 3cd1eaeddc
4 changed files with 8 additions and 13 deletions

View File

@ -60,11 +60,8 @@ export class LicenseAnalysisCapacityUsageComponent {
},
{
data: dataUntilCurrentMonth.map((month, monthIndex) =>
month.analysedFilesBytes
? month.analysedFilesBytes +
monthlyData.slice(0, monthIndex).reduce((acc, curr) => acc + (curr.analysedFilesBytes ?? 0), 0)
: 0,
data: dataUntilCurrentMonth.map((_, monthIndex) =>
monthlyData.slice(0, monthIndex + 1).reduce((acc, curr) => acc + (curr.analysedFilesBytes ?? 0), 0),
),
label: this._translateService.instant('license-info-screen.analysis-capacity-usage.analyzed-cumulative'),
yAxisID: 'y1',

View File

@ -63,11 +63,8 @@ export class LicensePageUsageComponent {
order: 1,
},
{
data: dataUntilCurrentMonth.map((month, monthIndex) =>
month.numberOfAnalyzedPages
? month.numberOfAnalyzedPages +
monthlyData.slice(0, monthIndex).reduce((acc, curr) => acc + (curr.numberOfAnalyzedPages ?? 0), 0)
: 0,
data: dataUntilCurrentMonth.map((_, monthIndex) =>
monthlyData.slice(0, monthIndex + 1).reduce((acc, curr) => acc + (curr.numberOfAnalyzedPages ?? 0), 0),
),
label: this._translateService.instant('license-info-screen.page-usage.cumulative-pages'),
yAxisID: 'y1',

View File

@ -6,7 +6,6 @@ import { ComplexFillTarget } from 'chart.js/dist/types';
const monthNames = dayjs.monthsShort();
const currentMonth = dayjs(Date.now()).month();
const currentYear = dayjs(Date.now()).year();
export const verboseDate = (date: Dayjs) => `${monthNames[date.month()]} ${date.year()}`;
@ -53,9 +52,9 @@ export const getLabelsFromLicense = (license: ILicenseReport) => {
};
export const getDataUntilCurrentMonth = (monthlyData: ILicenseData[]) => {
return monthlyData.filter(data => dayjs(data.startDate).month() <= currentMonth && dayjs(data.startDate).year() <= currentYear);
return monthlyData.filter(data => dayjs(data.startDate).isSameOrBefore(dayjs(Date.now()), 'month'));
};
export const isCurrentMonthAndYear = (date: Date | string) => {
return dayjs(date).month() === currentMonth && dayjs(date).year() === currentYear;
return dayjs(date).isSame(dayjs(Date.now()), 'month') && dayjs(date).isSame(dayjs(Date.now()), 'year');
};

View File

@ -10,6 +10,7 @@ import utc from 'dayjs/plugin/utc';
import localeData from 'dayjs/plugin/localeData';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
export interface DayJsDateAdapterOptions {
/**
@ -232,6 +233,7 @@ export class CustomDateAdapter extends DateAdapter<Dayjs> {
dayjs.extend(localizedFormat);
dayjs.extend(customParseFormat);
dayjs.extend(localeData);
dayjs.extend(isSameOrBefore);
this.setLocale(dateLocale);
}