Rename folders

This commit is contained in:
Jesse Lucas
2020-03-29 16:51:12 -04:00
parent 7a657bf3c7
commit 03c6fb2f82
35 changed files with 65 additions and 45 deletions
@@ -0,0 +1,12 @@
<mat-card class="{{elevation}}">
<mat-card-title>Folders</mat-card-title>
<mat-card-content>
<div fxLayout="row" fxLayoutAlign="space-between start">
<app-donut-chart [elementID]="chartID"></app-donut-chart>
<div class="items" fxLayout="column" fxLayoutAlign="space-evenly end">
<app-chart-item *ngFor="let state of states | keyvalue" [state]="state.key" [count]="state.value">
</app-chart-item>
</div>
</div>
</mat-card-content>
</mat-card>
@@ -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,47 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import Folder from '../../folder'
import { cardElevation } from '../../style'
import { FolderService } from 'src/app/folder.service';
import { DonutChartComponent } from '../donut-chart/donut-chart.component';
@Component({
selector: 'app-folder-chart',
templateUrl: './folder-chart.component.html',
styleUrls: ['./folder-chart.component.scss']
})
export class FolderChartComponent implements OnInit {
@ViewChild(DonutChartComponent) donutChart: DonutChartComponent;
chartID: string = 'foldersChart';
states: Map<string, number>;
elevation: string = cardElevation;
constructor(private folderService: FolderService) {
this.states = new Map();
}
ngOnInit(): void {
for (let state in Folder.StateType) {
console.log(state);
}
}
ngAfterViewInit() {
this.folderService.getAll().subscribe(
folder => {
// TODO: Clear existing data
this.donutChart.data([40]);
// Get StateType and convert to string
const stateType: Folder.StateType = Folder.getStateType(folder);
const state: string = Folder.stateTypeToString(stateType);
// Instantiate empty count states
if (!this.states.has(state)) {
this.states.set(state, 0);
}
const count: number = this.states.get(state) + 1;
this.states.set(state, count);
}
);
}
}