-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCJAnalysis.js
More file actions
209 lines (177 loc) · 6.3 KB
/
CJAnalysis.js
File metadata and controls
209 lines (177 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
function include(filePath, fileType) {
const scriptTag = document.createElement("script");
scriptTag.src = filePath;
scriptTag.type = fileType;
document.body.appendChild(scriptTag);
}
const plugin = ({widgets, simulator, prototype}) => {
let arryRowData = [];
let counter = 0
var data = prototype.customer_journey
let size = prototype.customer_journey ? Object.keys(data[0]).length : 0
if(counter === 0) {
for(let i=0; i<size;i++) {
arryRowData.push({
dt: "",
cld: "",
b1: "",
sdv:"",
b2: "",
veh: "",
vt: ""
})
}
counter++}
function GetTable (keys,arrayRowData) {
let rv = keys.map(function (key, index) {
var color1 = ["#ffffff", "#003a6f", "#005072", "#276577", "#396c6e", "#5c855f", "#598234", "#8da44a", "#aebd38", "#006f4d"];
if (key !== "") {
let container1 = document.createElement("div")
container1.innerHTML =
`
<div style= "background-color: ${color1[index]}; padding: 0; color:#ffffff; ">
<div className="grid " style="display: grid; grid-template-columns: auto auto auto">
<img src= "https://ngisvtrkzzxmikxlhgdt.supabase.co/storage/v1/object/public/playground.plugins/arrow-right-circle-fill-white.svg" style="height:30px; width: 50px; color: #ffffff; text-align:left;">
<div style="text-align: center; grid-column: 2 / span 2; font-weight:bold;">
${key}
</div>
</div>
</div>
<table style= "width: 100% ; ">
<tr>
<td> ${arrayRowData[index -1].dt}</td>
<td> ${arrayRowData[index -1].cld}</td>
<td> ${arrayRowData[index -1].b1}</td>
<td> ${arrayRowData[index -1].sdv}</td>
<td> ${arrayRowData[index -1].b2}</td>
<td> ${arrayRowData[index -1].veh}</td>
<td> ${arrayRowData[index -1].vt}</td>
</tr>
</table>
`
return ( container1 );
}
}
)
return rv;
};
let finalContainer = null;
var CJAnalysis = function () {
var keys = Object.keys(data).length === 0 ? [] : Object.keys(data[0]);
let fillerHTML = GetTable(keys, arryRowData);
finalContainer = document.createElement("div")
fillerHTML.forEach((element, index) => {
if(element !== undefined && index === 1) {
finalContainer = element
}
else if(element !== undefined) {
let child1 = element.children[0];
let child2 = element.children[1];
finalContainer.appendChild(child1)
finalContainer.appendChild(child2)
}
})
console.log(finalContainer);
let analysis = `
<style>
.gridContainer {
display: grid;
grid-template-columns: auto auto auto auto auto auto auto;
gap: 5px;
padding: 5px;
}
div {
text-align: center;
padding: 10px 0;
font-size: 20px;
}
.header1 {
grid-column: 1 / 8;
background-color: #d9d9d9;
font-weight:bold;
border-radius: 15px 15px 0px 0px;
}
.header21 {
grid-column: 1 / 3;
background-color: #d9d9d9;
font-weight:bold;
}
.header22 {
grid-column: 3/ 8;
background-color: #d9d9d9;
font-weight:bold;
}
.tableHeader {
font-weight:bolder;
text-align: center;
width: 240px;
word-wrap: break-word;
}
.gridContainer table, th, td {
text-align: center;
}
.tableStepHeader {
grid-column: 1/ 8;
padding: 0;
}
.tableStepHeader.circle{
background-color: #fff;
}
.tableStepHeader table{
table-layout: fixed;
}
.tableStepHeader table tr td:nth-child(odd) {
background:#f2f2f2;
}
.tableStepHeader table tr td:nth-child(even) {
background:#c8e3fb;
}
.tableStepHeader table tr td {
height: 100px;
font-size: 18px;
word-wrap: break-word;
}
</style>
<div class = "gridContainer">
<div class = "header1" >Systems-of-systems</div>
<div class = "header21" >Off-Board</div>
<div class = "header22">On-Board</div>
<div class = "tableHeader">Digital Touchpoints </div>
<div class = "tableHeader "> Cloud/ Backend</div>
<div class = "tableHeader ">
<img src= "https://ngisvtrkzzxmikxlhgdt.supabase.co/storage/v1/object/public/playground.plugins/triangles.svg" style="height:30px; width: 50px; margin: auto; object-fit: contain;">
</div>
<div class = "tableHeader ">SdV</div>
<div class = "tableHeader">
<img src= "https://ngisvtrkzzxmikxlhgdt.supabase.co/storage/v1/object/public/playground.plugins/triangles.svg" style="height:30px; width: 50px; margin: auto; object-fit: contain;">
</div>
<div class = "tableHeader" >E/E Vehicle </div>
<div class = "tableHeader" >Vehicle Touchpoints</div>
<div class = "tableStepHeader">
</div>
</div>
`
return keys.length === 0 ? null : (analysis);
}
let global_box = null
widgets.register("CJAnalysis", (box) => {
global_box = box
let container = document.createElement("div")
container.innerHTML = CJAnalysis()
let test = container.querySelector(".tableStepHeader")
test.innerHTML = finalContainer.innerHTML
box.injectNode(container)
}
)
return {
set_text_CA: (colHead, stepNo, bodyData) => {
arryRowData[stepNo][colHead] = bodyData;
let container = document.createElement("div")
container.innerHTML = CJAnalysis()
let test = container.querySelector(".tableStepHeader")
test.innerHTML = finalContainer.innerHTML
global_box.injectNode(container)
}
}
}
export default plugin