From f2c7de859ab9a307280065ebbb444b7e777305e5 Mon Sep 17 00:00:00 2001 From: lepdou Date: Fri, 6 May 2016 14:36:18 +0800 Subject: [PATCH] add namespace --- .../controller/AppNamespaceController.java | 13 ++ .../repository/AppNamespaceRepository.java | 4 + .../biz/service/AppNamespaceService.java | 7 + .../java/com/ctrip/apollo/biz/AllTests.java | 2 + .../AppNamespaceRepositoryTest.java | 33 +++++ apollo-biz/src/test/resources/data.sql | 8 ++ .../apollo/core/dto/AppNamespaceDTO.java | 34 +++++ .../ctrip/apollo/portal/PortalSettings.java | 4 + .../apollo/portal/api/AdminServiceAPI.java | 16 +++ .../controller/NamespaceController.java | 38 ++++++ .../portal/service/NamespaceService.java | 30 +++++ .../{views/create-app.html => app.html} | 34 ++--- .../static/{views/app.html => config.html} | 80 ++++++----- .../static/{views => config}/sync.html | 4 +- .../src/main/resources/static/index.html | 4 +- .../src/main/resources/static/namespace.html | 124 ++++++++++++++++++ .../scripts/controller/CreateAppController.js | 2 +- .../controller/LinkNamespaceController.js | 90 +++++++++++++ .../controller/app/SyncConfigController.js | 3 +- .../scripts/services/NamespaceService.js | 44 +++++++ .../resources/static/styles/common-style.css | 6 + 21 files changed, 515 insertions(+), 65 deletions(-) create mode 100644 apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppNamespaceRepositoryTest.java create mode 100644 apollo-biz/src/test/resources/data.sql create mode 100644 apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppNamespaceDTO.java create mode 100644 apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/NamespaceController.java create mode 100644 apollo-portal/src/main/java/com/ctrip/apollo/portal/service/NamespaceService.java rename apollo-portal/src/main/resources/static/{views/create-app.html => app.html} (68%) rename apollo-portal/src/main/resources/static/{views/app.html => config.html} (87%) rename apollo-portal/src/main/resources/static/{views => config}/sync.html (98%) create mode 100644 apollo-portal/src/main/resources/static/namespace.html create mode 100644 apollo-portal/src/main/resources/static/scripts/controller/LinkNamespaceController.js create mode 100644 apollo-portal/src/main/resources/static/scripts/services/NamespaceService.js diff --git a/apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/AppNamespaceController.java b/apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/AppNamespaceController.java index c0e63b83a..fb9f8c076 100644 --- a/apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/AppNamespaceController.java +++ b/apollo-adminservice/src/main/java/com/ctrip/apollo/adminservice/controller/AppNamespaceController.java @@ -1,11 +1,17 @@ package com.ctrip.apollo.adminservice.controller; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ctrip.apollo.biz.entity.AppNamespace; import com.ctrip.apollo.biz.service.AppNamespaceService; +import com.ctrip.apollo.common.utils.BeanUtils; +import com.ctrip.apollo.core.dto.AppNamespaceDTO; + +import java.util.List; @RestController public class AppNamespaceController { @@ -18,4 +24,11 @@ public class AppNamespaceController { @PathVariable("appnamespace") String appnamespace) { return appNamespaceService.isAppNamespaceNameUnique(appId, appnamespace); } + + @RequestMapping("/appnamespaces/public") + public List findPublicAppNamespaces(){ + List appNamespaces = appNamespaceService.findPublicAppNamespaces(); + return BeanUtils.batchTransform(AppNamespaceDTO.class, appNamespaces); + } + } diff --git a/apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/AppNamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/AppNamespaceRepository.java index 35d1612c4..a15cc35b2 100644 --- a/apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/AppNamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/AppNamespaceRepository.java @@ -4,10 +4,14 @@ import org.springframework.data.repository.PagingAndSortingRepository; import com.ctrip.apollo.biz.entity.AppNamespace; +import java.util.List; + public interface AppNamespaceRepository extends PagingAndSortingRepository{ AppNamespace findByAppIdAndName(String appId, String namespaceName); AppNamespace findByName(String namespaceName); + List findByNameNot(String namespaceName); + } diff --git a/apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppNamespaceService.java b/apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppNamespaceService.java index 0d087c315..8e075ead8 100644 --- a/apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppNamespaceService.java +++ b/apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AppNamespaceService.java @@ -2,9 +2,12 @@ package com.ctrip.apollo.biz.service; import com.google.common.base.Preconditions; +import java.util.List; import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -50,4 +53,8 @@ public class AppNamespaceService { auditService.audit(AppNamespace.class.getSimpleName(), appNs.getId(), Audit.OP.INSERT, createBy); } + + public List findPublicAppNamespaces(){ + return appNamespaceRepository.findByNameNot(ConfigConsts.NAMESPACE_DEFAULT); + } } diff --git a/apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java b/apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java index ec86b5f38..79a35d36b 100644 --- a/apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java +++ b/apollo-biz/src/test/java/com/ctrip/apollo/biz/AllTests.java @@ -1,6 +1,7 @@ package com.ctrip.apollo.biz; import com.ctrip.apollo.biz.message.DatabaseMessageSenderTest; +import com.ctrip.apollo.biz.repository.AppNamespaceRepositoryTest; import com.ctrip.apollo.biz.repository.AppRepositoryTest; import com.ctrip.apollo.biz.service.AdminServiceTest; import com.ctrip.apollo.biz.service.AdminServiceTransactionTest; @@ -14,6 +15,7 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({ AppRepositoryTest.class, + AppNamespaceRepositoryTest.class, AdminServiceTest.class, ConfigServiceTest.class, PrivilegeServiceTest.class, diff --git a/apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppNamespaceRepositoryTest.java b/apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppNamespaceRepositoryTest.java new file mode 100644 index 000000000..80682a38b --- /dev/null +++ b/apollo-biz/src/test/java/com/ctrip/apollo/biz/repository/AppNamespaceRepositoryTest.java @@ -0,0 +1,33 @@ +package com.ctrip.apollo.biz.repository; + +import com.ctrip.apollo.biz.BizTestConfiguration; +import com.ctrip.apollo.biz.entity.AppNamespace; +import com.ctrip.apollo.core.ConfigConsts; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.SpringApplicationConfiguration; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringApplicationConfiguration(classes = BizTestConfiguration.class) +@Transactional +@Rollback +public class AppNamespaceRepositoryTest { + + @Autowired + private AppNamespaceRepository repository; + + @Test + public void testFindAllPublicAppNamespaces(){ + List appNamespaceList = repository.findByNameNot(ConfigConsts.NAMESPACE_DEFAULT); + Assert.assertEquals(4, appNamespaceList.size()); + } + +} diff --git a/apollo-biz/src/test/resources/data.sql b/apollo-biz/src/test/resources/data.sql new file mode 100644 index 000000000..15d328f43 --- /dev/null +++ b/apollo-biz/src/test/resources/data.sql @@ -0,0 +1,8 @@ + +INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'application'); +INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'fx.apollo.config'); +INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'application'); +INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'fx.apollo.admin'); +INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'application'); +INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'fx.apollo.portal'); +INSERT INTO AppNamespace (AppID, Name) VALUES ('fxhermesproducer', 'fx.hermes.producer'); diff --git a/apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppNamespaceDTO.java b/apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppNamespaceDTO.java new file mode 100644 index 000000000..0776202da --- /dev/null +++ b/apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppNamespaceDTO.java @@ -0,0 +1,34 @@ +package com.ctrip.apollo.core.dto; + +public class AppNamespaceDTO { + + private String name; + + private String appId; + + private String comment; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } +} diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalSettings.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalSettings.java index 598e9168e..4bbcc87b9 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalSettings.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/PortalSettings.java @@ -28,4 +28,8 @@ public class PortalSettings { public List getEnvs() { return envs; } + + public Env getFirstEnv(){ + return envs.get(0); + } } diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java index 4709cfe65..1b7001059 100644 --- a/apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java @@ -1,6 +1,7 @@ package com.ctrip.apollo.portal.api; +import com.ctrip.apollo.core.dto.AppNamespaceDTO; import com.ctrip.apollo.core.enums.Env; import com.ctrip.apollo.core.dto.AppDTO; import com.ctrip.apollo.core.dto.ClusterDTO; @@ -61,6 +62,21 @@ public class AdminServiceAPI { + String.format("apps/%s/clusters/%s/namespaces/%s", appId, clusterName, namespaceName), NamespaceDTO.class); } + + public List findPublicAppNamespaces(Env env){ + AppNamespaceDTO[] appNamespaceDTOs = restTemplate.getForObject( + getAdminServiceHost(env)+ "appnamespaces/public", + AppNamespaceDTO[].class); + return Arrays.asList(appNamespaceDTOs); + } + + public NamespaceDTO save(Env env, NamespaceDTO namespace) { + return restTemplate.postForEntity(getAdminServiceHost(env) + + String.format("/apps/%s/clusters/%s/namespaces", namespace.getAppId(), + namespace.getClusterName()), namespace, NamespaceDTO.class) + .getBody(); + } + } @Service diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/NamespaceController.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/NamespaceController.java new file mode 100644 index 000000000..f234facdd --- /dev/null +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/NamespaceController.java @@ -0,0 +1,38 @@ +package com.ctrip.apollo.portal.controller; + +import com.ctrip.apollo.core.dto.AppNamespaceDTO; +import com.ctrip.apollo.core.dto.NamespaceDTO; +import com.ctrip.apollo.core.enums.Env; +import com.ctrip.apollo.core.exception.BadRequestException; +import com.ctrip.apollo.core.utils.StringUtils; +import com.ctrip.apollo.portal.service.NamespaceService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +public class NamespaceController { + @Autowired + private NamespaceService namespaceService; + + @RequestMapping("/appnamespaces/public") + public List findPublicAppNamespaces(){ + return namespaceService.findPublicAppNamespaces(); + } + + @RequestMapping(value = "/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces", method = RequestMethod.POST) + public NamespaceDTO save(@PathVariable String env, @RequestBody NamespaceDTO namespace){ + if (StringUtils.isContainEmpty(env, namespace.getAppId(), namespace.getClusterName(), namespace.getNamespaceName())){ + throw new BadRequestException("request payload contains empty"); + } + return namespaceService.save(Env.valueOf(env), namespace); + + } + +} diff --git a/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/NamespaceService.java b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/NamespaceService.java new file mode 100644 index 000000000..6de6c533b --- /dev/null +++ b/apollo-portal/src/main/java/com/ctrip/apollo/portal/service/NamespaceService.java @@ -0,0 +1,30 @@ +package com.ctrip.apollo.portal.service; + +import com.ctrip.apollo.core.dto.AppNamespaceDTO; +import com.ctrip.apollo.core.dto.NamespaceDTO; +import com.ctrip.apollo.core.enums.Env; +import com.ctrip.apollo.portal.PortalSettings; +import com.ctrip.apollo.portal.api.AdminServiceAPI; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class NamespaceService { + + @Autowired + private AdminServiceAPI.NamespaceAPI namespaceAPI; + @Autowired + private PortalSettings portalSettings; + + public List findPublicAppNamespaces(){ + return namespaceAPI.findPublicAppNamespaces(portalSettings.getFirstEnv()); + } + + public NamespaceDTO save(Env env, NamespaceDTO namespace){ + return namespaceAPI.save(env, namespace); + } + +} diff --git a/apollo-portal/src/main/resources/static/views/create-app.html b/apollo-portal/src/main/resources/static/app.html similarity index 68% rename from apollo-portal/src/main/resources/static/views/create-app.html rename to apollo-portal/src/main/resources/static/app.html index 79376323e..7d1c74043 100644 --- a/apollo-portal/src/main/resources/static/views/create-app.html +++ b/apollo-portal/src/main/resources/static/app.html @@ -3,16 +3,16 @@ - - - - + + + + 新建项目 -
+
@@ -64,25 +64,25 @@
-
+
- - - - - + + + + + - + - + - - - + + + - + diff --git a/apollo-portal/src/main/resources/static/views/app.html b/apollo-portal/src/main/resources/static/config.html similarity index 87% rename from apollo-portal/src/main/resources/static/views/app.html rename to apollo-portal/src/main/resources/static/config.html index 1b7d8b074..dfbf4a939 100644 --- a/apollo-portal/src/main/resources/static/views/app.html +++ b/apollo-portal/src/main/resources/static/config.html @@ -4,15 +4,15 @@ apollo - - - - + + + + -
+
@@ -28,7 +28,7 @@
- 应用信息 + 应用信息 @@ -68,14 +68,13 @@
-
+
-
- + @@ -84,15 +83,14 @@ - - - - - - - - - + +
+
+ +
+
@@ -128,7 +126,7 @@ 同步
@@ -236,7 +234,7 @@
- +
2016-02-23 @@ -254,7 +252,7 @@
- +
2016-02-23 @@ -316,7 +314,7 @@
-
+
- + - + - + - - - - - + + + + + - - + + - + - - - + + + - + - + diff --git a/apollo-portal/src/main/resources/static/views/sync.html b/apollo-portal/src/main/resources/static/config/sync.html similarity index 98% rename from apollo-portal/src/main/resources/static/views/sync.html rename to apollo-portal/src/main/resources/static/config/sync.html index 24e3407ac..7a0a94f04 100644 --- a/apollo-portal/src/main/resources/static/views/sync.html +++ b/apollo-portal/src/main/resources/static/config/sync.html @@ -12,7 +12,7 @@ -
+
@@ -175,7 +175,7 @@
-
+
diff --git a/apollo-portal/src/main/resources/static/index.html b/apollo-portal/src/main/resources/static/index.html index e579eac46..7ba2b42fc 100644 --- a/apollo-portal/src/main/resources/static/index.html +++ b/apollo-portal/src/main/resources/static/index.html @@ -25,7 +25,7 @@

