admin: Fix activate timer
This commit is contained in:
parent
84b9e352ee
commit
0ca7aa568d
@ -464,7 +464,9 @@ angular.module("FICApp")
|
|||||||
response.data.start = new Date(response.data.start);
|
response.data.start = new Date(response.data.start);
|
||||||
response.data.end = new Date(response.data.end);
|
response.data.end = new Date(response.data.end);
|
||||||
response.data.generation = new Date(response.data.generation);
|
response.data.generation = new Date(response.data.generation);
|
||||||
$rootScope.settings = response.data;
|
if ($rootScope.settings && $rootScope.settings.activateTime instanceof Date)
|
||||||
|
response.data.activateTime = $rootScope.settings.activateTime;
|
||||||
|
$rootScope.settings = response.data;
|
||||||
$rootScope.recvTime(response);
|
$rootScope.recvTime(response);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -564,7 +566,8 @@ angular.module("FICApp")
|
|||||||
$scope.nextsettings = NextSettings.query();
|
$scope.nextsettings = NextSettings.query();
|
||||||
$scope.erase = false;
|
$scope.erase = false;
|
||||||
$scope.editNextSettings = function(ns) {
|
$scope.editNextSettings = function(ns) {
|
||||||
$scope.activateTime = ns.date;
|
$scope.activateTime = new Date(ns.date);
|
||||||
|
$rootScope.settings.activateTime = $scope.activateTime;
|
||||||
$scope.erase = true;
|
$scope.erase = true;
|
||||||
Object.keys(ns.values).forEach(function(k) {
|
Object.keys(ns.values).forEach(function(k) {
|
||||||
$scope.config[k] = ns.values[k];
|
$scope.config[k] = ns.values[k];
|
||||||
@ -594,7 +597,7 @@ angular.module("FICApp")
|
|||||||
})
|
})
|
||||||
$scope.challenge = SettingsChallenge.get();
|
$scope.challenge = SettingsChallenge.get();
|
||||||
$scope.duration = 360;
|
$scope.duration = 360;
|
||||||
$scope.activateTime = "0001-01-01T00:00:00Z";
|
$scope.activateTime = "";
|
||||||
$scope.challenge.$promise.then(function(c) {
|
$scope.challenge.$promise.then(function(c) {
|
||||||
if (c.duration)
|
if (c.duration)
|
||||||
$scope.duration = c.duration;
|
$scope.duration = c.duration;
|
||||||
@ -656,8 +659,9 @@ angular.module("FICApp")
|
|||||||
this.config.unlockedChallengeDepth = (this.config.enableExerciceDepend?this.config.unlockedChallengeDepth:-1)
|
this.config.unlockedChallengeDepth = (this.config.enableExerciceDepend?this.config.unlockedChallengeDepth:-1)
|
||||||
this.config.disablesubmitbutton = (this.config.disabledsubmitbutton?this.config.disablesubmitbutton:'')
|
this.config.disablesubmitbutton = (this.config.disabledsubmitbutton?this.config.disablesubmitbutton:'')
|
||||||
var updateQuery = {};
|
var updateQuery = {};
|
||||||
if (this.activateTime && this.activateTime != '0001-01-01T00:00:00Z') {
|
if (this.activateTime && this.activateTime != '') {
|
||||||
updateQuery['t'] = this.activateTime;
|
updateQuery['t'] = this.activateTime;
|
||||||
|
this.activateTime = null;
|
||||||
}
|
}
|
||||||
if (this.erase) {
|
if (this.erase) {
|
||||||
updateQuery['erase'] = true;
|
updateQuery['erase'] = true;
|
||||||
@ -676,6 +680,7 @@ angular.module("FICApp")
|
|||||||
$rootScope.settings.end = null;
|
$rootScope.settings.end = null;
|
||||||
}
|
}
|
||||||
$rootScope.settings.generation = new Date(nGen);
|
$rootScope.settings.generation = new Date(nGen);
|
||||||
|
$scope.updateActivateTime();
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
$scope.addToast('danger', 'An error occurs when saving settings:', response.data.errmsg);
|
$scope.addToast('danger', 'An error occurs when saving settings:', response.data.errmsg);
|
||||||
});
|
});
|
||||||
@ -694,10 +699,15 @@ angular.module("FICApp")
|
|||||||
$rootScope.settings.activateTime = this.activateTime;
|
$rootScope.settings.activateTime = this.activateTime;
|
||||||
}
|
}
|
||||||
$scope.updActivateTime = function(modulo) {
|
$scope.updActivateTime = function(modulo) {
|
||||||
|
if (modulo) {
|
||||||
var ts = Math.floor((new Date(this.config.end) - $rootScope.getSrvTime().getTime() - (60000 * modulo / 2)) / (60000 * modulo)) * (60000 * modulo);
|
var ts = Math.floor((new Date(this.config.end) - $rootScope.getSrvTime().getTime() - (60000 * modulo / 2)) / (60000 * modulo)) * (60000 * modulo);
|
||||||
var d = new Date(this.config.end) - ts;
|
var d = new Date(this.config.end) - ts;
|
||||||
this.activateTime = new Date(d);
|
this.activateTime = new Date(d);
|
||||||
this.updateActivateTime();
|
this.updateActivateTime();
|
||||||
|
} else {
|
||||||
|
this.activateTime = null;
|
||||||
|
this.updateActivateTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$scope.reset = function(type) {
|
$scope.reset = function(type) {
|
||||||
var txts = {
|
var txts = {
|
||||||
|
@ -139,7 +139,9 @@ angular.module("FICApp")
|
|||||||
res += Math.floor(input / 3600) + ":";
|
res += Math.floor(input / 3600) + ":";
|
||||||
input = input % 3600;
|
input = input % 3600;
|
||||||
}
|
}
|
||||||
if (input >= 60) {
|
if (res || input >= 60) {
|
||||||
|
if (res && Math.floor(input / 60) <= 9)
|
||||||
|
res += "0";
|
||||||
res += Math.floor(input / 60) + "'";
|
res += Math.floor(input / 60) + "'";
|
||||||
input = input % 60;
|
input = input % 60;
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
<a class="dropdown-item" ng-click="updActivateTime(30)">modulo 30 minutes</a>
|
<a class="dropdown-item" ng-click="updActivateTime(30)">modulo 30 minutes</a>
|
||||||
<a class="dropdown-item" ng-click="updActivateTime(60)">modulo 60 minutes</a>
|
<a class="dropdown-item" ng-click="updActivateTime(60)">modulo 60 minutes</a>
|
||||||
<a class="dropdown-item" ng-click="updActivateTime(90)">modulo 90 minutes</a>
|
<a class="dropdown-item" ng-click="updActivateTime(90)">modulo 90 minutes</a>
|
||||||
<a class="dropdown-item" ng-click="activateTime = '0001-01-01T00:00:00Z'" ng-show="activateTimeCountDown">annuler la propagation</a>
|
<a class="dropdown-item" ng-click="updActivateTime(null)" ng-show="activateTimeCountDown">annuler la propagation</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="datetime-local" class="form-control form-control-sm" id="activateTime" ng-model="activateTime" ng-change="updateActivateTime()">
|
<input type="datetime-local" class="form-control form-control-sm" id="activateTime" ng-model="activateTime" ng-change="updateActivateTime()">
|
||||||
</div>
|
</div>
|
||||||
<small ng-if="activateTimeCountDown">
|
<small ng-if="activateTimeCountDown">
|
||||||
Propagation dans : {{ activateTimeCountDown | timer }}
|
Propagation dans : {{ activateTimeCountDown | timer }}.
|
||||||
Il restera : {{ timeRemaining - activateTimeCountDown | timer }}
|
Il restera : {{ timeRemaining - activateTimeCountDown | timer }}
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user