Ajout du temps de travail et du capital si validé
This commit is contained in:
parent
e0f098d33d
commit
a9fcac9551
|
@ -3,3 +3,4 @@
|
||||||
- Copier le dossier `ninegate-gnome-extension@cadoles.com` dans `~/.local/share/gnome-shell/extensions`
|
- Copier le dossier `ninegate-gnome-extension@cadoles.com` dans `~/.local/share/gnome-shell/extensions`
|
||||||
- Copier `config.json.dist` vers `config.json` et y entrer votre clé API Ninebadge
|
- Copier `config.json.dist` vers `config.json` et y entrer votre clé API Ninebadge
|
||||||
- Recharger votre session Gnome (ALT + F2, entrer "r" puis appuyer sur Entrée)
|
- Recharger votre session Gnome (ALT + F2, entrer "r" puis appuyer sur Entrée)
|
||||||
|
- Activer l'extension
|
|
@ -37,8 +37,12 @@ class MyPopup extends PanelMenu.Button {
|
||||||
|
|
||||||
this.add_child(icon);
|
this.add_child(icon);
|
||||||
|
|
||||||
let today = new Date()
|
let workedItem = new PopupMenu.PopupMenuItem('');
|
||||||
let time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
|
let workedLabel = new St.Label({text:'TEMPS DE TRAVAIL : 0:00'});
|
||||||
|
workedItem.add(workedLabel);
|
||||||
|
|
||||||
|
this.menu.addMenuItem(workedItem);
|
||||||
|
|
||||||
|
|
||||||
let timeItem = new PopupMenu.PopupMenuItem('');
|
let timeItem = new PopupMenu.PopupMenuItem('');
|
||||||
let timeLabel = new St.Label({text:'CAPITAL TOTAL : +0:00'});
|
let timeLabel = new St.Label({text:'CAPITAL TOTAL : +0:00'});
|
||||||
|
@ -50,7 +54,7 @@ class MyPopup extends PanelMenu.Button {
|
||||||
let ifValidateLabel = new St.Label({text:'CAPITAL SI VALIDÉ : +0:00'});
|
let ifValidateLabel = new St.Label({text:'CAPITAL SI VALIDÉ : +0:00'});
|
||||||
ifValidateItem.add(ifValidateLabel);
|
ifValidateItem.add(ifValidateLabel);
|
||||||
|
|
||||||
//this.menu.addMenuItem(ifValidateItem);
|
this.menu.addMenuItem(ifValidateItem);
|
||||||
|
|
||||||
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
||||||
|
|
||||||
|
@ -77,7 +81,38 @@ class MyPopup extends PanelMenu.Button {
|
||||||
started = false
|
started = false
|
||||||
label.set_text('DÉBUT POINTAGE');
|
label.set_text('DÉBUT POINTAGE');
|
||||||
}
|
}
|
||||||
ifValidateLabel.set_text('CAPITAL SI VALIDÉ : +0:00')
|
let today = new Date();
|
||||||
|
|
||||||
|
let timers = result.timers;
|
||||||
|
let lastTimer = new Date(timers[timers.length - 1].start);
|
||||||
|
|
||||||
|
let currentHours = parseInt(Math.abs(today - lastTimer) / (1000 * 60 * 60) % 24);
|
||||||
|
let currentMinutes = parseInt(Math.abs(today.getTime() - lastTimer.getTime()) / (1000 * 60) % 60);
|
||||||
|
|
||||||
|
let timeday = status.timeday;
|
||||||
|
let timedayToMinutes = timeday.split(':');
|
||||||
|
timedayToMinutes = parseInt(timedayToMinutes[0]) * 60 + parseInt(timedayToMinutes[1]);
|
||||||
|
|
||||||
|
let workedToday = timedayToMinutes + currentHours * 60 + currentMinutes;
|
||||||
|
let workedHours = Math.floor(workedToday / 60);
|
||||||
|
let workedMinutes = workedToday % 60;
|
||||||
|
|
||||||
|
let capitalToMinutes = result.capitaltime.replace('+', '').split(':');
|
||||||
|
capitalToMinutes = parseInt(capitalToMinutes[0]) * 60 + parseInt(capitalToMinutes[1]);
|
||||||
|
|
||||||
|
let workedTodayPlusCapital = workedToday + capitalToMinutes
|
||||||
|
let diff = 7*60 - workedTodayPlusCapital
|
||||||
|
let diffHours = Math.floor(diff / 60);
|
||||||
|
let diffMinutes = diff % 60;
|
||||||
|
|
||||||
|
workedLabel.set_text('TEMPS DE TRAVAIL : '+ workedHours + ':' + String(workedMinutes).padStart(2, 0));
|
||||||
|
|
||||||
|
if(diff > 0) {
|
||||||
|
ifValidateLabel.set_text('CAPITAL SI VALIDÉ : -' + diffHours + ':' + String(diffMinutes).padStart(2, 0));
|
||||||
|
} else {
|
||||||
|
ifValidateLabel.set_text('CAPITAL SI VALIDÉ : +' + diffHours + ':' + String(diffMinutes).padStart(2, 0));
|
||||||
|
}
|
||||||
|
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
log(error);
|
log(error);
|
||||||
}
|
}
|
||||||
|
@ -136,6 +171,10 @@ function get_config(property) {
|
||||||
return json_result[property];
|
return json_result[property];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addMinutes(date, minutes) {
|
||||||
|
return new Date(date.getTime() + minutes*60000);
|
||||||
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue