frontend: new parameters to setup kind of notifications allowed
This commit is contained in:
parent
24989c4cfa
commit
ef35879dde
@ -40,7 +40,7 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
|
||||
refreshEvents()
|
||||
$interval(refreshEvents, 2100);
|
||||
})
|
||||
.controller("TimerController", function($scope, $rootScope, $interval) {
|
||||
.controller("TimerController", function($scope, $rootScope, $interval, $timeout) {
|
||||
$scope.duration = 0;
|
||||
|
||||
$scope.init = function(end) {
|
||||
@ -53,9 +53,12 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
|
||||
})
|
||||
}
|
||||
$scope.initT = function(end) {
|
||||
var time = angular.fromJson(sessionStorage.userService);
|
||||
var srv_cur = new Date(Date.now() + (time.cu - time.he));
|
||||
$scope.duration = Math.floor((end - srv_cur)/1000);
|
||||
var time = angular.fromJson(sessionStorage.time);
|
||||
if (time) {
|
||||
var srv_cur = new Date(Date.now() + (time.cu - time.he));
|
||||
$scope.duration = Math.floor((end - srv_cur)/1000);
|
||||
} else
|
||||
$timeout(function() { $scope.initT(end); }, 1000);
|
||||
}
|
||||
|
||||
var stop = $interval(function() {
|
||||
|
@ -77,12 +77,17 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
$rootScope.current_tag = undefined;
|
||||
$rootScope.notify_field = 0;
|
||||
|
||||
Notification.requestPermission().then(function(result) {
|
||||
if (result == "granted")
|
||||
$rootScope.notify_field = 7;
|
||||
else
|
||||
$rootScope.notify_field = 0;
|
||||
});
|
||||
if ('Notification' in window)
|
||||
Notification.requestPermission(function(result) {
|
||||
if (result == "granted") {
|
||||
if (localStorage && localStorage.notification)
|
||||
$rootScope.notify_field = localStorage.notification;
|
||||
else
|
||||
$rootScope.notify_field = 63;
|
||||
}
|
||||
else
|
||||
$rootScope.notify_field = 0;
|
||||
});
|
||||
})
|
||||
.component('flagKey', {
|
||||
bindings: {
|
||||
@ -259,7 +264,30 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
else if (event.time > maxTimeSeen)
|
||||
maxTimeSeen = event.time;
|
||||
|
||||
if ($rootScope.notify_field != 0) {
|
||||
// Determine the kind of event
|
||||
var kind = 1;
|
||||
|
||||
if (event.txt.match(/<\/strong> qui vient de nous rejoindre/)) {
|
||||
kind = 64;
|
||||
} else {
|
||||
var res = event.txt.match(/(\w+) le <strong>\d+<sup>e<\/sup><\/strong> défi [^&]+/)
|
||||
if (res) {
|
||||
if (res[1] == "résolu")
|
||||
kind = 8;
|
||||
else if (res[1] == "pour")
|
||||
kind = 16;
|
||||
else if (res[1] == "tente")
|
||||
kind = 32;
|
||||
}
|
||||
}
|
||||
if (kind != 1) {
|
||||
if ($scope.my && $scope.my.name && event.txt.indexOf($scope.my.name) >= 0)
|
||||
kind |= 2;
|
||||
else
|
||||
kind |= 4;
|
||||
}
|
||||
|
||||
if ((kind & $rootScope.notify_field) == kind) {
|
||||
var notification = new Notification("Challenge forensic", {body: event.txt.replace(/&#(\d+);/g, function(match, dec) {return String.fromCharCode(dec);}).replace(/(<([^>]+)>)/ig,""), badge: "/img/icon-" + event.kind + ".ico", icon: "/img/icon-" + event.kind + ".ico"});
|
||||
notification.onclick = function(ev) {
|
||||
$location.url("/edit");
|
||||
@ -542,7 +570,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
});
|
||||
}
|
||||
})
|
||||
.controller("MyTeamController", function($scope, $http, $rootScope, $timeout) {
|
||||
.controller("MyTeamController", function($scope, $http, $rootScope, $timeout, $location) {
|
||||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.current_tag = undefined;
|
||||
@ -555,6 +583,32 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
$rootScope.message = "";
|
||||
$rootScope.sberr = "";
|
||||
|
||||
$scope.notify = {
|
||||
info: ($rootScope.notify_field & 1) != 1,
|
||||
team: ($rootScope.notify_field & 2) != 2,
|
||||
others: ($rootScope.notify_field & 4) != 4,
|
||||
solve: ($rootScope.notify_field & 8) != 8,
|
||||
hint: ($rootScope.notify_field & 16) != 16,
|
||||
tries: ($rootScope.notify_field & 32) != 32,
|
||||
rename: ($rootScope.notify_field & 64) != 64,
|
||||
}
|
||||
|
||||
$scope.alternotify = function() {
|
||||
$rootScope.notify_field =
|
||||
($scope.notify.info?0:1) |
|
||||
($scope.notify.team?0:2) |
|
||||
($scope.notify.others?0:4) |
|
||||
($scope.notify.solve?0:8) |
|
||||
($scope.notify.hint?0:16) |
|
||||
($scope.notify.tries?0:32) |
|
||||
($scope.notify.rename?0:64);
|
||||
if ($rootScope.notify_field != 0)
|
||||
localStorage.notification = $rootScope.notify_field;
|
||||
else
|
||||
delete localStorage.notification;
|
||||
$location.url("/");
|
||||
}
|
||||
|
||||
var cbt;
|
||||
|
||||
$scope.tsubmit = function() {
|
||||
|
@ -133,8 +133,8 @@ angular.module("FICApp")
|
||||
angular.module("FICApp")
|
||||
.controller("CountdownController", function($scope, $rootScope, $interval) {
|
||||
var time;
|
||||
if (sessionStorage.userService)
|
||||
time = angular.fromJson(sessionStorage.userService);
|
||||
if (sessionStorage.time)
|
||||
time = angular.fromJson(sessionStorage.time);
|
||||
|
||||
$scope.time = {};
|
||||
|
||||
@ -149,7 +149,7 @@ angular.module("FICApp")
|
||||
"cu": Math.floor(response.headers("x-fic-time") * 1000),
|
||||
"he": (new Date()).getTime(),
|
||||
};
|
||||
sessionStorage.userService = angular.toJson(time);
|
||||
sessionStorage.time = angular.toJson(time);
|
||||
return time;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
<div class="row mb-4">
|
||||
<div class="col-md">
|
||||
|
||||
<div class="card niceborder">
|
||||
<div class="card-header">Votre équipe est composée de :</div>
|
||||
<div class="card-body" ng-if="!my.members.length">
|
||||
@ -32,3 +35,69 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-5" ng-if="notify_field != 0">
|
||||
|
||||
<div class="card border-success niceborder">
|
||||
<div class="card-header bg-success text-light">Gestion des notifications</div>
|
||||
<form class="card-body" ng-submit="alternotify()">
|
||||
<p>
|
||||
Ces paramètres ne seront valable que pour votre navigateur.
|
||||
</p>
|
||||
|
||||
<div class="form-check">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" type="checkbox" disabled ng-model="notify.info">
|
||||
<span class="custom-control-label">Ne pas recevoir les notifications de l'équipe serveur.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" type="checkbox" ng-model="notify.team">
|
||||
<span class="custom-control-label">Ne pas recevoir les notifications de mon équipe.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" type="checkbox" ng-model="notify.others">
|
||||
<span class="custom-control-label">Ne pas recevoir les notifications des autres équipes.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" type="checkbox" ng-model="notify.solve">
|
||||
<span class="custom-control-label">Ne pas recevoir les notifications de résolution.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" type="checkbox" ng-model="notify.hint">
|
||||
<span class="custom-control-label">Ne pas recevoir les notifications de découverte d'indice.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" type="checkbox" ng-model="notify.tries">
|
||||
<span class="custom-control-label">Ne pas recevoir les notifications de tentatives.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<label class="custom-control custom-checkbox">
|
||||
<input class="custom-control-input" type="checkbox" ng-model="notify.rename">
|
||||
<span class="custom-control-label">Ne pas recevoir les notifications de nouvelle équipe.</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success float-right">Enregistrer</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user