-
Notifications
You must be signed in to change notification settings - Fork 0
/
appscript.html
580 lines (546 loc) · 26 KB
/
appscript.html
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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>app script project management</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment-with-locales.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.43/moment-timezone.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<link rel="stylesheet" href="https://md-shefat-masum.github.io/project_management_app_script/style.css">
<script>
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
</script>
</head>
<body class="bg-dark">
<div id="app">
<div class="app_content">
<div class="sidebar ">
<h1>Task Manger</h1>
<nav>
<ul>
<li>
<router-link to="/"><i class="fa fa-pie-chart"></i> Dashboard</router-link>
</li>
<li>
<router-link to="/tasks"><i class="fa fa-pie-chart"></i> Tasks</router-link>
</li>
<li>
<router-link to="/task_json"><i class="fa fa-pie-chart"></i> task json</router-link>
</li>
</ul>
</nav>
</div>
<div class="app_body">
<header>
<div class="row">
<div class="col-md-6 d-flex align-items-center gap-2">
<button onclick="document.querySelector('.app_content').classList.toggle('nav_hide')"
class="nav_toggler"><i class="fa fa-align-left"></i></button>
<div id="today_date"></div>
</div>
<div class="col-md-6 text-end">
<div class="d-inline-block">
<div class="d-flex align-items-center gap-4">
<h4 class="text-capitalize">Work Time:</h4>
<h4 class="qty" id="working_hour" data-work_sec="<?= sum_of_track_secs() ?>">00:00:00</h4> min
<!-- <button class="btn btn-secondary px-4" style="opacity:0; visibility:hidden;">
<i class="fa-solid fa-play tracker_control"></i>
</button> -->
</div>
</div>
</div>
</div>
</header>
<div class="router_contents">
<router-view></router-view>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14"></script>
<script src="https://unpkg.com/vue-router@3/dist/vue-router.js"></script>
<script>
let dashboard = Vue.component("dashboard", {
created: function () {
console.log("dashboard init");
},
methods: {},
template: `
<section class="my-5">
<div class="container">
<h2 class="mb-5">At A Glance</h2>
<div class="row gy-3">
<div class="col-md-4">
<div class="card progress_cards shadow-sm border-0">
<div class="card-body">
<h3 class="heading"> Start Date </h3>
<div class=" bottom d-flex justify-content-between">
<div class="progresss d-flex">
<div class="qty">
<?= get_project_start_date() ?>
</div>
</div>
<div class="icon">
<i class="fa-solid fa-arrow-trend-up"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card progress_cards shadow-sm border-0">
<div class="card-body">
<h3 class="heading"> Project working days </h3>
<div class=" bottom d-flex justify-content-between">
<div class="progresss d-flex">
<div class="qty">
<?= date_diff() ?>
</div>
</div>
<div class="icon">
<i class="fa-solid fa-arrow-trend-up"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card progress_cards shadow-sm border-0">
<div class="card-body">
<h3 class="heading"> Progress </h3>
<div class=" bottom d-flex justify-content-between">
<div class="progresss d-flex">
<div class="qty">
<?= get_completed_progress() ?>
</div>%
</div>
<div class="icon">
<i class="fa-solid fa-arrow-trend-up"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card progress_cards shadow-sm border-0">
<div class="card-body">
<h3 class="heading">Total task</h3>
<div class=" bottom d-flex justify-content-between">
<div class="progresss d-flex">
<div class="qty">
<?= count_total_task() ?>
</div>
</div>
<div class="icon">
<i class="fa-solid fa-list-check"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card progress_cards shadow-sm border-0">
<div class="card-body">
<h3 class="heading">Completed task</h3>
<div class=" bottom d-flex justify-content-between">
<div class="progresss d-flex">
<div class="qty">
<?= count_completed_task() ?>
</div>
</div>
<div class="icon">
<i class="fa-solid fa-list-check"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card progress_cards shadow-sm border-0">
<div class="card-body">
<h3 class="heading">Remaining task</h3>
<div class=" bottom d-flex justify-content-between">
<div class="progresss d-flex">
<div class="qty">
<?= count_total_task() - count_completed_task() ?>
</div>
</div>
<div class="icon">
<i class="fa-solid fa-list-check"></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
`,
});
let tasks = Vue.component("task", {
data: function(){
return {
interval: null,
start_time: null,
working_hour: null,
min: 0,
}
},
created: function () {
this.start_time = moment().tz('Asia/Dhaka');
},
methods: {
start_task: function(event, row_no){
let that = this;
if(event.target.classList.contains('fa-pause')){
event.target.classList.remove('fa-pause');
event.target.classList.add('fa-play');
document.querySelector('.work_times.active').classList.remove('active')
that.save_end_time(row_no, that.min);
clearInterval(that.interval);
}
else {
event.target.classList.remove('fa-play');
event.target.classList.add('fa-pause');
if(document.querySelectorAll('.task_list_ul i.fa-pause').length > 1){
alert("close running task before starting new task");
event.target.classList.remove('fa-pause');
event.target.classList.add('fa-play');
document.querySelector('.task_list_ul i.fa-pause').scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
return 0;
}
that.save_start_time(row_no);
start_time = that.start_time;
that.interval = setInterval(function(){
that.render_work_time();
that.render_this_task_work_time(row_no);
if(that.min >= 60){
that.save_end_time(row_no, that.min);
that.min = 0;
}
that.min++;
},1000);
}
console.log(event, row_no);
},
save_end_time: function(row_no, sec){
google.script.run.set_track_work_time({
date: new Date().toDateString(),
start_time: "",
end_time: moment().format("HH:mm:ss"),
total_sec: sec * 1000,
row_no: row_no,
});
},
save_start_time: function(row_no){
google.script.run.set_track_work_time({
date: new Date().toDateString(),
start_time: moment().format("HH:mm:ss"),
end_time: "",
total_sec: 0,
row_no: row_no,
});
Toast.fire({
icon: 'success',
title: 'Timer Started'
})
},
render_work_time: function(){
let that = this;
that.working_hour = document.getElementById("working_hour");
var mili_sec = +that.working_hour.dataset.work_sec;
var times = that.ms_to_hours(mili_sec);
that.working_hour.innerHTML = `${times.hours}:${times.minutes}:${times.seconds}`;
that.working_hour.dataset.work_sec = mili_sec+1000;
},
render_this_task_work_time: function(row_no){
let that = this;
let this_task_working_hour = document.getElementById("ms_"+row_no);
!this_task_working_hour.classList.contains('active') && this_task_working_hour.classList.add('active');
var mili_sec = +this_task_working_hour.dataset.ms;
this_task_working_hour.innerHTML = new Date(mili_sec).toISOString().slice(11, 19) + ` hrs`;
this_task_working_hour.dataset.ms = mili_sec+1000;
},
ms_to_hours: function(value){
var now = moment();
var seconds = moment.duration(value).seconds();
var minutes = moment.duration(value).minutes();
var hours = Math.trunc(moment.duration(value).asHours());
return {
hours: hours.toString().padStart(2, '0'),
minutes: minutes.toString().padStart(2, '0'),
seconds: seconds.toString().padStart(2, '0'),
}
},
complete_task: function(event, row_no){
google.script.run.complete_task(row_no, event.target.checked==true?1:0);
if(event.target.checked==true){
Toast.fire({
icon: 'success',
title: 'task added to completed'
})
}else{
Toast.fire({
icon: 'warning',
title: 'task removed from completed'
})
}
},
save_work_start_time: function(event, row_no){
google.script.run.save_work_start_time(row_no, event.target.value||'');
Toast.fire({
icon: 'success',
title: 'work start time been saved'
})
},
save_work_end_time: function(event, row_no){
google.script.run.save_work_end_time(row_no, event.target.value||'');
Toast.fire({
icon: 'success',
title: 'work end time been saved'
})
},
save_item_delay: function(event, row_no){
google.script.run.save_item_delay(row_no, event.target.value||'');
Toast.fire({
icon: 'success',
title: 'item delay been saved'
})
},
save_item_delay_comment: function(event, row_no){
google.script.run.save_item_delay_comment(row_no, event.target.value||'');
Toast.fire({
icon: 'success',
title: 'item delay comment been saved'
})
},
},
template: `
<div>
<div class="cells headings">
<div class="cols titles">
Titles
</div>
<div class="cols start_date">
Start Date
</div>
<div class="cols end_date">
End Date
</div>
<div class="cols work_start_time">
Work Start Time
</div>
<div class="cols work_end_time">
Work End Time
</div>
<div class="cols work_times">
Work Time
</div>
<div class="cols delay">
Delay
</div>
<div class="cols delay_comment">
Delay Comment
</div>
<div class="cols completion_days">
Completion Days
</div>
<div class="cols assign_to">
Assign to
</div>
<div class="cols is_done">
Is Done
</div>
<div class="cols priority">
priority
</div>
</div>
<ul class="task_list_ul">
<? var data = getTasks();?>
<? for (var i = 0; i < data.length; i++) { ?>
<li>
<div class="task_heading">
<?= data[i].title ?>
</div>
</li>
<? if(data[i].children.length){ ?>
<li>
<ul>
<? for (var j = 0; j < data[i].children.length; j++) { ?>
<li>
<div class="task_heading">
<?= data[i].children[j].title ?>
</div>
</li>
<? if(data[i].children[j].children.length){ ?>
<li>
<ul>
<? for (var k = 0; k < data[i].children[j].children.length; k++) { ?>
<? item = data[i].children[j].children[k]; ?>
<li>
<div class="task_content">
<? if(item.is_done == 1){ ?>
<input @change="complete_task($event, <?= item.row_no ?>)" checked type="checkbox" class="form-check-input d-inline-block">
<?}else{ ?>
<input @change="complete_task($event, <?= item.row_no ?>)" type="checkbox" class="form-check-input d-inline-block">
<? } ?>
<i class="fa fa-play" @click="start_task($event, <?= item.row_no ?>)"></i>
<span style="flex:1;">
<?= item.title ?>
</span>
</div>
<div class="cells">
<div class="cols start_date">
<?= item.start_date_formated ?>
</div>
<div class="cols end_date">
<?= item.end_date_formated ?>
</div>
<div class="cols work_start_time">
<? if(item.work_start_time_formated != '') { ?>
<?= item.work_start_time_formated ?>
<? } else{ ?>
<input type="datetime-local" @change="save_work_start_time($event,<?= item.row_no ?>)">
<? } ?>
</div>
<div class="cols work_end_time">
<? if(item.work_end_time_formated != '') { ?>
<?= item.work_end_time_formated ?>
<? } else{ ?>
<input type="datetime-local" @change="save_work_end_time($event,<?= item.row_no ?>)">
<? } ?>
</div>
<div class="cols work_times" data-ms="<?= item.work_times_ms ?>" id="<?= 'ms_'+item.row_no ?>">
<?= item.work_times ?> hrs
</div>
<div class="cols delay">
<? if(item.delay != '') { ?>
<?= item.delay ?> hrs
<? } else{ ?>
<input type="number" @change="save_item_delay($event,<?= item.row_no ?>)"> hrs
<? } ?>
</div>
<div class="cols delay_comment">
<? if(item.delay_comment != '') { ?>
<?= item.delay_comment ?> hrs
<? } else{ ?>
<textarea type="number" @change="save_item_delay_comment($event,<?= item.row_no ?>)"></textarea>
<? } ?>
</div>
<div class="cols completion_days">
<?= item.completion_days ?> days
</div>
<div class="cols assign_to">
<?= item.assign_to ?>
</div>
<div class="cols is_done">
<?= item.is_done == 1 ? 'yes' : 'no' ?>
</div>
<div class="cols priority">
<select name="" value="<?= item.priority ?>" id="">
<option value="low">low</option>
<option value="medium">medium</option>
<option value="heigh">heigh</option>
</select>
</div>
</div>
</li>
<? } ?>
</ul>
</li>
<? } ?>
<? } ?>
</ul>
</li>
<? } ?>
<? } ?>
</ul>
</div>
`,
});
let task_json = Vue.component("task_json", {
data: function(){
return {
data: [],
}
},
created: function () {
},
template: `
<pre>
<? var data = getTasks();?>
<?= JSON.stringify(data, undefined, 3) ?>
</pre>
`
});
const routes = [
{ path: "/", component: dashboard },
{ path: "/tasks", component: tasks },
{ path: "/task_json", component: task_json },
];
const router = new VueRouter({
routes, // short for `routes: routes`
linkExactActiveClass: "active",
});
new Vue({
router,
el: "#app",
data: function () {
return {
};
},
created: function () {
this.$nextTick(function () {
this.render_work_time();
});
},
updated: function () {
this.$nextTick(function () {
});
},
methods: {
render_work_time: function(){
let that = this;
that.working_hour = document.getElementById("working_hour");
var mili_sec = +that.working_hour.dataset.work_sec;
var times = that.ms_to_hours(mili_sec);
that.working_hour.innerHTML = `${times.hours}:${times.minutes}:${times.seconds}`;
that.working_hour.dataset.work_sec = mili_sec+1000;
},
ms_to_hours: function(value){
var now = moment();
var seconds = moment.duration(value).seconds();
var minutes = moment.duration(value).minutes();
var hours = Math.trunc(moment.duration(value).asHours());
return {
hours: hours.toString().padStart(2, '0'),
minutes: minutes.toString().padStart(2, '0'),
seconds: seconds.toString().padStart(2, '0'),
}
},
},
});
setInterval(() => {
document.getElementById("today_date").innerHTML = new moment().format("ddd DD MMM, YYYY | hh:mm:ss a");
}, 1000);
</script>
</body>
</html>