RED-9993: fixed license labels.
This commit is contained in:
parent
e57d54a755
commit
edf9e61132
@ -3,7 +3,7 @@ import { LicenseService } from '@services/license.service';
|
|||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { ChartDataset } from 'chart.js';
|
import { ChartDataset } from 'chart.js';
|
||||||
import { ChartBlue, ChartGreen, ChartRed } from '../../utils/constants';
|
import { ChartBlue, ChartGreen, ChartRed } from '../../utils/constants';
|
||||||
import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig, isCurrentMonthAndYear } from '../../utils/functions';
|
import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig, isCurrentMonth } from '../../utils/functions';
|
||||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
import { size } from '@iqser/common-ui/lib/utils';
|
import { size } from '@iqser/common-ui/lib/utils';
|
||||||
@ -43,7 +43,7 @@ export class LicenseAnalysisCapacityUsageComponent {
|
|||||||
#getCapacityDatasets(): ChartDataset[] {
|
#getCapacityDatasets(): ChartDataset[] {
|
||||||
const monthlyData = [...this.licenseService.selectedLicenseReport.monthlyData];
|
const monthlyData = [...this.licenseService.selectedLicenseReport.monthlyData];
|
||||||
const dataUntilCurrentMonth = getDataUntilCurrentMonth(monthlyData);
|
const dataUntilCurrentMonth = getDataUntilCurrentMonth(monthlyData);
|
||||||
if (monthlyData.length === 1 || isCurrentMonthAndYear(monthlyData[0].startDate)) {
|
if (monthlyData.length === 1 || isCurrentMonth(monthlyData[0].startDate)) {
|
||||||
const empty = { analysedFilesBytes: null } as ILicenseData;
|
const empty = { analysedFilesBytes: null } as ILicenseData;
|
||||||
dataUntilCurrentMonth.splice(0, 0, empty);
|
dataUntilCurrentMonth.splice(0, 0, empty);
|
||||||
monthlyData.splice(0, 0, empty);
|
monthlyData.splice(0, 0, empty);
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { LicenseService } from '@services/license.service';
|
|||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { ChartDataset } from 'chart.js';
|
import { ChartDataset } from 'chart.js';
|
||||||
import { ChartBlue, ChartGreen, ChartRed } from '../../utils/constants';
|
import { ChartBlue, ChartGreen, ChartRed } from '../../utils/constants';
|
||||||
import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig, isCurrentMonthAndYear } from '../../utils/functions';
|
import { getDataUntilCurrentMonth, getLabelsFromLicense, getLineConfig, isCurrentMonth } from '../../utils/functions';
|
||||||
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
import { ILicenseData } from '@red/domain';
|
import { ILicenseData } from '@red/domain';
|
||||||
@ -40,7 +40,7 @@ export class LicensePageUsageComponent {
|
|||||||
#getPagesDatasets(): ChartDataset[] {
|
#getPagesDatasets(): ChartDataset[] {
|
||||||
const monthlyData = [...this.licenseService.selectedLicenseReport.monthlyData];
|
const monthlyData = [...this.licenseService.selectedLicenseReport.monthlyData];
|
||||||
const dataUntilCurrentMonth = getDataUntilCurrentMonth(monthlyData);
|
const dataUntilCurrentMonth = getDataUntilCurrentMonth(monthlyData);
|
||||||
if (monthlyData.length === 1 || isCurrentMonthAndYear(monthlyData[0].startDate)) {
|
if (monthlyData.length === 1 || isCurrentMonth(monthlyData[0].startDate)) {
|
||||||
const empty = { numberOfAnalyzedPages: null } as ILicenseData;
|
const empty = { numberOfAnalyzedPages: null } as ILicenseData;
|
||||||
dataUntilCurrentMonth.splice(0, 0, empty);
|
dataUntilCurrentMonth.splice(0, 0, empty);
|
||||||
monthlyData.splice(0, 0, empty);
|
monthlyData.splice(0, 0, empty);
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export const getLabelsFromLicense = (license: ILicenseReport) => {
|
|||||||
monthIterator = monthIterator.add(1, 'month');
|
monthIterator = monthIterator.add(1, 'month');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startMonth.month() === endMonth.month() || startMonth.month() === currentMonth) {
|
if (startMonth.isSame(endMonth, 'month') || isCurrentMonth(startMonth.toDate())) {
|
||||||
result.splice(0, 0, '');
|
result.splice(0, 0, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,6 +55,6 @@ export const getDataUntilCurrentMonth = (monthlyData: ILicenseData[]) => {
|
|||||||
return monthlyData.filter(data => dayjs(data.startDate).isSameOrBefore(dayjs(Date.now()), 'month'));
|
return monthlyData.filter(data => dayjs(data.startDate).isSameOrBefore(dayjs(Date.now()), 'month'));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isCurrentMonthAndYear = (date: Date | string) => {
|
export const isCurrentMonth = (date: Date | string) => {
|
||||||
return dayjs(date).isSame(dayjs(Date.now()), 'month') && dayjs(date).isSame(dayjs(Date.now()), 'year');
|
return dayjs(date).isSame(dayjs(Date.now()), 'month');
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user