refactor chart and list component structure

This commit is contained in:
Jesse Lucas
2020-03-29 16:51:12 -04:00
parent 37f2f2cdf6
commit eaffbc0f92
27 changed files with 108 additions and 20 deletions
@@ -0,0 +1 @@
<p>device-chart works!</p>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DeviceChartComponent } from './device-chart.component';
describe('DeviceChartComponent', () => {
let component: DeviceChartComponent;
let fixture: ComponentFixture<DeviceChartComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DeviceChartComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DeviceChartComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-device-chart',
templateUrl: './device-chart.component.html',
styleUrls: ['./device-chart.component.scss']
})
export class DeviceChartComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
@@ -0,0 +1 @@
<canvas id={{elementID}} width="200%" height="100%"></canvas>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DonutChartComponent } from './donut-chart.component';
describe('DonutChartComponent', () => {
let component: DonutChartComponent;
let fixture: ComponentFixture<DonutChartComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DonutChartComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DonutChartComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,47 @@
import { Component, OnInit, AfterViewInit, Input } from '@angular/core';
import { Chart } from 'chart.js'
import { flatMap } from 'rxjs/operators';
@Component({
selector: 'app-donut-chart',
templateUrl: './donut-chart.component.html',
styleUrls: ['./donut-chart.component.scss']
})
export class DonutChartComponent implements OnInit {
@Input() elementID: string;
private canvas: any;
private ctx: any;
constructor() { }
ngOnInit(): void {
}
ngAfterViewInit(): void {
this.canvas = document.getElementById(this.elementID);
this.ctx = this.canvas.getContext('2d');
const myChart = new Chart(this.ctx, {
type: 'doughnut',
data: {
labels: ["Up to Date", "Syncing", "Waiting to Sync", "Out of Sync", "Failed Items"],
datasets: [{
data: [100, 200, 300, 0, 0],
backgroundColor: [
'#56C568',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)'
],
borderWidth: 1
}]
},
options: {
responsive: false,
display: false,
legend: {
display: false
}
}
});
}
}
@@ -0,0 +1 @@
<p>folder-chart works!</p>
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FolderChartComponent } from './folder-chart.component';
describe('FolderChartComponent', () => {
let component: FolderChartComponent;
let fixture: ComponentFixture<FolderChartComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ FolderChartComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(FolderChartComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-folder-chart',
templateUrl: './folder-chart.component.html',
styleUrls: ['./folder-chart.component.scss']
})
export class FolderChartComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}