Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

48 lines
1.5 KiB

/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { AppDto, StorageUsagePerDateDto } from '@app/shared';
import { ChartHelpers, ChartOptions } from './shared';
@Component({
selector: 'sqx-asset-uploads-count-card[app][usage]',
styleUrls: ['./asset-uploads-count-card.component.scss'],
templateUrl: './asset-uploads-count-card.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AssetUploadsCountCardComponent implements OnChanges {
@Input()
public app!: AppDto;
@Input()
public usage?: ReadonlyArray<StorageUsagePerDateDto>;
public chartData: any;
public chartOptions = ChartOptions.Default;
public ngOnChanges() {
if (this.usage) {
const labels = ChartHelpers.createLabels(this.usage);
this.chartData = {
labels,
datasets: [
{
label: 'All',
lineTension: 0,
fill: false,
backgroundColor: ChartHelpers.getBackgroundColor(),
borderColor: ChartHelpers.getBorderColor(),
borderWidth: 1,
data: this.usage.map(x => x.totalCount),
},
],
};
}
}
}