(config)
| 553 | } |
| 554 | |
| 555 | function updateLocalConfig(config) { |
| 556 | var hasConfig = !isEmptyObject($scope.config); |
| 557 | |
| 558 | $scope.config = config; |
| 559 | $scope.config.options._listenAddressesStr = $scope.config.options.listenAddresses.join(', '); |
| 560 | $scope.config.options._globalAnnounceServersStr = $scope.config.options.globalAnnounceServers.join(', '); |
| 561 | $scope.config.options._urAcceptedStr = "" + $scope.config.options.urAccepted; |
| 562 | |
| 563 | $scope.devices = deviceMap($scope.config.devices); |
| 564 | for (var id in $scope.devices) { |
| 565 | $scope.completion[id] = { |
| 566 | _total: 100, |
| 567 | _needBytes: 0, |
| 568 | _needItems: 0 |
| 569 | }; |
| 570 | |
| 571 | }; |
| 572 | |
| 573 | // myID is watched as $scope.otherDevices() relies on this |
| 574 | // and it can potenitally not be loaded due to this function |
| 575 | // scope being called in an undetermistic manner |
| 576 | $scope.$watch('myID', function(myID) { |
| 577 | if (myID) { |
| 578 | $scope.devicesGrouped = {}; |
| 579 | const otherDevices = $scope.otherDevices(); |
| 580 | for (var id in otherDevices) { |
| 581 | if ($scope.devicesGrouped[otherDevices[id].group] === undefined) { |
| 582 | $scope.devicesGrouped[otherDevices[id].group] = []; |
| 583 | } |
| 584 | $scope.devicesGrouped[otherDevices[id].group].push(otherDevices[id]); |
| 585 | }; |
| 586 | |
| 587 | $scope.devicesGrouped = sortByKeyThenProperty($scope.devicesGrouped, "name", "deviceID"); |
| 588 | } |
| 589 | }); |
| 590 | |
| 591 | $scope.folders = folderMap($scope.config.folders); |
| 592 | $scope.foldersGrouped = {}; |
| 593 | Object.keys($scope.folders).forEach(function (folder) { |
| 594 | refreshFolder(folder); |
| 595 | $scope.folders[folder].devices.forEach(function (deviceCfg) { |
| 596 | refreshCompletion(deviceCfg.deviceID, folder); |
| 597 | }); |
| 598 | |
| 599 | if ($scope.foldersGrouped[$scope.folders[folder].group] === undefined) { |
| 600 | $scope.foldersGrouped[$scope.folders[folder].group] = []; |
| 601 | } |
| 602 | $scope.foldersGrouped[$scope.folders[folder].group].push($scope.folders[folder]); |
| 603 | }); |
| 604 | |
| 605 | $scope.foldersGrouped = sortByKeyThenProperty($scope.foldersGrouped, "label", "id"); |
| 606 | |
| 607 | refreshNoAuthWarning(); |
| 608 | setDefaultTheme(); |
| 609 | |
| 610 | if (!hasConfig) { |
| 611 | $scope.$emit('ConfigLoaded'); |
| 612 | } |
no test coverage detected