diff --git a/apollo-portal/src/main/resources/static/config/sync.html b/apollo-portal/src/main/resources/static/config/sync.html index d9fd97eb6f25cea2e802f337880e0cf7ba195ac2..85825b66272b4aea13ec84d4f84365412f54937b 100644 --- a/apollo-portal/src/main/resources/static/config/sync.html +++ b/apollo-portal/src/main/resources/static/config/sync.html @@ -46,24 +46,8 @@
- - - - - - - - - - - - - - - - -
环境集群
+
diff --git a/apollo-portal/src/main/resources/static/index.html b/apollo-portal/src/main/resources/static/index.html index 4f563dffaf51376263ea240ec4ffffd0eff1114b..144f6a81d6f350c9da29642a4ab2f37f320cabbc 100644 --- a/apollo-portal/src/main/resources/static/index.html +++ b/apollo-portal/src/main/resources/static/index.html @@ -15,7 +15,7 @@
当前站点支持   -   +   环境点击切换
diff --git a/apollo-portal/src/main/resources/static/namespace.html b/apollo-portal/src/main/resources/static/namespace.html index ccd452eed691a2855659126423ac84a0f012aca5..159226728b21f672ea227d1319b53219d6828d8e 100644 --- a/apollo-portal/src/main/resources/static/namespace.html +++ b/apollo-portal/src/main/resources/static/namespace.html @@ -41,24 +41,8 @@
- - - - - - - - - - - - - - - - -
环境集群
+
diff --git a/apollo-portal/src/main/resources/static/scripts/app.js b/apollo-portal/src/main/resources/static/scripts/app.js index 8feaf589ab91da6eca55378dfd0366140e5d680b..2b3227f015393e85f3cd31597b9a55ac14b1173e 100644 --- a/apollo-portal/src/main/resources/static/scripts/app.js +++ b/apollo-portal/src/main/resources/static/scripts/app.js @@ -5,7 +5,7 @@ var appService = angular.module('app.service', ['ngResource']); var appUtil = angular.module('app.util', ['toastr']); /** directive */ -var directive_module = angular.module('apollo.directive', ['app.service']); +var directive_module = angular.module('apollo.directive', ['app.service', 'app.util', 'toastr']); /** page module 定义*/ // 首页 diff --git a/apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js b/apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js index b0a25c3d91f43d20f157d4390bd7908e2e88b343..85ed522b3d3cfa8d8b3de540a60f62d8a33f74b9 100644 --- a/apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js +++ b/apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js @@ -8,22 +8,6 @@ namespace_module.controller("LinkNamespaceController", $scope.step = 1; - ////// load env ////// - AppService.load_nav_tree($scope.appId).then(function (result) { - $scope.namespaceIdentifers = []; - var envClusterInfo = AppUtil.collectData(result); - envClusterInfo.forEach(function (node) { - var env = node.env; - node.clusters.forEach(function (cluster) { - cluster.env = env; - cluster.checked = false; - $scope.namespaceIdentifers.push(cluster); - }) - }); - }, function (result) { - toastr.error(AppUtil.errorMsg(result), "加载环境出错"); - }); - NamespaceService.find_public_namespaces().then(function (result) { var publicNamespaces = []; result.forEach(function (item) { @@ -45,9 +29,13 @@ namespace_module.controller("LinkNamespaceController", name:'', comment:'' }; + + var selectedClusters = []; + $scope.collectSelectedClusters = function (data) { + selectedClusters = data; + }; $scope.createNamespace = function () { if ($scope.type == 'link'){ - var selectedClusters = collectSelectedClusters(); if (selectedClusters.length == 0){ toastr.warning("请选择集群"); return; @@ -85,35 +73,11 @@ namespace_module.controller("LinkNamespaceController", }; - var envAllSelected = false; - $scope.toggleEnvsCheckedStatus = function () { - envAllSelected = !envAllSelected; - $scope.namespaceIdentifers.forEach(function (namespaceIdentifer) { - namespaceIdentifer.checked = envAllSelected; - }) - }; - - function collectSelectedClusters() { - var selectedClusters = []; - $scope.namespaceIdentifers.forEach(function (namespaceIdentifer) { - if (namespaceIdentifer.checked){ - namespaceIdentifer.clusterName = namespaceIdentifer.name; - selectedClusters.push(namespaceIdentifer); - } - }); - return selectedClusters; - } - - $scope.namespaceType = 1; $scope.selectNamespaceType = function (type) { $scope.namespaceType = type; }; - $scope.switchSelect = function (o) { - o.checked = !o.checked; - }; - $scope.back = function () { $window.location.href = '/config.html?#appid=' + $scope.appId; }; diff --git a/apollo-portal/src/main/resources/static/scripts/controller/app/SyncConfigController.js b/apollo-portal/src/main/resources/static/scripts/controller/app/SyncConfigController.js index 3288e81c0ebb85031ac66ca98de6b96d8ea9be37..acc612ca242d52cd4726df79ca371b14bb551831 100644 --- a/apollo-portal/src/main/resources/static/scripts/controller/app/SyncConfigController.js +++ b/apollo-portal/src/main/resources/static/scripts/controller/app/SyncConfigController.js @@ -10,31 +10,7 @@ sync_item_module.controller("SyncItemController", namespaceName: params.namespaceName }; - ////// load env ////// - AppService.load_nav_tree($scope.pageContext.appId).then(function (result) { - $scope.namespaceIdentifers = []; - var envClusterInfo = AppUtil.collectData(result); - envClusterInfo.forEach(function (node) { - var env = node.env; - node.clusters.forEach(function (cluster) { - cluster.env = env; - cluster.checked = false; - if (env != $scope.pageContext.env || cluster.name != $scope.pageContext.clusterName){ - $scope.namespaceIdentifers.push(cluster); - } - }) - }); - }, function (result) { - toastr.error(AppUtil.errorMsg(result), "加载环境出错"); - }); - var envAllSelected = false; - $scope.toggleEnvsCheckedStatus = function () { - envAllSelected = !envAllSelected; - $scope.namespaceIdentifers.forEach(function (namespaceIdentifer) { - namespaceIdentifer.checked = envAllSelected; - }) - }; ////// load items ////// ConfigService.find_items($scope.pageContext.appId, $scope.pageContext.env, @@ -85,6 +61,11 @@ sync_item_module.controller("SyncItemController", toastr.error(AppUtil.errorMsg(result)); }); }; + + var selectedClusters = []; + $scope.collectSelectedClusters = function (data) { + selectedClusters = data; + }; function parseSyncSourceData() { var sourceData = { @@ -92,11 +73,11 @@ sync_item_module.controller("SyncItemController", syncItems: [] }; var namespaceName = $scope.pageContext.namespaceName; - $scope.namespaceIdentifers.forEach(function (namespaceIdentifer) { - if (namespaceIdentifer.checked){ - namespaceIdentifer.clusterName = namespaceIdentifer.name; - namespaceIdentifer.namespaceName = namespaceName; - sourceData.syncToNamespaces.push(namespaceIdentifer); + selectedClusters.forEach(function (cluster) { + if (cluster.checked){ + cluster.clusterName = cluster.name; + cluster.namespaceName = namespaceName; + sourceData.syncToNamespaces.push(cluster); } }); $scope.sourceItems.forEach(function (item) { diff --git a/apollo-portal/src/main/resources/static/scripts/directive.js b/apollo-portal/src/main/resources/static/scripts/directive.js index c4a9fbf2bb25eae451ba361fcb8b6412a0367982..576b94c520ba0b51f37ecc749dce08bf5238500b 100644 --- a/apollo-portal/src/main/resources/static/scripts/directive.js +++ b/apollo-portal/src/main/resources/static/scripts/directive.js @@ -1,3 +1,5 @@ + +/** navbar */ directive_module.directive('apollonav', function ($compile, $window, AppService, EnvService) { return { restrict: 'E', @@ -113,3 +115,65 @@ directive_module.directive('apollonav', function ($compile, $window, AppService, } }); + +/** env cluster selector*/ + +directive_module.directive('apolloclusterselector', function ($compile, $window, AppService, AppUtil, toastr) { + return { + restrict: 'E', + templateUrl: '../views/component/env-selector.html', + transclude: true, + replace: true, + scope: { + appId: '=apolloAppId', + defaultChecked: '=apolloDefaultChecked', + select: '=apolloSelect' + }, + link: function (scope, element, attrs) { + ////// load env ////// + AppService.load_nav_tree(scope.appId).then(function (result) { + scope.clusters = []; + var envClusterInfo = AppUtil.collectData(result); + envClusterInfo.forEach(function (node) { + var env = node.env; + node.clusters.forEach(function (cluster) { + cluster.env = env; + cluster.checked = scope.defaultChecked; + scope.clusters.push(cluster); + }) + }); + scope.select(collectSelectedClusters()); + }, function (result) { + toastr.error(AppUtil.errorMsg(result), "加载环境信息出错"); + }); + + scope.envAllSelected = scope.defaultChecked; + + scope.toggleEnvsCheckedStatus = function () { + scope.envAllSelected = !scope.envAllSelected; + scope.clusters.forEach(function (cluster) { + cluster.checked = scope.envAllSelected; + }); + scope.select(collectSelectedClusters()); + }; + + scope.switchSelect = function (o) { + o.checked = !o.checked; + scope.select(collectSelectedClusters()); + }; + + function collectSelectedClusters() { + var selectedClusters = []; + scope.clusters.forEach(function (cluster) { + if (cluster.checked){ + cluster.clusterName = cluster.name; + selectedClusters.push(cluster); + } + }); + return selectedClusters; + } + + } + } + +}); diff --git a/apollo-portal/src/main/resources/static/views/component/env-selector.html b/apollo-portal/src/main/resources/static/views/component/env-selector.html new file mode 100644 index 0000000000000000000000000000000000000000..2256b19c8e8f0ec0d4d8b258c6336c39deba7684 --- /dev/null +++ b/apollo-portal/src/main/resources/static/views/component/env-selector.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + +
环境集群
diff --git a/application.pid b/application.pid index 195e5b161d2e3b3710c8f828c2037a93a7efd22c..7842531a27be52ed5e5b56f23e82a4dddca96332 100644 --- a/application.pid +++ b/application.pid @@ -1 +1 @@ -7804 \ No newline at end of file +13303 \ No newline at end of file