Apollo

携程统一配置中心
共收录了 {{appsCount}} 个项目 - 创建项目 + 创建项目

@@ -42,7 +42,7 @@
-

{{app.appId}}

diff --git a/apollo-portal/src/main/resources/static/namespace.html b/apollo-portal/src/main/resources/static/namespace.html new file mode 100644 index 000000000..cf540ef72 --- /dev/null +++ b/apollo-portal/src/main/resources/static/namespace.html @@ -0,0 +1,124 @@ + + + + + + + + + + + 新建Namespace + + + + +
+ +
+ +
+
+
+
+ 新建Namespace +
+ +
+ +
+ +
+ {{appId}} +
+
+
+
+ +
+ + + + + + + + + + + + + + + + +
环境集群
{{namespaceIdentifer.env}}{{namespaceIdentifer.name}}
+
+
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js b/apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js index bb92c4c53..3fb55b18c 100644 --- a/apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js +++ b/apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js @@ -5,7 +5,7 @@ create_app_module.controller('CreateAppController', ['$scope', '$window', 'toast AppService.create('ALL', $scope.app).then(function (result) { toastr.success('添加成功!'); setInterval(function () { - $window.location.href = '/views/app.html?#appid=' + result.appId; + $window.location.href = '/views/config.html?#appid=' + result.appId; }, 1000); }, function (result) { toastr.error(AppUtil.errorMsg(result), '添加失败!'); diff --git a/apollo-portal/src/main/resources/static/scripts/controller/LinkNamespaceController.js b/apollo-portal/src/main/resources/static/scripts/controller/LinkNamespaceController.js new file mode 100644 index 000000000..f06713dc5 --- /dev/null +++ b/apollo-portal/src/main/resources/static/scripts/controller/LinkNamespaceController.js @@ -0,0 +1,90 @@ +application_module.controller("LinkNamespaceController", + ['$scope', '$location', '$window', 'toastr', 'AppService', 'AppUtil', 'NamespaceService', + function ($scope, $location, $window, toastr, AppService, AppUtil, NamespaceService) { + + var params = AppUtil.parseParams($location.$$url); + $scope.appId = params.appid; + $scope.isRootUser = params.root ? true : false; + + ////// load env ////// + AppService.load_nav_tree($scope.appId).then(function (result) { + $scope.namespaceIdentifers = []; + result.nodes.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) { + var namespace = {}; + namespace.id = item.name; + namespace.text = item.name; + publicNamespaces.push(namespace); + }); + $('#namespaces').select2({ + width: '250px', + data: publicNamespaces + }); + }, function (result) { + toastr.error(AppUtil.errorMsg(result), "load public namespace error"); + }); + + $scope.saveNamespace = function () { + var selectedClusters = collectSelectedClusters(); + if (selectedClusters.length == 0){ + toastr.warning("请选择集群"); + return; + } + var namespaceName = $('#namespaces').select2('data')[0].id; + selectedClusters.forEach(function (cluster) { + NamespaceService.save($scope.appId, cluster.env, cluster.clusterName, + namespaceName).then(function (result) { + toastr.success( + cluster.env + "_" + result.clusterName + "_" + result.namespaceName + + "创建成功"); + }, function (result) { + toastr.error(AppUtil.errorMsg(result), + cluster.env + "_" + cluster.clusterName + "_" + + namespaceName + "创建失败"); + }); + }) + }; + + 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; + } + }]); + 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 d517812b8..190a947a6 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 @@ -3,7 +3,6 @@ sync_item_module.controller("SyncItemController", function ($scope, $location, $window, toastr, AppService, AppUtil, ConfigService) { var params = AppUtil.parseParams($location.$$url); - var currentUser = 'test_user'; $scope.pageContext = { appId: params.appid, env: params.env, @@ -115,7 +114,7 @@ sync_item_module.controller("SyncItemController", }; $scope.backToAppHomePage = function () { - $window.location.href = '/views/app.html?#appid=' + $scope.pageContext.appId; + $window.location.href = '/views/config.html?#appid=' + $scope.pageContext.appId; }; $scope.switchSelect = function (o) { diff --git a/apollo-portal/src/main/resources/static/scripts/services/NamespaceService.js b/apollo-portal/src/main/resources/static/scripts/services/NamespaceService.js new file mode 100644 index 000000000..b987940bb --- /dev/null +++ b/apollo-portal/src/main/resources/static/scripts/services/NamespaceService.js @@ -0,0 +1,44 @@ +appService.service("NamespaceService", ['$resource', '$q', function ($resource, $q) { + var namespace_source = $resource("", {}, { + find_public_namespaces: { + method: 'GET', + isArray: true, + url: '/appnamespaces/public' + }, + save: { + method: 'POST', + url: '/apps/:appId/envs/:env/clusters/:clusterName/namespaces', + isArray: false + } + }); + + return { + find_public_namespaces: function () { + var d = $q.defer(); + namespace_source.find_public_namespaces({}, function (result) { + d.resolve(result); + }, function (result) { + d.reject(result); + }); + return d.promise; + }, + save: function (appId, env, clusterName, namespaceName) { + var d = $q.defer(); + namespace_source.save({ + appId: appId, + env: env, + clusterName: clusterName + }, { + appId: appId, + clusterName: clusterName, + namespaceName: namespaceName + }, function (result) { + d.resolve(result); + }, function (result) { + d.reject(result); + }); + return d.promise; + } + } + +}]); diff --git a/apollo-portal/src/main/resources/static/styles/common-style.css b/apollo-portal/src/main/resources/static/styles/common-style.css index 69d59b714..0339bc3e6 100644 --- a/apollo-portal/src/main/resources/static/styles/common-style.css +++ b/apollo-portal/src/main/resources/static/styles/common-style.css @@ -259,3 +259,9 @@ table th { padding-bottom: 4px; } +.list-group-item .btn-title{ + color: gray; + font-family: "Apple Color Emoji"; + font-size: 16px; +} + -- GitLab