-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
95 lines (82 loc) · 3.67 KB
/
Copy pathapp.js
File metadata and controls
95 lines (82 loc) · 3.67 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
Vue.createApp({
data() {
return {
initialDate : new Date(2022,01,17),
selectedDate : new Date(),
teams : [
{
teamName: "Sherlock",
teamIcon: "bi bi-lightning-charge",
numOnCall: 2,
onCallPerson: [],
oooPerson: [],
people: ["Tarun", "Charles", "Harry", "James", "AK", "Amol"]
},
{
teamName: "Strange",
teamIcon: "bi bi-phone-flip",
numOnCall: 1,
onCallPerson: [],
oooPerson: [],
people: ["Gary", "Mohan", "Anime"]
},
{
teamName: "Storage",
teamIcon: "bi bi-hdd-stack",
numOnCall: 1,
onCallPerson: [],
oooPerson: [],
people: ["Sam", "Moore", "Nben"]
},
{
teamName: "Sytems",
teamIcon: "bi bi-pc-display",
numOnCall: 1,
onCallPerson: [],
oooPerson: [],
people: ["Washington", "Varun"]
}
]
} ;
},
methods: {
updateOnCallPerson() {
if( this.selectedDate )
{
let tempTeams = this.teams
currDate = new Date( moment(this.selectedDate).format("yyyy-MM-DD"))
var dayIndex = moment(currDate).day()
for( team in tempTeams)
{
var peopleLen = tempTeams[ team ].people.length
var firstOnCall = moment(currDate).week() % peopleLen
// If day is Sun, use previous week number
if( dayIndex == 0 )
firstOnCall = firstOnCall - 1
if( firstOnCall < 0 )
firstOnCall = peopleLen - firstOnCall-1
var secondOnCall = (firstOnCall + ( peopleLen / 2 )) % peopleLen
if( tempTeams[ team ].numOnCall == 2 )
tempTeams[ team ].onCallPerson= [ tempTeams[ team ].people[ firstOnCall ], tempTeams[ team ].people[ secondOnCall ] ]
else
tempTeams[ team ].onCallPerson= [ tempTeams[ team ].people[ firstOnCall ] ]
// OOO set for Sherlock
if( team == 0 )
{
var leaveIndexFirst = (firstOnCall +1) % peopleLen
var leaveIndexSecond = 0
if( leaveIndexFirst + (peopleLen/2) < peopleLen )
leaveIndexSecond = parseInt(leaveIndexFirst + peopleLen/2 )
else
leaveIndexSecond = parseInt(leaveIndexFirst - peopleLen/2)
tempTeams[ team ].oooPerson = [ tempTeams[ team ].people[ leaveIndexFirst ], tempTeams[ team ].people[ leaveIndexSecond ] ]
}
}
this.teams = tempTeams
}
}
},
mounted() {
this.updateOnCallPerson()
},
}).mount("#app") ;