Răsfoiți Sursa

Listen for ConfigSaved event in the UI (fixes #244)

Audrius Butkevicius 11 ani în urmă
părinte
comite
521b49166e
2 a modificat fișierele cu 36 adăugiri și 25 ștergeri
  1. 0 0
      auto/gui.files.go
  2. 36 25
      gui/app.js

Fișier diff suprimat deoarece este prea mare
+ 0 - 0
auto/gui.files.go


+ 36 - 25
gui/app.js

@@ -237,6 +237,14 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
         }
     })
 
+    $scope.$on('ConfigSaved', function (event, arg) {
+        updateLocalConfig(arg.data);
+
+        $http.get(urlbase + '/config/sync').success(function (data) {
+            $scope.configInSync = data.configInSync;
+        });
+    });
+
     var debouncedFuncs = {};
 
     function refreshRepo(repo) {
@@ -252,6 +260,33 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
         debouncedFuncs[key]();
     }
 
+    function updateLocalConfig(config) {
+        var hasConfig = !isEmptyObject($scope.config);
+
+        $scope.config = config;
+        $scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(', ');
+
+        $scope.nodes = $scope.config.Nodes;
+        $scope.nodes.forEach(function (nodeCfg) {
+            $scope.completion[nodeCfg.NodeID] = {
+                _total: 100,
+            };
+        });
+        $scope.nodes.sort(nodeCompare);
+
+        $scope.repos = repoMap($scope.config.Repositories);
+        Object.keys($scope.repos).forEach(function (repo) {
+            refreshRepo(repo);
+            $scope.repos[repo].Nodes.forEach(function (nodeCfg) {
+                refreshCompletion(nodeCfg.NodeID, repo);
+            });
+        });
+
+        if (!hasConfig) {
+            $scope.$emit('ConfigLoaded');
+        }
+    }
+
     function refreshSystem() {
         $http.get(urlbase + '/system').success(function (data) {
             $scope.myID = data.myID;
@@ -324,31 +359,7 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca
 
     function refreshConfig() {
         $http.get(urlbase + '/config').success(function (data) {
-            var hasConfig = !isEmptyObject($scope.config);
-
-            $scope.config = data;
-            $scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(', ');
-
-            $scope.nodes = $scope.config.Nodes;
-            $scope.nodes.forEach(function (nodeCfg) {
-                $scope.completion[nodeCfg.NodeID] = {
-                    _total: 100,
-                };
-            });
-            $scope.nodes.sort(nodeCompare);
-
-            $scope.repos = repoMap($scope.config.Repositories);
-            Object.keys($scope.repos).forEach(function (repo) {
-                refreshRepo(repo);
-                $scope.repos[repo].Nodes.forEach(function (nodeCfg) {
-                    refreshCompletion(nodeCfg.NodeID, repo);
-                });
-            });
-
-            if (!hasConfig) {
-                $scope.$emit('ConfigLoaded');
-            }
-
+            updateLocalConfig(data);
             console.log("refreshConfig", data);
         });
 

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff