-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.html
More file actions
530 lines (436 loc) · 15.6 KB
/
widget.html
File metadata and controls
530 lines (436 loc) · 15.6 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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: Arial, Helvetica, sans-serif;}
* {box-sizing: border-box;}
/* Button used to open the chat form - fixed at the bottom of the page */
.open-button {
padding: 16px 20px;
position: fixed;
bottom: 23px;
right: 28px;
width: 200px;
background-color: #0052cc;
color: #fff;
outline: none;
height: 50px;
border-radius: 999px;
text-align: center;
text-decoration: none;
box-shadow: 0 1px 2px 0 #7a869a;
font-weight: 600;
cursor: pointer;
font-size: 18px;
}
h1 {
margin: 5px;
font-size: 25px;
}
/* The popup chat - hidden by default */
.chat-popup {
display: none;
position: fixed;
bottom: 0;
right: 15px;
border: 3px solid #f1f1f1;
z-index: 9;
}
/* Add styles to the form container */
.form-container {
max-width: 300px;
padding: 10px;
background-color: white;
}
/* Full-width textarea */
.form-container textarea {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
border: none;
background: #f1f1f1;
resize: none;
min-height: 50px;
}
/* When the textarea gets focus, do something */
.form-container textarea:focus {
background-color: #ddd;
outline: none;
}
/* Set a style for the submit/send button */
.form-container .btn {
background-color: #0052cc;
color: white;
padding: 16px 20px;
border: none;
cursor: pointer;
width: 45%;
margin-bottom:10px;
opacity: 1;
font-size: 18px;
margin-left: 7px;
height: 10px;
line-height: 2px;
border-radius: 5px;
}
/* Add a red background color to the cancel button */
.form-container .cancel {
background-color: #f3f3f7;
color: grey;
}
.closeall{
background-color: #f3f3f7;
color: grey;
width: 95% !important;
}
/* Add some hover effects to buttons */
.form-container .btn:hover, .open-button:hover {
opacity: 0.9;
}
#summary{
margin-bottom: 5px !important;
}
#description{
height: 100px !important;
}
table {
border-radius: 5px;
border-collapse: collapse;
width: 100%;
font-size: 15px;
margin-bottom: 10px;
}
td{border: 1px solid #dddddd;
text-align: left;
padding: 5px;
}
th {
border: 1px solid #dddddd;
text-align: left;
padding: 5px;
background-color: #0052cc;
color: white;
}
tr:nth-child(even) {
background-color: #dddddd;
}
.modal,
.modal-box {
z-index: 900;
}
.modal-sandbox {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: transparent;
}
.modal {
display: none;
position: fixed;
width: 100%;
height: 100%;
left: 0;
top: 0;
background: rgb(0,0,0);
background: rgba(0,0,0,.8);
overflow: auto;
}
.modal-box {
position: relative;
width: 80%;
max-width: 920px;
margin: 100px auto;
animation-name: modalbox;
animation-duration: .4s;
animation-timing-function: cubic-bezier(0,0,.3,1.6);
}
.modal-header {
padding: 20px 40px;
background: #546E7A;
color: #ffffff;
}
.modal-body {
background: #ECEFF1;
padding: 60px 40px;
}
/* Close Button */
.close-modal {
text-align: right;
cursor: pointer;
}
/* Animation */
@-webkit-keyframes modalbox {
0% {
top: -250px;
opacity: 0;
}
100% {
top: 0;
opacity: 1;
}
}
@keyframes modalbox {
0% {
top: -250px;
opacity: 0;
}
100% {
top: 0;
opacity: 1;
}
}
</style>
</head>
<body>
<!-- <a href="#" class="modal-trigger" data-modal="modal-name">Modal open!</a> -->
<!-- Modal -->
<div class="modal" id="modal-name">
<div class="modal-sandbox"></div>
<div class="modal-box">
<div class="modal-header">
<div class="close-modal">✖</div>
<h1>Simple modal box</h1>
</div>
<div class="modal-body">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic soluta saepe, atque, iure quidem maiores non dolores, fuga eaque voluptatibus corporis accusantium quas. Eligendi velit eum fugiat eius? Distinctio reiciendis sint error, repellat ut soluta doloremque, accusamus vitae placeat?</p>
<p>Laboriosam voluptas, iure rem provident laborum culpa atque fugit inventore sit. Corrupti dolore architecto inventore officia, odit totam voluptatem laboriosam tempore reiciendis, et neque, consequuntur. Non, tenetur? Tempore reprehenderit tenetur nemo asperiores alias commodi assumenda architecto minima numquam repellendus debitis nulla, rerum officia itaque, sunt nihil sequi quod perspiciatis, animi quas voluptates velit aperiam voluptatem.</p>
<br />
<button class="close-modal">Close!</button>
</div>
</div>
</div>
<h2>Ticketing Widget POC</h2>
<div style="width:75%; text-align: justify;">
<p><b>IMPORTANT: Please click on the Alert icon on the right most part of your address bar and click on Load Scripts to make this work.</b></p>
<p>Concept:</p>
<p>A Widget needs to be available on the dashboard which first allows the Dashboard User to check for relevant articles, then the User can go ahead and search via a relevant Keyword.
Now, all articles are stored at CS's Knowledge base, which is maintained by Aaryender and can be found here: https://wizrocket.atlassian.net/wiki/spaces/CSK/overview</p>
<p>The number of articles shown as per result are restricted to 5 for the POC and are ordered by score given to each result by Confluence search api itself.</p>
<p>Clicking any of the articles in this POC will can open up a modal with details of the article, it can also be redirected to the main conflunce page.</p>
<p>If the Dashboard User is unable to find any article useful for him/herself, they can go ahead an contact DK.</p>
<p>Here, they can log a summary and complete description of the problem they are facing. The widget on submit click finds meta data and combines it with User Input to create a Jira Ticket.</p>
<p>For POC purposes a few values have been hardcoded and attached to the description the User enters, this is after the User clicks on sumbit button.</p>
<p>Also, this widget is working perfectly, so each time someone clicks on submit a ticket is logged, so be carefully while checking this around.</p>
<p>Lastly, you can check the ticket created on to the last page, where if you clcik you will be taken to the portal with detais of the ticket and also if you explore you can see all past tickets.</p>
</div>
<button class="open-button" onclick="openForm()">We are here!</button>
<div class="chat-popup" id="myhelpForm">
<div class="form-container">
<h1 style="text-align: center;">Help</h1>
<textarea placeholder="Type search keywords[e.g.: Attribution]" name="msg" id="searchkey" required></textarea>
<button type="button" id="searchSubmit" onclick="search()" class="btn">Search</button>
<button type="button" class="btn cancel" onclick="closeForm()">Close</button>
<div id="searchResults" style="display: none">
<ul id="results"></ul>
<h4 style="text-align: center;">Can't find what you are looking for?</h4>
<button class="btn" style="width: 95%" onclick="openJiraForm()">Contact DK</button>
</div>
</div>
</div>
<div class="chat-popup" id="jiraForm">
<div class="form-container">
<h1 style="text-align: center;">Support</h1>
<textarea placeholder="Summary" name="msg" id="summary" required></textarea>
<textarea placeholder="Description" name="msg" id="description" required></textarea>
<button type="button" id="jiraFormSubmit" onclick="submitJiraForm()" class="btn">Submit</button>
<button type="button" class="btn cancel" onclick="closeJiraForm()">Close</button>
</div>
</div>
<div class="chat-popup" id="finalpage">
<div class="form-container">
<h1 style="text-align: center;">Support Request History</h1>
<div id="newRequestSpace">
<h4 style="text-align: center;">New Request Created</h4>
<table id="newRequestSpaceTable">
<tr>
<th>Ticket ID</th>
<th>Status</th>
</tr>
</table>
</div>
<div id="oldRequestSpace">
<h4 style="text-align: center;">Previous Requests</h4>
<table id="oldRequestSpaceTable">
<tr>
<th>Ticket ID</th>
<th>Status</th>
</tr>
</table>
</div>
<button type="button" class="btn closeall" onclick="closeall()">Close</button>
</div>
</div>
<script>
$(function() {
setMetaData();
getOldTickets();
});
function setMetaData() {
window.localStorage.setItem('Account ID', 'ABC-XYZK-8765');
window.localStorage.setItem('Account Name', 'ABC.com');
window.localStorage.setItem('ES IP', '10.11.80.21');
window.localStorage.setItem('Redis IP', '10.11.64.25');
window.localStorage.setItem('Page', window.location.pathname);
window.localStorage.setItem('Reporter', "dk@clevertap.com");
window.localStorage.setItem('TZ', "ME");
}
function openForm() {
document.getElementById("myhelpForm").style.display = "block";
}
function openJiraForm() {
document.getElementById("jiraForm").style.display = "block";
document.getElementById("myhelpForm").style.display = "none";
}
function printOldTickets(res) {
res = JSON.parse(res);
var tb = $('#oldRequestSpaceTable');
var maxResult = 5;
var threshold = 0;
if ((res["issues"]).length > maxResult) {
threshold = maxResult;
} else {
threshold = (res["issues"]).length;
}
for (i = 0; i < threshold; i++) {
result = res["issues"][i];
tid = result["key"];
link = "https://wizrocket.atlassian.net/servicedesk/customer/portal/8/" + tid;
status = result["fields"]["status"]["name"];
var data = "<tr><td><a target='_blank' href=" + link + ">" + tid + "</a></td><td>" + status + "</td>";
tb.append(data);
}
}
function printSuccessResponse(res) {
res = JSON.parse(res);
var tb = $('#newRequestSpaceTable');
document.getElementById("jiraForm").style.display = "none";
document.getElementById("finalpage").style.display = "block";
tid = res["key"];
link = "https://wizrocket.atlassian.net/servicedesk/customer/portal/8/" + tid;
status = "Open";
var data = "<tr><td><a target='_blank' href=" + link + ">" + tid + "</a></td><td>" + status + "</td>";
tb.append(data);
}
function printResults(res) {
res = JSON.parse(res);
var ul = $('#results');
var maxResult = 5;
var threshold = 0;
if ((res["results"]).length > maxResult) {
threshold = maxResult;
} else {
threshold = (res["results"]).length;
}
document.getElementById("searchResults").style.display = "block";
for (i = 0; i < threshold; i++) {
result = res["results"][i];
content = result["content"]["title"];
cid = result["content"]["id"];
link = "https://wizrocket.atlassian.net/wiki/spaces/CSK/pages/" +cid;
var data = "<li><a target='_blank' href=" + link + ">" + content + "</a></li>";
ul.append(data);
}
}
function getOldTickets() {
reporter = getMetaData("Reporter");
var res = {};
var data = JSON.stringify();
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if (xhr.readyState === 4) {
res = xhr.response;
printOldTickets(res);
}
});
url = "http://34.212.26.146/getOldTickets?reporter=" + reporter;
xhr.open("GET", url);
xhr.setRequestHeader("Accept", "application/json");
xhr.send(data);
}
function submitJiraForm() {
document.getElementById("jiraForm").style.display = "none";
document.getElementById("finalpage").style.display = "block";
summary = document.getElementById("summary").value;
desc = document.getElementById("description").value;
var res = {};
var data = JSON.stringify();
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if (xhr.readyState === 4) {
res = xhr.response;
printSuccessResponse(res);
}
});
acid = getMetaData("Account ID");
acname = getMetaData("Account Name");
esip = getMetaData("ES IP");
redisip = getMetaData("Redis IP");
pageurl = getMetaData("Page");
reporter = getMetaData("Reporter");
tz = getMetaData("TZ");
meta = [acid, acname, esip, redisip, pageurl];
url = "http://34.212.26.146/createTicket?summary=" + summary + "&desc=" + desc + "&meta=" + meta + "&tz=" + tz;
xhr.open("GET", url);
xhr.setRequestHeader("Accept", "application/json");
xhr.send(data);
}
function getMetaData(x) {
return window.localStorage.getItem(x);
}
function search() {
skey = document.getElementById("searchkey").value;
var res = {}
var data = JSON.stringify();
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if (xhr.readyState === 4) {
res = xhr.response;
printResults(res);
}
});
url = "http://34.212.26.146/getSearchResults?skey=" + skey
xhr.open("GET", url);
xhr.setRequestHeader("Accept", "application/json");
xhr.send(data);
}
function closeForm() {
document.getElementById("myhelpForm").style.display = "none";
document.getElementById("searchResults").style.display = "none";
var ul = $('#results');
ul.remove();
$("#searchResults").prepend("<ul id='results'></ul>");
}
function closeall() {
document.getElementById("myhelpForm").style.display = "none";
document.getElementById("jiraForm").style.display = "none";
document.getElementById("searchResults").style.display = "none";
document.getElementById("finalpage").style.display = "none";
}
function closeJiraForm() {
document.getElementById("jiraForm").style.display = "none";
document.getElementById("searchResults").style.display = "none";
var ul = $('#results');
ul.remove();
$("#searchResults").prepend("<ul id='results'></ul>");
}
$(".modal-trigger").click(function(e) {
e.preventDefault();
dataModal = $(this).attr("data-modal");
$("#" + dataModal).css({ "display": "block" });
// $("body").css({"overflow-y": "hidden"}); //Prevent double scrollbar.
});
$(".close-modal, .modal-sandbox").click(function() {
$(".modal").css({ "display": "none" });
// $("body").css({"overflow-y": "auto"}); //Prevent double scrollbar.
});
</script>
</body>
</html>