Skip to content

Commit e9d2854

Browse files
authored
Merge pull request #124 from 0x41head/angular-ui
Added initial commit for YAML download button
2 parents b2da34c + bb6d75c commit e9d2854

7 files changed

Lines changed: 136 additions & 72 deletions

File tree

package-lock.json

Lines changed: 59 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@angular/platform-browser-dynamic": "~13.3.0",
2222
"@angular/router": "~13.3.0",
2323
"d3": "^7.5.0",
24+
"js-yaml": "^4.1.0",
2425
"markdown-it": "^13.0.1",
2526
"rxjs": "~7.5.0",
2627
"tslib": "^2.3.0",
@@ -33,6 +34,7 @@
3334
"@angular/compiler-cli": "~13.3.0",
3435
"@types/d3": "^7.4.0",
3536
"@types/jasmine": "~3.10.0",
37+
"@types/js-yaml": "^4.0.5",
3638
"@types/markdown-it": "^12.2.3",
3739
"@types/node": "^12.11.1",
3840
"@types/yamljs": "^0.2.31",

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
stroke: #000;
88
shape-rendering: crispEdges;
99
}
10-
.abc{
10+
.heatmapClass{
1111
background-color: aquamarine;
1212
}
1313
.example-card {
@@ -16,3 +16,7 @@
1616
margin:5%;
1717
padding: 20px;
1818
}
19+
.buttonClass{
20+
float: right;
21+
margin: 5%;
22+
}

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@
33
<div class="col-md-3">
44
</div>
55
<div class="col-md-6">
6-
<div id="chart" class="abc">
7-
<mat-card class="example-card" *ngIf="show">
6+
<div id="chart" class="heatmapClass">
7+
<mat-card class="example-card" *ngIf="showTaskCard">
88
<mat-card-title-group>
9-
<mat-card-title>{{header}}</mat-card-title>
10-
<mat-card-subtitle>{{subheader}}</mat-card-subtitle>
9+
<mat-card-title>{{taskHeader}}</mat-card-title>
10+
<mat-card-subtitle>{{taskSubheader}}</mat-card-subtitle>
1111
</mat-card-title-group>
12-
<mat-card-content *ngFor="let task of tasks;index as i">
13-
<div *ngIf="task.done; then trueBlock else falseBlock"></div>
12+
<mat-card-content *ngFor="let task of tasksData;index as i">
13+
<div *ngIf="task.ifTaskDone; then trueBlock else falseBlock"></div>
1414
<p>
1515
<ng-template #trueBlock>
16-
<mat-checkbox (click)="this.checkboxToggle(i)" [checked]="true" color="primary">
17-
{{task["name"]}}
16+
<mat-checkbox (click)="this.toggleCheckbox(i)" [checked]="true" color="primary">
17+
{{task["taskName"]}}
1818
</mat-checkbox>
1919
</ng-template>
2020
<ng-template #falseBlock>
21-
<mat-checkbox (click)="this.checkboxToggle(i)" [checked]="false" color="primary">
22-
{{task["name"]}}
21+
<mat-checkbox (click)="this.toggleCheckbox(i)" [checked]="false" color="primary">
22+
{{task["taskName"]}}
2323
</mat-checkbox>
2424
</ng-template>
2525
</p>
2626
</mat-card-content>
2727
</mat-card>
28-
</div>
29-
28+
<button class="buttonClass" (click)="SaveDemo()">Save As</button>
29+
</div>
3030
</div>
3131
<div class="col-md-3">
3232
</div>

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

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Component, OnInit } from '@angular/core';
22
import { ymlService } from '../../service/yaml-parser/yaml-parser.service';
33
import * as d3 from 'd3';
4+
import * as yaml from "js-yaml"
45

56
export interface taskSchema{
6-
name:string
7-
done:boolean
7+
taskName:string
8+
ifTaskDone:boolean
89
}
910

