RED-4596: update license view
This commit is contained in:
parent
10292071b0
commit
3a0bff7ae9
@ -7,6 +7,7 @@
|
|||||||
[legendOptions]="legendOptions"
|
[legendOptions]="legendOptions"
|
||||||
[showLegend]="legend"
|
[showLegend]="legend"
|
||||||
[view]="[width + legendSpacing, height]"
|
[view]="[width + legendSpacing, height]"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
>
|
>
|
||||||
<svg:g [attr.transform]="transform" class="bar-chart chart">
|
<svg:g [attr.transform]="transform" class="bar-chart chart">
|
||||||
<svg:g
|
<svg:g
|
||||||
@ -62,6 +63,7 @@
|
|||||||
ngx-combo-charts-series-vertical
|
ngx-combo-charts-series-vertical
|
||||||
></svg:g>
|
></svg:g>
|
||||||
</svg:g>
|
</svg:g>
|
||||||
|
|
||||||
<svg:g [attr.transform]="transform" class="line-chart chart">
|
<svg:g [attr.transform]="transform" class="line-chart chart">
|
||||||
<svg:g>
|
<svg:g>
|
||||||
<svg:g *ngFor="let series of lineChart; trackBy: trackBy">
|
<svg:g *ngFor="let series of lineChart; trackBy: trackBy">
|
||||||
@ -76,7 +78,7 @@
|
|||||||
[xScale]="xScaleLine"
|
[xScale]="xScaleLine"
|
||||||
[yScale]="yScaleLine"
|
[yScale]="yScaleLine"
|
||||||
ngx-charts-line-series
|
ngx-charts-line-series
|
||||||
/>
|
></svg:g>
|
||||||
</svg:g>
|
</svg:g>
|
||||||
|
|
||||||
<svg:g
|
<svg:g
|
||||||
@ -90,7 +92,7 @@
|
|||||||
[xSet]="xSet"
|
[xSet]="xSet"
|
||||||
[yScale]="yScaleLine"
|
[yScale]="yScaleLine"
|
||||||
ngx-charts-tooltip-area
|
ngx-charts-tooltip-area
|
||||||
/>
|
></svg:g>
|
||||||
|
|
||||||
<svg:g *ngFor="let series of lineChart">
|
<svg:g *ngFor="let series of lineChart">
|
||||||
<svg:g
|
<svg:g
|
||||||
@ -105,7 +107,7 @@
|
|||||||
[xScale]="xScaleLine"
|
[xScale]="xScaleLine"
|
||||||
[yScale]="yScaleLine"
|
[yScale]="yScaleLine"
|
||||||
ngx-charts-circle-series
|
ngx-charts-circle-series
|
||||||
/>
|
></svg:g>
|
||||||
</svg:g>
|
</svg:g>
|
||||||
</svg:g>
|
</svg:g>
|
||||||
</svg:g>
|
</svg:g>
|
||||||
|
|||||||
@ -1,14 +1,4 @@
|
|||||||
import {
|
import { Component, EventEmitter, HostListener, Input, Output, ViewEncapsulation } from '@angular/core';
|
||||||
Component,
|
|
||||||
ContentChild,
|
|
||||||
EventEmitter,
|
|
||||||
HostListener,
|
|
||||||
Input,
|
|
||||||
Output,
|
|
||||||
TemplateRef,
|
|
||||||
ViewChild,
|
|
||||||
ViewEncapsulation,
|
|
||||||
} from '@angular/core';
|
|
||||||
|
|
||||||
import { curveLinear } from 'd3-shape';
|
import { curveLinear } from 'd3-shape';
|
||||||
import { scaleBand, scaleLinear, scalePoint, scaleTime } from 'd3-scale';
|
import { scaleBand, scaleLinear, scalePoint, scaleTime } from 'd3-scale';
|
||||||
@ -18,12 +8,12 @@ import {
|
|||||||
Color,
|
Color,
|
||||||
ColorHelper,
|
ColorHelper,
|
||||||
LegendPosition,
|
LegendPosition,
|
||||||
LineSeriesComponent,
|
|
||||||
Orientation,
|
Orientation,
|
||||||
ScaleType,
|
ScaleType,
|
||||||
|
Series,
|
||||||
|
StringOrNumberOrDate,
|
||||||
ViewDimensions,
|
ViewDimensions,
|
||||||
} from '@swimlane/ngx-charts';
|
} from '@swimlane/ngx-charts';
|
||||||
import { ILineChartSeries } from './models';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
// eslint-disable-next-line @angular-eslint/component-selector
|
// eslint-disable-next-line @angular-eslint/component-selector
|
||||||
@ -55,7 +45,7 @@ export class ComboChartComponent extends BaseChartComponent {
|
|||||||
@Input() roundDomains = false;
|
@Input() roundDomains = false;
|
||||||
@Input() colorSchemeLine: Color;
|
@Input() colorSchemeLine: Color;
|
||||||
@Input() autoScale;
|
@Input() autoScale;
|
||||||
@Input() lineChart: ILineChartSeries[];
|
@Input() lineChart: Series[];
|
||||||
@Input() yLeftAxisScaleFactor: any;
|
@Input() yLeftAxisScaleFactor: any;
|
||||||
@Input() yRightAxisScaleFactor: any;
|
@Input() yRightAxisScaleFactor: any;
|
||||||
@Input() rangeFillOpacity: number;
|
@Input() rangeFillOpacity: number;
|
||||||
@ -63,9 +53,6 @@ export class ComboChartComponent extends BaseChartComponent {
|
|||||||
@Input() noBarWhenZero = true;
|
@Input() noBarWhenZero = true;
|
||||||
@Output() activate = new EventEmitter<{ value; entries: unknown[] }>();
|
@Output() activate = new EventEmitter<{ value; entries: unknown[] }>();
|
||||||
@Output() deactivate = new EventEmitter<{ value; entries: unknown[] }>();
|
@Output() deactivate = new EventEmitter<{ value; entries: unknown[] }>();
|
||||||
@ContentChild('tooltipTemplate') tooltipTemplate: TemplateRef<unknown>;
|
|
||||||
@ContentChild('seriesTooltipTemplate') seriesTooltipTemplate: TemplateRef<unknown>;
|
|
||||||
@ViewChild(LineSeriesComponent) lineSeriesComponent: LineSeriesComponent;
|
|
||||||
dims: ViewDimensions;
|
dims: ViewDimensions;
|
||||||
xScale: any;
|
xScale: any;
|
||||||
yScale: any;
|
yScale: any;
|
||||||
@ -84,7 +71,7 @@ export class ComboChartComponent extends BaseChartComponent {
|
|||||||
xDomainLine;
|
xDomainLine;
|
||||||
yDomainLine;
|
yDomainLine;
|
||||||
seriesDomain;
|
seriesDomain;
|
||||||
combinedSeries: ILineChartSeries[];
|
combinedSeries: Series[];
|
||||||
xSet;
|
xSet;
|
||||||
filteredDomain;
|
filteredDomain;
|
||||||
hoveredVertical;
|
hoveredVertical;
|
||||||
@ -205,7 +192,7 @@ export class ComboChartComponent extends BaseChartComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getXDomainLine(): any[] {
|
getXDomainLine(): any[] {
|
||||||
let values: number[] = [];
|
let values: StringOrNumberOrDate[] = [];
|
||||||
|
|
||||||
for (const results of this.lineChart) {
|
for (const results of this.lineChart) {
|
||||||
for (const d of results.series) {
|
for (const d of results.series) {
|
||||||
@ -219,13 +206,13 @@ export class ComboChartComponent extends BaseChartComponent {
|
|||||||
let domain = [];
|
let domain = [];
|
||||||
|
|
||||||
if (this.scaleType === 'time') {
|
if (this.scaleType === 'time') {
|
||||||
const min = Math.min(...values);
|
const min = Math.min(...(values as number[]));
|
||||||
const max = Math.max(...values);
|
const max = Math.max(...(values as number[]));
|
||||||
domain = [min, max];
|
domain = [min, max];
|
||||||
} else if (this.scaleType === 'linear') {
|
} else if (this.scaleType === 'linear') {
|
||||||
values = values.map(v => Number(v));
|
values = values.map(v => Number(v));
|
||||||
const min = Math.min(...values);
|
const min = Math.min(...(values as number[]));
|
||||||
const max = Math.max(...values);
|
const max = Math.max(...(values as number[]));
|
||||||
domain = [min, max];
|
domain = [min, max];
|
||||||
} else {
|
} else {
|
||||||
domain = values;
|
domain = values;
|
||||||
@ -292,7 +279,6 @@ export class ComboChartComponent extends BaseChartComponent {
|
|||||||
|
|
||||||
getYScaleLine(domain, height): any {
|
getYScaleLine(domain, height): any {
|
||||||
const scale = scaleLinear().range([height, 0]).domain(domain);
|
const scale = scaleLinear().range([height, 0]).domain(domain);
|
||||||
|
|
||||||
return this.roundDomains ? scale.nice() : scale;
|
return this.roundDomains ? scale.nice() : scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
export interface ISeries {
|
|
||||||
name: number;
|
|
||||||
value: number;
|
|
||||||
min: number;
|
|
||||||
max: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ILineChartSeries {
|
|
||||||
name: string;
|
|
||||||
series: ISeries[];
|
|
||||||
}
|
|
||||||
@ -2,13 +2,13 @@ import { Component } from '@angular/core';
|
|||||||
import { ComboBarScheme, LICENSE_STORAGE_KEY, LineChartScheme } from '../utils/constants';
|
import { ComboBarScheme, LICENSE_STORAGE_KEY, LineChartScheme } from '../utils/constants';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { IDateRange, ILicense, ILicenseReport } from '@red/domain';
|
import { IDateRange, ILicense, ILicenseReport } from '@red/domain';
|
||||||
import { LicenseService } from '../../../../../services/license.service';
|
import { LicenseService } from '@services/license.service';
|
||||||
import { switchMap, tap } from 'rxjs/operators';
|
import { switchMap, tap } from 'rxjs/operators';
|
||||||
import { List, LoadingService } from '@iqser/common-ui';
|
import { List, LoadingService } from '@iqser/common-ui';
|
||||||
import { generateDateRanges, isCurrentMonth, toDate, verboseDate } from '../utils/functions';
|
import { generateDateRanges, isCurrentMonth, toDate, verboseDate } from '../utils/functions';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { ILineChartSeries } from '../combo-chart/models';
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { Series } from '@swimlane/ngx-charts';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'redaction-license-chart',
|
selector: 'redaction-license-chart',
|
||||||
@ -18,7 +18,7 @@ export class LicenseChartComponent {
|
|||||||
readonly lineChartScheme = LineChartScheme;
|
readonly lineChartScheme = LineChartScheme;
|
||||||
readonly comboBarScheme = ComboBarScheme;
|
readonly comboBarScheme = ComboBarScheme;
|
||||||
|
|
||||||
lineChartSeries$ = this.#licenseChartSeries$;
|
readonly lineChartSeries$ = this.#licenseChartSeries$;
|
||||||
barChart = [];
|
barChart = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -27,7 +27,7 @@ export class LicenseChartComponent {
|
|||||||
private readonly _loadingService: LoadingService,
|
private readonly _loadingService: LoadingService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
get #licenseChartSeries$(): Observable<ILineChartSeries[]> {
|
get #licenseChartSeries$(): Observable<Series[]> {
|
||||||
return this._licenseService.selectedLicense$.pipe(
|
return this._licenseService.selectedLicense$.pipe(
|
||||||
tap(() => this._loadingService.start()),
|
tap(() => this._loadingService.start()),
|
||||||
switchMap(license => this.#getLicenseData(license)),
|
switchMap(license => this.#getLicenseData(license)),
|
||||||
@ -35,7 +35,7 @@ export class LicenseChartComponent {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #getLicenseData(license: ILicense): Promise<ILineChartSeries[]> {
|
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 startMonth: number = startDate.month();
|
const startMonth: number = startDate.month();
|
||||||
@ -47,7 +47,7 @@ export class LicenseChartComponent {
|
|||||||
return this.#mapRangesToReports(startMonth, startYear, dateRanges, reports);
|
return this.#mapRangesToReports(startMonth, startYear, dateRanges, reports);
|
||||||
}
|
}
|
||||||
|
|
||||||
#mapRangesToReports(month: number, year: number, dateRanges: List<IDateRange>, reports: List<ILicenseReport>): ILineChartSeries[] {
|
#mapRangesToReports(month: number, year: number, dateRanges: List<IDateRange>, reports: List<ILicenseReport>): Series[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: this._translateService.instant('license-info-screen.chart.total-pages'),
|
name: this._translateService.instant('license-info-screen.chart.total-pages'),
|
||||||
@ -120,9 +120,11 @@ export class LicenseChartComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#totalLicensedPagesSeries(dateRanges: List<IDateRange>) {
|
#totalLicensedPagesSeries(dateRanges: List<IDateRange>) {
|
||||||
|
const processingPages = this._licenseService.processingPages;
|
||||||
|
|
||||||
return dateRanges.map(dateRange => ({
|
return dateRanges.map(dateRange => ({
|
||||||
name: verboseDate(dateRange),
|
name: verboseDate(dateRange),
|
||||||
value: this._licenseService.processingPages,
|
value: processingPages,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Component, EventEmitter, Output } from '@angular/core';
|
import { Component, EventEmitter, Output } from '@angular/core';
|
||||||
import { LicenseService } from '../../../../../services/license.service';
|
import { LicenseService } from '@services/license.service';
|
||||||
import { ILicense } from '@red/domain';
|
import { ILicense } from '@red/domain';
|
||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
import { map, tap } from 'rxjs/operators';
|
import { map, tap } from 'rxjs/operators';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user