dashboard: refactor interface

This commit is contained in:
nemunaire 2018-12-04 05:34:34 +01:00
parent b9f1822a65
commit 3056a19d09
3 changed files with 35 additions and 18 deletions

View file

@ -69,9 +69,11 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
.controller("DataController", function($scope, $http, $rootScope, $interval) {
var pathname = window.location.pathname;
if (pathname == "/")
pathname = "/public0.html"
pathname = "/public0.html";
pathname = pathname.replace(".html", ".json");
var refreshScene = function() {
$http.get(pathname.replace(".html", ".json")).then(function(response) {
$http.get(pathname).then(function(response) {
if ($scope.lastpublicetag != undefined && $scope.lastpublicetag == response.headers()["last-modified"])
return;
$scope.lastpublicetag = response.headers()["last-modified"];
@ -79,7 +81,24 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
$scope.scene = response.data;
});
}
var refreshData = function() {
refreshScene();
var refreshSceneInterval = $interval(refreshScene, 900);
var refreshSettings = function() {
$http.get("/settings.json").then(function(response) {
$rootScope.recvTime(response);
response.data.start = new Date(response.data.start);
response.data.end = new Date(response.data.end);
response.data.generation = new Date(response.data.generation);
response.data.awards = new Date("2019-01-23T15:00:00Z");
$rootScope.settings = response.data;
});
}
refreshSettings();
var refreshSettingsInterval = $interval(refreshSettings, 4200);
$rootScope.refresh = function() {
$http.get("/my.json").then(function(response) {
if ($scope.lastmyetag != undefined && $scope.lastmyetag == response.headers()["last-modified"])
return;
@ -138,10 +157,8 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"])
$scope.pagesrank = Array(Math.ceil($scope.rank.length / 7)).fill(0).map(function(v, i){ return i; });
});
}
refreshData();
refreshScene();
$interval(refreshData, 4200);
$interval(refreshScene, 900);
$rootScope.refresh();
$interval($rootScope.refresh, 4200);
})
.controller("TeamController", function($scope, $http, $interval) {
$scope.mystats = null;