From a91eb701bf2d225eb85fc1c52ae5e76be06f1a5e Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 11 May 2014 14:43:38 -0300 Subject: [PATCH] Reload configuration after lost connection or restart. --- auto/gui.files.go | 2 +- gui/app.js | 43 ++++++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/auto/gui.files.go b/auto/gui.files.go index bc1cdc6f6..430432dd0 100644 --- a/auto/gui.files.go +++ b/auto/gui.files.go @@ -18,7 +18,7 @@ func init() { bs, _ = ioutil.ReadAll(gr) Assets["angular.min.js"] = bs - bs, _ = hex.DecodeString("1f8b080000096e8800ffd41bdb72db36f63d5f81aa69492532e574767676a2389dd64d3bdeb44d26aefbe2d1034542126b0ae082506c8dab7fdf830b49800029da8e3759cdb4b1808373c7b900d0f4d95f659e118e168c5e9798bd449c6df1042594f08c6c71f5bdc8b7a5f84f7d47cfa64fa6cf56395dc4397afa122de3bc04a098acb679ccf47701f424d8c21f256759c283d993271f6386ca1d49f83a232b7452ad883634dde6380ceab960822ee7e3995cb065f9220634272860b894786ab84830ca689e631606e7d5e829673960586ee17b46090a9f96092d80c3a76bce8b31ba7d82e02370170c7ffc29e602f9f1ac1e5d61feee2d0c09599b51413c665c712e45044ec4a4c22e582158122c01e0763f6b4d2eb3953bbed99dfd24240bac5142532c905cce3d48ce8810d4624fcf63c628f3ac2b31266fc49c4b09348f73972d860b5a2192e3d3293a073392558916784919460b4af312e5945ec108e798d9143997c080428edf66e94b14fc9a951c134004d6010913f0156935f49e514e139a2305817e48535077894b00e4bb02fc30e0f886c3376d05e588fb8981fcb7f8e61c93f4eda2280df4efb67c4585cd3e0833ff9a6d328ec2b73f16e5b8414db69b0566bdc83f00ba989c1190f3639c9f1b04d40caaa6507867ccda71fcc8f5e4fdf1bf8f590cfb23ff80ffb305205337a03104fa819524952a6a4086e30724a76bd8c8b8a57881fce72cc748cd2afd0fd6bc41e01719677e20e40d8917394e0d1a6a0ac11c85bd8e1bbcc2397bb9fe95261d38e5cc7d509e8bf11f551c35fd5b0ca366dc4467adbf784fdebbeca8112426fd8be776145a6db373ffe6d37bca54dfc5d94336dc852da8c0f6c396af31a48e249681f7c212f920c2f771595e5396f62335a034e2a219f121af3454e70388efe7db24c138c56958a503f1c99628fc4a467f73546a370cbe269803952b194983b1089d711e06eb2cc5c1786641bb09447cf6169d269df86835b3fd947c49c9a6b77785ff39867de94adecd11c37ccb4897247753d8ed224eae52460b301cd003b382d9aef06e416396eada61dfa1cf41028ae4794a3745cc70184fd0a22da6701aba4471f47bbcc1e8ab13c8895b92e2654660e3a16fbf451a60e10568cb29306a54aff492b105d0e80f1dbd681b4f0eebe5aff5f22e3503184806e582a423fff4dbc9a2d3e068a82934af6b3433538f7505b0047f580ba5d76594494e9652111826aceab3e72898963b88261bb07529f6575986cde234e6719b5f7b23dacaa92a098911d810eb0db1c6aada09fddc69e495a39beb9abfcd5a27829ae64d9cac0d7c62dcf16aafd4b288fa5ec09f043080490203171fce84175202a14be28ac05e431563b027915f6a047347116da12c01bddc1a75ea604389fa97d06ba02eaa65a84fafc3f1c482e0294c8602e6a8aeaac7688a5e1c1f1fdb9059aae371f5318a7058eff5828c4071d114e9ad59bae5f5b4350f46456196a28ca02e2dcb902f26a3755cbebb2650891698f11d2c1bfbe0c5a7ea8e66ceecde19e16cd7814510bdccd2792ddc6f315f479bf8263c9ea07fa167ca1212e28cfcb8e3b8fc8372284d8e3c0d87032554cfd3b1cba145b9565c3769a80f87d0b6c03a89ef11e4f0648d42dca55a4729c74345f000bad6b0dce9f9498b9c8bc1763073811a6aed439f73da6d613b8a1ddaacaaa51bbc4fdb8da09fdc7ef6a4ddec4195cab7a515eddbf1cfc89d4e6882b8d49f2675f2092ec815ec71129809caa2e0a206db40df03bb5866e24ecce79c160550f66296070f5cc59840c4680f1939dfacaec0e5bf97c7f388d30b20c04ec134906b9eab09b0cba2e42c7c319ed972e8e52768241a5ca8a946e8efbf51337a96e678d496454d839b8d50386ab814c71def314b2093c42bac0df31c8dbe198fbcd26a951802b5737b414f73289a1fdfdea2e63fcac8923e82c525ee543497ec9359dd325d908191fac9eb6d1974156d0dae52b9413fba82659b98edbce8ba546adbd6f695473730a4f72ed13dca564786325148fcc7c3b05a062d120e520104a429afeb88fda6484c7d00060fb3b66e651a4c70968740c51f2c4577e10996b2e9585a8d936056047f80f3244dbd4057e073db0305a0afd110e391a82a732cc90a1d82267cc9b4f296338284428256a642581cd1762fd3410b8562dbb4c94262fa66dcc6d81388829fb252cb5e07688f5acf1221d2ff8352e9d55df5a9dba9bb286d032566d9ad2d37807fb1ea7283e4209db9c1f0a0ceccb0e8aa4c1c72fd8f35a619934ad3676c7db1fdfb1e7b1b2aff6c22b482406f9eea16e54f7cd00c82199b53e968c6ad49079b1ae2236625e0f6f1f798eac933c8bb7f76d31e606779167417ed8813273f4f26480f37b6c855450b9de03ffd2910a71937ce983bce87c2e0ebea1668e8d99f3cb31d7bab9af8233e4cd27b4bd63a33b480a27785b47aa44ec1f506b51cc3853ae72c2a8b3ce361301192c585d194dd0043955e6f220e112c1ccf3c7d5e414be7540648813afe7dfeeef7a894776dd972175a9c8c27e8768de3141cec25ba0d4e29017ef8d11f50c405a0d2b800b6d429f9f4af9292606f11f65964240e95475d7da13c0feed4b775f66c1f75771d61976b7a1d1c56865e1ab887759d57a01e1f15fe7c68275568b78c8126f58aa71194d898a4e1ed7e52ed0e97154102847b73035ee1d58105768ef3a53a216b05352ba6b9f2368c45f51d0d78a03c2b5398eae1e82f9a11704a14b4ac5e29e35efbd0d66b9ca68e5a0feaf3d6e41c48a63b126f80e67e804efddbd7566a1be6d38a0cad03e6b85f6a1f45e7be461e35fa053d7ce1d2d640f544c0fc1a2db39c63f34cbc2b5b91caffbe6a1cd07435f35e40d2efda8912b2cd877114224f6045c6cde4111dfcf3ca3e77cf3159f1354c3c7fde719825e12eb3799b943d3e40f607c8dfd6816b8f0359e77304fd961f8b1cdaebc5ea905f0695094a29c11394cdee2ae8a09da0a9209fee1da826c0f982de3db3714d44c8e98aa12e0e1c9755bbacc7658d730f095bb9a72e5fede0df73e9532d6e2476cfa635e776d2a93e0b86e3ab018d93bafe004c1d9b4f495c6ccb75e826c28ea8149594f1d0b886bd6ff0f812760de56bcc2a3ebbea20b3f3e88cc48303b1a8040e1edaf375561edccd19942fed607c0faf262d138163ce1cb72703fb3443f84b32ef76518fccf25a4314e1034da1ae415c5b74f54b38fa239317f1ed777307ad91e438666faa5b97ded2c87c8c67f1796973adec818ed08bb964eb603291eba69293c0cfe592417b9ae63bd79d611399acf664ed83ce22db6b33b6fb5da694352cfc5fe4f13c4e7098d48171d2ee87c5dc78dcd3c2029ece36e003d409776b03f48aa60d28a1041467975271104ef67d7d8181a42a4d9cb7054e6de2596b11bdacb6d7dc7d56748fd644676941e7d334058e920f6ad7a3d47bb4039f56105122f54aa2de0117f453944816cf4e89a4a938259258e540d589f472eeced97e644466d795ea7d4f5428cf881f8bafecf1932395d39e285afe6c6008a16a8d5be5ec2f3523edf760ed3c213eaa4df3f37bdf7aef608b62d47b753ba25360c5486f9d572d4235fc67aaf394a452f79a9101dd4e249cb1cc3885bcd26eccbeb0324e79477f941ab42f3f69135f3db3b75fa2b5cb15d651aeb0c8dbc07e504fc5ec04f130037ef92daef7f18cbe0418f47ac6be37b09eced4fa7bf09bc7fa8edefba6d108cd7ace68050e30a1d57c0726ea5fa47899e83af93e7036aedb72eb24d2395f700fd87590ae008776911532a76ff4ee2e8fcbfbd6c87bdaeac9e820ad4fc59b8bbbabbede48d2d2e6588b7689ebdf8684369b13f9bcf2180025704d38c549b681ed09b93c874a75bb317ff39466ab8c97e2897d5229400435f1db12e74d868e34c7d69d8c4250bd1a5ce694b250fe99d395fa235e48d263f110b09e79715c95f08272ebd121f008ad8ec2aca1346dc5e6defcd1978e9001890122b67fea5571af5737131929b67c82e4c3228f88723ae2f4e7ec06a761ad406b551374a4ba5d8616191117d6c3f9695feac9416986fae54dd77ba163d4f9e84861790dcef1dd3fd033f31fa77e9190d3130fe8cc47b55f4bdf8dc5b3b400fd92dd85b5213c3d8099df8631d3cbc503c8bff593371f1c310ac6aefc41ac090ef9d9068b9f547e417e265f6319fff468b30dfa103fbb0b6743587a889b0de2a597890750bf7a04272bd79080efe96316f3de07051d44e3fc3ade95bf573f0b7c7cfff63e5f34d9efe238cd987833f21187019535d09b5454157d4c9bfa513f8a86e2f63498982dbb380ad3bfbaae87398b4999e4dbd49991d5c0cbf62b6275c90fb84ff49f0689bd81166f801c17bfa07ba514265e839e8cc403d31122ab23f96cf26464577a971a6794a5f3d1eb5753b9f2b5a6a0d5f45f000000ffff010000ffffe046b7fd573e0000") + bs, _ = hex.DecodeString("1f8b080000096e8800ffd43b6d6fdbb6d6dffb2b38af9be4d6b1d3e1c1838bbae9b065dd90db6d2d9a655f027f902ddae62293ba14ddc4c8fcdfefe18b2452a46425696e3b036d6cf2f0bcf3bc50d4e4d95f4546a84073ceae0bcc5f22c1b77884168c0a42b7b8fc9d67db42fed3bfd1b3c993c9b355c6e649869ebe44cb242b0028a1ab6d9670f35b023d89b6f0a5109c2c44347df2e463c251b1a30bb12674854eca15e30d4bb7198ea36a2e1aa1cbd970aa166c79364f00cd098a382e149e0a6e2c19e52ccb308fa3f372f454f00c302cb7f09b308ae2a7c582e5c0e1d3b510f910dd3e41f091b8738e3ffe940889fc785a8daeb078f71686a4acf5a8249e70a1395722022772526397ac50ac08160070bb9f36269764e58f6f76673f49c9226794b2144b2497b30092332a0575d833f39873c603eb0a8ce91b39e75302cde3cc678be39c9588d4f86482cec18c7455a0395e328ed19cb1ac40196357302204e62e45211430a050e3b7247d89a25f4921300544601d907001bea2ac86de7326d882654843a01fd214d45de00200c52e073f8c04be11f0cb58413be27e6421ff2db939c7347d3bcf0b0bfdbbad583169b30fd2ccbf920d11287efb635e0c6bd474bb9963de89fc03a04be81905393f26d9b94540cfa0720ac577c66c1c278cdc4cde1ffffb8427b03fb20ff83f5b00b275031a43a01f584953a5a21aa43f7e4072ba868d8c1b8a97c87f2619467a56ebbfb7e62d02bfa838f303a56f6832cf706ad1d05308e618ec755ce395ced9c9f5af6cd18253cddc07e5b91cff51c751dbbfe530aac76d74cefa8bf7f4bdcf8e1e417232bc78e646a1d5969c87379fd953b6fa2ece1eb2e12e5c4125b61fb6628d21752c1215782f1c910f227c9f14c535e36937520bca20ceeb9110f25243553e80f87ebe5d2c304e711a97e9407ec812c55fa9e86f8f5ada259488783875a7e2e86b8a053070a5826c34945135c9e2684d521c35a0fddc223f7b87853ad3dc918d7a613713a154e6b2b2f755f67302bbd9d7573bb31c8b2da76d4286d5dca6cbdb79b2b84a39cbc1dc400f9c018c7d85777396f0d4541cfb1655f71250a6dc53b6c9138ee36484e64d31a5abb1254ac6bf271b8cbe3a814cbaa5295e120adb157dfb2d3200f32040534e89d1a07a65960c1d805a7fe8e845d3786ad82c7f6d96b7a919c040322832141df5356c27874e8da3a6a6d1bcaed04c6d3d5675c312fc612d955e155f363955808dc1307159d53d47d1a4d8410cda80ad0bb92b8b22ae17a789489afcbadb771ada201a23b021d75b620d758d1487b933c84b47b7d7d5dfed0a690c95d09b64b1b6f0c971cfab8352abd2eb7b097f12c100a60b18b8f87026bd905108780ad718ecd55731167b0af9a54130f314d114ca1130c8ad55ddf63694ac9a29bb06eab2c686aaf63a1e8e1c0891c2642c618eaa5a7c8826e8c5f1f1b10b495213c5cb8f55bac3faa017100a25495dda3766d95654d3ce3c1815c5244584a2362dab442127c7eba478774da17ecd31173b58360cc1cb4fd9534dbdd9bd3722f8ae058b247a49d25925dc6f89588f37c94d7c3c42ff42cfb42514c419fd712770f1071350d01c05da140f4aaa5ea4439f438772a5b876d25055f6a1ed80b512df23c8fc8b358a719b6a3da51cf7152100e85bc371a7e7270d723e06d7c1ec057aa8b10f43cee93693cd287668b3ea46b0f73e6db68f6172fbe993668b08b5add8164eb46fc63f2b777aa109e252779a34c927baa057b0c76964272887828f1a6c03dd12ec6295895b319f0b96e7403988591d57081d632219a30364d47cbdba04577f2f8f6763c12e80003f05d340ae79ae27c02ef342f0f8c570eaca61969fa0816c8ba1a61aa0bfff46f5e8599ae14153163d0d6e3640f1a0e6521e92bcc77c01992459616398e768f0cd701094d6a8c412a899db73769a41a9fdf8f6969dc211a14bf6081657b853d992f24f6675c774110123759337db326a2bda6a5c8576836e7439279b84ef82e8da54eadad6f595473730a4f736d103cad6078d2a5128fcc7fdb03a06cd1702a40208485341d791fb4d939884002c1ea64dddaa34b8c0248b814a3858caee22102c55d3b1741a27c9ac0cfe0017489a6681a9c067ae074ac050a321c7c7b2aaccb0222b75089a0825d3d25bce28920a891a990a6179b0dbbecc042d14cb6dd3240b89e99b61136347208a7e228591bd0ad001b59e2da448ff04a5b2abbbead3b4537751da064acca25d5b7e00ff62d5e507c95e3af383e1419dd961d157993c1afb1f6bcc30a694664ee6ba62fbf71df6b654fed944680481ce3cd52eca9ff8a01924332ea7cad1ac672d2d6c1a888f9817803bc4df63aa27239077ff6ca7ddc3ceea2ce82eda91274e619e6c900e6e5c91cb8a163ac1ff0fa7409c12619d4cb79c0fc5d1d7e5b3a3be677feaa47718ac6a928ff830c9e0b3b5c699a103347e972bab8ff5d9b9d9a08e63f850e7828f8b3c23228e4652b224b79ab21b60a8d4ebcd5840048b87d3409f97b3c23b950152a08e7f9fbffb7d5ca8277464b98b1d4e862374bbc6490a0ef612dd46a78c023fe2e80f28e222506992035bfa6c7df257c168b47708872c329087ca83b6be509d07b7eadb397b764fc1db8eb08b35bb8e0e2bc32c8dfcc3bad607a7011f95fe7c68279568b79c8326cd8aa76328b1314de3dbfda8dc1d3e2b920408f7e606bc22a80307ec1c674b7d42d6086a4e4cf3e5ad191b574f76c003d55999c6540d8fff62848253a2a861f55219f7da87ae5e9334f5d47a509fb736e74032ddd1640334f73d741adebeae529b309f5664681db0c0dd5287287acf6bd4516358d0c30f5c9a1a282f16d83fc74b92096c9f89b7652b5afadf57b503daae663f1750f4db76a2826cf2611d85a813589971893aa2833fafdc73f70cd39558c3c4f3e72d87590aee92cc9aa4dcf11eb23f40fea60e7c7b1cc83a9f23e837fc58e6d04e2fd687fc2aa88c50ca281e2132bdaba0bd7682a18242baf7a0ea00170a7af7ccc6151129a72f867e70e0b9acde651d2e6b9d7b28d8d23d4df9ea06ff8e873ee5e25a62ff6cda70ee269df233e738b9ead138e9c71f80a965f36989f36db18efd44d81295c605e322b61ec3de37787c09bb868935e6259f6d7590dd79b446e2de81585602070fedc59a1407773381f2a5198cefe1d5b4612270cca9e7f6b4679f66097f4967ed2e1a90593dd69045784f53e8c720be2ddafa253cfe83a807f1cddb7607adb1c870c2df944f5d3a4b23fb0a9fc3e7a5cbb5b6073a422f668aad83c944ad9b284ea230974b0eed699aed7c77864d64b3da91b50f3a8b6aafedd81e769942d5b0f0bfcce359b2c0f1a20a8ca3663f2ce786c38e1616f0b4b6011fa04eb85b1b6056d46d400125a03cbb548a8370b2efea0b2c246569e2dd2df06a93c05a87e865b9bd66fe8da37bb426264b4b3a9fa629f0947c50bb01a5dea31df8b482c812a953127d7b38679fa2447278f64a2443c52b91e42a0faa4aa497337fcef5232b32fbae54ed7baa4339a1612ca1b2274c8e964e7ba26985b3812584ae356eb5b3bf348c34ef8335f384fce8362dccef7debbd832d8a55ef55ed88498125239d755eb90855f09fa9ced3922add1b467a743b63e98c05110cf24ab331fbc2ca38ed1ddd51aad7befca44d7c7939dfbd89d62c57784bb9c2c7c106f683be2ae626888719f09fd2e2cadbb4967d7b5c5834cf09ee7ac1c62c0bdeb03940f18e5724abc7fac16b90168479ff445d65f33b88034c192bdd91a9ea559856a6da0ed00f1cb19beede39d0f48accc60998dd52babc1c6c4a2d864ba4cd56d402696cdac04e6a5ba71e01376fa3f6b2cc445eebb89f79aafdaa3cc31e3bd8d5d897d30b5cbdd612bb028dd41dcf638053e254aca57841361023a0a0c8a05cde6eecd7b552b222a2906f072c4a75c9c82a5f8bf12e86987077ec3c18d208caab8bcb8c311eabaf195be92fc95c911ecadb88d5cc8be3b28f90941b371f8147e8b734660365686b36f7f6fb6a264c47340188c47d4bade4deacae2708cdb76284d4eda680886a7a2cd8cfe406a771a54067556d2aa56e9fa139a1f2a9797f7e9a4f16d5a0324375fda7edd2d2316abdf9a4b1bc06e7f8eeffd033fb8f574429c8c94900741aa2daada5ef86f26e5c847e217761ad0f4f0f60e6b77ecc7472f100f26fc3e4ed5b4f9c81b14b7f906ba2437eb6c1f26dd02fc8cfd49530eb4f87369ba00ff1b3bb70d687a587b8592f5e3a997800f5ab4770b2620d69fb9e3ee6301fbcd5d04234c9ae935df17bf946e3e3fb77f00ea5cd7e1bc729e1f2e2ca471c474c55506f52598374316deb47bfcf0d15f66934b2cf0de4799c7961bc1a163ca1c522dba6de8caa065e36af32eb9b0680fbc47cb548ec2db47803e4847cf9ef955698bc927a3290b75c0788ae8ed4ddcd93815b275e1a9c6392ce06af5f4dd4cad7868251d37f010000ffff010000ffff653340c9123f0000") gr, _ = gzip.NewReader(bytes.NewBuffer(bs)) bs, _ = ioutil.ReadAll(gr) Assets["app.js"] = bs diff --git a/gui/app.js b/gui/app.js index 8feec1e7e..ca92178a7 100644 --- a/gui/app.js +++ b/gui/app.js @@ -44,10 +44,12 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) { function getSucceeded() { if (!getOK) { + $scope.init(); $('#networkError').modal('hide'); getOK = true; } if (restarting) { + $scope.init(); $('#restarting').modal('hide'); 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.get(urlbase + '/version').success(function (data) { - $scope.version = data; - }); + $scope.init = function() { + $http.get(urlbase + '/version').success(function (data) { + $scope.version = data; + }); - $http.get(urlbase + '/system').success(function (data) { - $scope.system = data; - $scope.myID = data.myID; - }); + $http.get(urlbase + '/system').success(function (data) { + $scope.system = data; + $scope.myID = data.myID; + }); - $http.get(urlbase + '/config').success(function (data) { - $scope.config = data; - $scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(', '); + $http.get(urlbase + '/config').success(function (data) { + $scope.config = data; + $scope.config.Options.ListenStr = $scope.config.Options.ListenAddress.join(', '); - var nodes = $scope.config.Nodes; - nodes.sort(nodeCompare); - $scope.nodes = nodes; + var nodes = $scope.config.Nodes; + nodes.sort(nodeCompare); + $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) { - $scope.configInSync = data.configInSync; - }); + $http.get(urlbase + '/config/sync').success(function (data) { + $scope.configInSync = data.configInSync; + }); + }; + $scope.init(); setInterval($scope.refresh, 10000); });