1011
export interface cardSchema{
@@ -20,12 +21,12 @@ export interface cardSchema{
2021
styleUrls: ['./circular-heatmap.component.css']
2122
})
2223
export class CircularHeatmapComponent implements OnInit {
23-
maxLevel:number=-1
24-
show:boolean=false
25-
header:string=''
26-
subheader:string=''
27-
tasks:any[]=[]
28-
data:cardSchema[] =[];
24+
maxLevelOfTasks:number=-1
25+
showTaskCard:boolean=false
26+
taskHeader:string=''
27+
taskSubheader:string=''
28+
tasksData:any[]=[]
29+
ALL_CARD_DATA:cardSchema[] =[];
2930
radial_labels:string[]= [];
3031
YamlObject:any;
3132
segment_labels:string[] = [];
@@ -41,7 +42,7 @@ export class CircularHeatmapComponent implements OnInit {
4142
for(let x in this.YamlObject['strings']['en']['maturity_levels']){
4243
var y=parseInt(x)+1
4344
this.radial_labels.push('Level '+y)
44-
this.maxLevel=y
45+
this.maxLevelOfTasks=y
4546
}
4647

4748
});
@@ -55,7 +56,7 @@ export class CircularHeatmapComponent implements OnInit {
5556
for(var x in this.YamlObject['dimension']){
5657
this.segment_labels.push(this.YamlObject['dimension'][x]['subdimension']['name'])
5758
}
58-
for(var l=0 ; l<this.maxLevel; l++){
59+
for(var l=0 ; l<this.maxLevelOfTasks; l++){
5960
for(var x in this.YamlObject['dimension']){
6061
var tempdata:cardSchema={
6162
"Name": "",
@@ -73,57 +74,67 @@ export class CircularHeatmapComponent implements OnInit {
7374
if(Status){
7475
totalImplemented+=1
7576
}
76-
tempdata["Task"].push({"name":nameOfTask,"done":Status})
77+
tempdata["Task"].push({"taskName":nameOfTask,"ifTaskDone":Status})
7778
}
7879
tempdata["Done%"]=totalImplemented/this.YamlObject['dimension'][x]['subdimension']['level-'+(l+1)].length
7980
}
8081
catch{
8182
tempdata["Done%"]=-1
8283
}
83-
this.data.push(tempdata)
84+
this.ALL_CARD_DATA.push(tempdata)
8485
}
8586
}
86-
console.log(this.data)
87-
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
87+
console.log(this.ALL_CARD_DATA)
88+
this.loadCircularHeatMap(this.ALL_CARD_DATA, "#chart", this.radial_labels, this.segment_labels);
8889
this.noTasktoGrey()
8990
})
9091
}
9192

