Skip to content

Commit 175c558

Browse files
committed
Fix: reset implemented and Code Cleanup
1 parent c79673a commit 175c558

1 file changed

Lines changed: 50 additions & 89 deletions

File tree

src/app/component/circular-heatmap/circular-heatmap.component.ts

Lines changed: 50 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Router, NavigationExtras } from '@angular/router';
66

77
export interface taskSchema {
88
taskName: string;
9-
ifTaskDone: boolean;
9+
// ifTaskDone: boolean;
1010
teamsImplemented: any;
1111
}
1212

@@ -130,9 +130,7 @@ export class CircularHeatmapComponent implements OnInit {
130130
if (teamsImplemented) {
131131
teamStatus = teamsImplemented;
132132
}
133-
// if (Status) {
134-
// totalImplemented += 1;
135-
// }
133+
136134
// Calculating %done
137135
(
138136
Object.keys(teamStatus) as (keyof typeof teamStatus)[]
@@ -147,7 +145,6 @@ export class CircularHeatmapComponent implements OnInit {
147145

148146
tempData['Task'].push({
149147
taskName: nameOfTask,
150-
ifTaskDone: Status,
151148
teamsImplemented: teamStatus,
152149
});
153150
}
@@ -174,70 +171,6 @@ export class CircularHeatmapComponent implements OnInit {
174171
});
175172
}
176173

