Reload configuration after lost connection or restart.

This commit is contained in:
Jakob Borg 2014-05-11 14:43:38 -03:00
parent 1a1f118f1a
commit a91eb701bf
2 changed files with 25 additions and 20 deletions

File diff suppressed because one or more lines are too long

View File

@ -44,10 +44,12 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
function getSucceeded() { function getSucceeded() {
if (!getOK) { if (!getOK) {
$scope.init();
$('#networkError').modal('hide'); $('#networkError').modal('hide');
getOK = true; getOK = true;
} }
if (restarting) { if (restarting) {
$scope.init();
$('#restarting').modal('hide'); $('#restarting').modal('hide');
restarting = false; restarting = false;
} }
@ -421,32 +423,35 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
$http.post(urlbase + '/config', JSON.stringify($scope.config), {headers: {'Content-Type': 'application/json'}}); $http.post(urlbase + '/config', JSON.stringify($scope.config), {headers: {'Content-Type': 'application/json'}});
}; };
$http.get(urlbase + '/version').success(function (data) { $scope.init = function() {
$scope.version = data; $http.get(urlbase + '/version').success(function (data) {
}); $scope.version = data;
});
$http.get(urlbase + '/system').success(function (data) { $http.get(urlbase + '/system').success(function (data) {
$scope.system = data; $scope.system = data;
$scope.myID = data.myID; $scope.myID = data.myID;
}); });
$http.get(urlbase + '/config').success(function (data) { $http.get(urlbase + '/config').success(function (data) {
$scope.config = data; $scope.config = data;
$scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(', '); $scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(', ');
var nodes = $scope.config.Nodes; var nodes = $scope.config.Nodes;
nodes.sort(nodeCompare); nodes.sort(nodeCompare);
$scope.nodes = nodes; $scope.nodes = nodes;
$scope.repos = $scope.config.Repositories; $scope.repos = $scope.config.Repositories;
$scope.refresh(); $scope.refresh();
}); });
$http.get(urlbase + '/config/sync').success(function (data) { $http.get(urlbase + '/config/sync').success(function (data) {
$scope.configInSync = data.configInSync; $scope.configInSync = data.configInSync;
}); });
};
$scope.init();
setInterval($scope.refresh, 10000); setInterval($scope.refresh, 10000);
}); });