Add settings field to fetch timetable thresholds
This commit is contained in:
@@ -75,7 +75,12 @@ app.controller('timetableCtrl',
|
||||
$scope.arr=[];
|
||||
parse(data);
|
||||
});
|
||||
};
|
||||
$http.get('/infoscreen/hsl_data/settings')
|
||||
.then(function(data, status, headers, config) {
|
||||
$scope.departureThreshold = data.data['departure_threshold'];
|
||||
$scope.hurryThreshold = data.data['hurry_threshold'];
|
||||
});
|
||||
}
|
||||
$scope.$on('$destroy', function() {
|
||||
$interval.cancel(inter1);
|
||||
$interval.cancel(inter2);
|
||||
@@ -138,8 +143,8 @@ app.controller('timetableCtrl',
|
||||
delOld();
|
||||
}
|
||||
function delOld(){
|
||||
var toSoon=5;
|
||||
var hurry=10;
|
||||
tooSoon = typeof($scope.departureThreshold) != 'undefined' ? $scope.departureThreshold: 0;
|
||||
hurry = typeof($scope.hurryThreshold) != 'undefined' ? $scope.hurryThreshold : 0;
|
||||
f= new Date();
|
||||
for(var a=$scope.arr.length-1; a>=0; a--){
|
||||
var time=$scope.arr[a]['time'].split(":");
|
||||
@@ -149,13 +154,14 @@ app.controller('timetableCtrl',
|
||||
d.setHours(time[0]);
|
||||
d.setMinutes(time[1]);
|
||||
var diff=(d.getTime()-f.getTime());
|
||||
if(diff < toSoon*60000)
|
||||
if(diff < tooSoon*60000)
|
||||
$scope.arr.splice(a,1);
|
||||
else if(diff < hurry*60000)
|
||||
$scope.arr[a]['hurry']=true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
load();
|
||||
var inter1=$interval(delOld,2000);
|
||||
var inter2=$interval(load,10000);
|
||||
|
||||
@@ -10,6 +10,7 @@ from infoscreen.models import ABBInfoItem, ExternalImageInfoItem, ImageInfoItem,
|
||||
from infoscreen.models import ImageUploadForm
|
||||
from infoscreen.models import HSLDataModel
|
||||
from infoscreen.hsl_fetcher import HSLFetcher
|
||||
import sikweb.settings as settings
|
||||
import json
|
||||
import logging
|
||||
import threading
|
||||
@@ -183,6 +184,12 @@ def delete_rotation(request, *args, **kwargs):
|
||||
|
||||
return resp
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
def hsl_timetable_settings(request, *args, **kwargs):
|
||||
d = {"departure_threshold": settings.HSL_DEPARTURE_THRESHOLD,
|
||||
"hurry_threshold": settings.HSL_HURRY_THRESHOLD}
|
||||
resp = json.dumps(d)
|
||||
return HttpResponse(resp, status=200)
|
||||
|
||||
@require_http_methods(["GET"])
|
||||
def CurrentHSLView(request, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user