92-
checkboxToggle(taskIndex:number){
93+
toggleCheckbox(taskIndex:number){
9394
//console.log('fo')
9495
let _self=this
9596
var index=0;
9697
var cnt=0;
97-
for(var i=0;i<this.data.length;i++){
98-
if(this.data[i]["Name"]===this.header&&this.data[i]["Level"]===this.subheader){
98+
for(var i=0;i<this.ALL_CARD_DATA.length;i++){
99+
if(this.ALL_CARD_DATA[i]["Name"]===this.taskHeader&&this.ALL_CARD_DATA[i]["Level"]===this.taskSubheader){
99100
index=i
100101
break;
101102
}
102103
}
103-
if(this.data[index]["Task"][taskIndex]["done"]){
104-
this.data[index]["Task"][taskIndex]["done"]=false
104+
if(this.ALL_CARD_DATA[index]["Task"][taskIndex]["ifTaskDone"]){
105+
this.ALL_CARD_DATA[index]["Task"][taskIndex]["ifTaskDone"]=false
105106
}
106107
else{
107-
this.data[index]["Task"][taskIndex]["done"]=true
108+
this.ALL_CARD_DATA[index]["Task"][taskIndex]["ifTaskDone"]=true
108109
}
109110
//console.log(this.data[i]["Task"][taskIndex]["done"])
110-
for(var i=0;i< this.data[index]["Task"].length;i++){
111-
console.log(this.data[index]["Task"][i]["done"])
112-
if(this.data[index]["Task"][i]["done"]){
111+
for(var i=0;i< this.ALL_CARD_DATA[index]["Task"].length;i++){
112+
console.log(this.ALL_CARD_DATA[index]["Task"][i]["ifTaskDone"])
113+
if(this.ALL_CARD_DATA[index]["Task"][i]["ifTaskDone"]){
113114
cnt+=1
114115
}
115116
}
116-
this.data[index]['Done%']=cnt/this.data[index]["Task"].length
117+
this.ALL_CARD_DATA[index]['Done%']=cnt/this.ALL_CARD_DATA[index]["Task"].length
117118
//console.log(this.data[index]['Done%'],cnt)
118119
var color = d3.scaleLinear<string,string>().domain([0,1]).range(["white", "green"]);
119120

120-
this.loadCircularHeatMap(this.data, "#chart", this.radial_labels, this.segment_labels);
121-
d3.selectAll("#segment-" + this.data[index]["Name"]+'-'+this.data[index]["Level"].replace(' ','-')).attr("fill", function(p) {
122-
return color(_self.data[index]["Done%"])
121+
this.loadCircularHeatMap(this.ALL_CARD_DATA, "#chart", this.radial_labels, this.segment_labels);
122+
d3.selectAll("#segment-" + this.ALL_CARD_DATA[index]["Name"]+'-'+this.ALL_CARD_DATA[index]["Level"].replace(' ','-')).attr("fill", function(p) {
123+
return color(_self.ALL_CARD_DATA[index]["Done%"])
123124
});
124125

125126
}
126127

128+
SaveDemo() {
129+
let yamlStr = yaml.dump(this.YamlObject);
130+
let file = new Blob([yamlStr], { type: 'text/csv;charset=utf-8' });
131+
var link = document.createElement('a');
132+
link.href = window.URL.createObjectURL(file);
133+
link.download = './hlll.txt'
134+
link.click();
135+
link.remove();
136+
}
137+
127138
loadCircularHeatMap(dataset:any, dom_element_to_append_to:string, radial_labels:string[], segment_labels:string[]) {
128139
//d3.select(dom_element_to_append_to).selectAll('svg').exit()
129140
//console.log(dataset)
@@ -177,11 +188,11 @@ export class CircularHeatmapComponent implements OnInit {
177188

178189
svg.selectAll("path")
179190
.on('click', function(d) {
180-
_self.subheader=d.explicitOriginalTarget.__data__.Level
181-
_self.tasks=d.explicitOriginalTarget.__data__.Task;
182-
_self.header=d.explicitOriginalTarget.__data__.Name
183-
_self.show=true
184-
console.log(_self.tasks)
191+
_self.taskSubheader=d.explicitOriginalTarget.__data__.Level
192+
_self.tasksData=d.explicitOriginalTarget.__data__.Task;
193+
_self.taskHeader=d.explicitOriginalTarget.__data__.Name
194+
_self.showTaskCard=true
195+
console.log(_self.tasksData)
185196
})
186197
.on('mouseover', function(d) {
187198

@@ -384,9 +395,9 @@ export class CircularHeatmapComponent implements OnInit {
384395
}
385396

386397
noTasktoGrey():void{
387-
for (var x in this.data){
388-
if (this.data[x]["Done%"]==-1){
389-
d3.selectAll("#segment-" + this.data[x]["Name"]+'-'+this.data[x]["Level"].replace(' ','-')).attr("fill","#DCDCDC");
398+
for (var x in this.ALL_CARD_DATA){
399+
if (this.ALL_CARD_DATA[x]["Done%"]==-1){
400+
d3.selectAll("#segment-" + this.ALL_CARD_DATA[x]["Name"]+'-'+this.ALL_CARD_DATA[x]["Level"].replace(' ','-')).attr("fill","#DCDCDC");
390401
}
391402
}
392403
}

src/app/component/matrix/matrix.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<mat-chip-list #chipList aria-label="Filter" color="primary">
66
<mat-chip
77
color="primary"
8-
*ngFor="let row of rows"
8+
*ngFor="let row of rowsCurrentlyBeingShown"
99
(removed)="remove(row)"
1010
[selected]=true>
1111
{{row}}

0 commit comments

Comments
 (0)