177-
toggleCheckbox(taskIndex: number) {
178-
let _self = this;
179-
var index = 0;
180-
var cnt = 0;
181-
for (var i = 0; i < this.ALL_CARD_DATA.length; i++) {
182-
if (
183-
this.ALL_CARD_DATA[i]['SubDimension'] === this.cardHeader &&
184-
this.ALL_CARD_DATA[i]['Level'] === this.cardSubheader
185-
) {
186-
index = i;
187-
break;
188-
}
189-
}
190-
if (this.ALL_CARD_DATA[index]['Task'][taskIndex]['ifTaskDone']) {
191-
this.ALL_CARD_DATA[index]['Task'][taskIndex]['ifTaskDone'] = false;
192-
} else {
193-
this.ALL_CARD_DATA[index]['Task'][taskIndex]['ifTaskDone'] = true;
194-
}
195-
196-
// console.log(this.data[i]["Task"][taskIndex]["done"])
197-
// Creating counter for %done
198-
for (var i = 0; i < this.ALL_CARD_DATA[index]['Task'].length; i++) {
199-
console.log(this.ALL_CARD_DATA[index]['Task'][i]['ifTaskDone']);
200-
if (this.ALL_CARD_DATA[index]['Task'][i]['ifTaskDone']) {
201-
cnt += 1;
202-
}
203-
}
204-
// Updating values in this.YamlObject
205-
var allDimensionNames = Object.keys(this.YamlObject);
206-
for (var i = 0; i < allDimensionNames.length; i++) {
207-
var allSubDimensionInThisDimension = Object.keys(
208-
this.YamlObject[allDimensionNames[i]]
209-
);
210-
for (var j = 0; j < allSubDimensionInThisDimension.length; j++) {
211-
if (allSubDimensionInThisDimension[j] == this.cardHeader) {
212-
var taskName =
213-
this.ALL_CARD_DATA[index]['Task'][taskIndex]['taskName'];
214-
this.YamlObject[allDimensionNames[i]][
215-
allSubDimensionInThisDimension[j]
216-
][taskName]['isImplemented'] =
217-
this.ALL_CARD_DATA[index]['Task'][taskIndex]['ifTaskDone'];
218-
break;
219-
}
220-
}
221-
}
222-
this.ALL_CARD_DATA[index]['Done%'] =
223-
cnt / this.ALL_CARD_DATA[index]['Task'].length;
224-
// console.log(this.data[index]['Done%'], cnt);
225-
var color = d3
226-
.scaleLinear<string, string>()
227-
.domain([0, 1])
228-
.range(['white', 'green']);
229-
230-
d3.selectAll(
231-
'#segment-' +
232-
this.ALL_CARD_DATA[index]['SubDimension'].replace(/ /g, '-') +
233-
'-' +
234-
this.ALL_CARD_DATA[index]['Level'].replace(' ', '-')
235-
).attr('fill', function (p) {
236-
return color(_self.ALL_CARD_DATA[index]['Done%']);
237-
});
238-
this.saveState();
239-
}
240-
241174
teamCheckbox(taskIndex: number, teamKey: any) {
242175
let _self = this;
243176
var index = 0;
@@ -257,17 +190,13 @@ export class CircularHeatmapComponent implements OnInit {
257190
!this.ALL_CARD_DATA[index]['Task'][taskIndex]['teamsImplemented'][
258191
teamKey
259192
];
260-
// Working on %done
261193
// Creating counter for %done
262194
for (var i = 0; i < this.ALL_CARD_DATA[index]['Task'].length; i++) {
263-
console.log(this.ALL_CARD_DATA[index]['Task'][i]['ifTaskDone']);
264-
265195
var teamList: any;
266196
teamList = this.ALL_CARD_DATA[index]['Task'][i]['teamsImplemented'];
267197
(Object.keys(teamList) as (keyof typeof teamList)[]).forEach(
268198
(key, index) => {
269199
if (teamList[key] === true) {
270-
console.log(key, ' is true');
271200
cntTrue += 1;
272201
}
273202
cntAll += 1;
@@ -391,10 +320,8 @@ export class CircularHeatmapComponent implements OnInit {
391320
} catch {
392321
curr = d.toElement.__data__;
393322
}
394-
//console.log(curr)
395323
// increase the segment height of the one being hovered as well as all others of the same date
396324
// while decreasing the height of all others accordingly
397-
//console.log(d)
398325
if (curr['Done%'] != -1) {
399326
d3.selectAll(
400327
'#segment-' +
@@ -408,11 +335,6 @@ export class CircularHeatmapComponent implements OnInit {
408335
.on('mouseout', function (d) {
409336
//console.log(d.explicitOriginalTarget.__data__.Day)
410337

411-
// var time = d.Time;
412-
// var timeCleaned = time.split(":").join("-");
413-
// var segment = d3.select("#segment-"+d.Day +"-"+timeCleaned); //designate selector variable for brevity
414-
// var fillcolor = segment.select("desc").text(); //access original color from desc
415-
// segment.style("fill", fillcolor);
416338
if (curr['Done%'] != -1) {
417339
d3.selectAll(
418340
'#segment-' +
@@ -682,7 +604,6 @@ export class CircularHeatmapComponent implements OnInit {
682604
this.showOverlay = false;
683605
}
684606
SaveEditedYAMLfile() {
685-
//console.log(this.YamlObject);
686607
let yamlStr = yaml.dump(this.YamlObject);
687608
let file = new Blob([yamlStr], { type: 'text/csv;charset=utf-8' });
688609
var link = document.createElement('a');
@@ -691,20 +612,60 @@ export class CircularHeatmapComponent implements OnInit {
691612
link.click();
692613
link.remove();
693614
}
615+
reColorHeatmap() {
616+
for (var index = 0; index < this.ALL_CARD_DATA.length; index += 1) {
617+
let cntAll: number = 0;
618+
let cntTrue: number = 0;
619+
var _self = this;
620+
for (var i = 0; i < this.ALL_CARD_DATA[index]['Task'].length; i++) {
621+
var teamList: any;
622+
teamList = this.ALL_CARD_DATA[index]['Task'][i]['teamsImplemented'];
623+
(Object.keys(teamList) as (keyof typeof teamList)[]).forEach(
624+
(key, index) => {
625+
if (teamList[key] === true) {
626+
cntTrue += 1;
627+
}
628+
cntAll += 1;
629+
}
630+
);
631+
}
632+
if (cntAll !== 0) {
633+
this.ALL_CARD_DATA[index]['Done%'] = cntTrue / cntAll;
634+
// console.log(this.ALL_CARD_DATA[index]['Done%'], cntTrue);
635+
var color = d3
636+
.scaleLinear<string, string>()
637+
.domain([0, 1])
638+
.range(['white', 'green']);
639+
640+
d3.selectAll(
641+
'#segment-' +
642+
this.ALL_CARD_DATA[index]['SubDimension'].replace(/ /g, '-') +
643+
'-' +
644+
this.ALL_CARD_DATA[index]['Level'].replace(' ', '-')
645+
).attr('fill', function (p) {
646+
return color(_self.ALL_CARD_DATA[index]['Done%']);
647+
});
648+
}
649+
}
650+
// this.noTasktoGrey();
651+
}
694652

695653
ResetIsImplemented() {
696654
for (var x = 0; x < this.ALL_CARD_DATA.length; x++) {
697655
if (this.ALL_CARD_DATA[x]['Done%'] > 0) {
698-
this.ALL_CARD_DATA[x]['Done%'] = 0;
656+
// this.ALL_CARD_DATA[x]['Done%'] = 0;
699657
for (var y = 0; y < this.ALL_CARD_DATA[x]['Task'].length; y++) {
700-
this.ALL_CARD_DATA[x]['Task'][y]['ifTaskDone'] = false;
658+
var currTaskTeamsImplemented =
659+
this.ALL_CARD_DATA[x]['Task'][y]['teamsImplemented'];
660+
(
661+
Object.keys(
662+
currTaskTeamsImplemented
663+
) as (keyof typeof currTaskTeamsImplemented)[]
664+
).forEach((key, index) => {
665+
currTaskTeamsImplemented[key] = false;
666+
});
701667
}
702-
d3.selectAll(
703-
'#segment-' +
704-
this.ALL_CARD_DATA[x]['SubDimension'].replace(/ /g, '-') +
705-
'-' +
706-
this.ALL_CARD_DATA[x]['Level'].replace(' ', '-')
707-
).attr('fill', 'white');
668+
this.reColorHeatmap();
708669
}
709670
}
710671
this.saveState();

0 commit comments

Comments
 (0)