Updated comments

This commit is contained in:
Hartenstein Ruben (PEA4-Fe) 2021-01-18 14:15:55 +01:00
parent af576fa392
commit 20050c8114

View File

@ -18,7 +18,7 @@ interface KeyInterface {
export class HomeComponent implements OnInit { export class HomeComponent implements OnInit {
keys: KeyInterface[] = []; keys: KeyInterface[] = [];
isActiveKey: { [key: string]: boolean } = {}; // object to check if key is currently active isActiveKey: { [key: string]: boolean } = {}; // Object to check if key is currently active
myChart: Chart; myChart: Chart;
constructor( constructor(
@ -27,11 +27,11 @@ export class HomeComponent implements OnInit {
) { } ) { }
ngOnInit() { ngOnInit() {
// fetch all available groups // Fetch all available groups
this.fetchData('/material/groups', data => this.createGroup(data)); this.fetchData('/material/groups', data => this.createGroup(data));
} }
// api access with callback // Api access with callback
async fetchData(URL: string, processor: any) { async fetchData(URL: string, processor: any) {
this.api.get(URL, (sData, err, headers) => { this.api.get(URL, (sData, err, headers) => {
processor(sData); processor(sData);
@ -48,10 +48,10 @@ export class HomeComponent implements OnInit {
this.keys = temp; // invoke update in rb-multiselect this.keys = temp; // invoke update in rb-multiselect
this.initChart(); this.initChart();
// only neccesary if keys get preselected // Only neccesary if keys get preselected
//this.calcFieldSelectKeys(); //this.calcFieldSelectKeys();
// fetch all samples populated with according group // Fetch all samples populated with according group
this.getSamples(); this.getSamples();
} }
@ -70,7 +70,7 @@ export class HomeComponent implements OnInit {
} }
} }
// loop through samples and count // Loop through samples and count
countSamples(data: any) { countSamples(data: any) {
this.keys.map(key => key.count = 0); this.keys.map(key => key.count = 0);
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
@ -83,14 +83,14 @@ export class HomeComponent implements OnInit {
this.updateGraph(); this.updateGraph();
} }
// preset select // Preset select
calcFieldSelectKeys() { calcFieldSelectKeys() {
this.keys.forEach(key => { this.keys.forEach(key => {
this.isActiveKey[key.id] = key.active; this.isActiveKey[key.id] = key.active;
}); });
} }
// update keys based on select // Update keys based on select
updateGroups(activeKeys: any) { updateGroups(activeKeys: any) {
this.keys.forEach(key => { this.keys.forEach(key => {
if (activeKeys.hasOwnProperty(key.id)) { if (activeKeys.hasOwnProperty(key.id)) {
@ -100,7 +100,7 @@ export class HomeComponent implements OnInit {
this.getSamples(); this.getSamples();
} }
// get data for graph based on active keys // Get data for graph based on active keys
updateGraph() { updateGraph() {
let nameList: string[] = []; let nameList: string[] = [];
let dataList: number[] = []; let dataList: number[] = [];
@ -116,7 +116,7 @@ export class HomeComponent implements OnInit {
this.myChart.update(); this.myChart.update();
} }
// draw graph // Initialize graph
async initChart() { async initChart() {
this.myChart = new Chart("myChart", { this.myChart = new Chart("myChart", {
type: 'bar', type: 'bar',