From b75a435942c30cbfa69a3c49cb85778b8050cb9c Mon Sep 17 00:00:00 2001 From: lepdou Date: Wed, 25 May 2016 18:32:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9A=E5=A4=84=E7=BB=86?= =?UTF-8?q?=E8=8A=82&bugfix&=E8=A1=A8=E6=A0=BC=E6=A8=A1=E5=BC=8F=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=88=A0=E9=99=A4key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/repository/NamespaceRepository.java | 2 +- .../apollo/biz/service/NamespaceService.java | 2 +- .../apollo/portal/api/AdminServiceAPI.java | 4 ++ .../controller/PortalConfigController.java | 8 +++ .../portal/service/PortalConfigService.java | 3 + .../service/txtresolver/PropertyResolver.java | 4 -- .../src/main/resources/static/config.html | 63 ++++++++++++++----- .../main/resources/static/config/sync.html | 14 ++--- .../src/main/resources/static/scripts/app.js | 2 +- .../app/ConfigNamespaceController.js | 63 ++++++++++++------- .../resources/static/scripts/directive.js | 2 +- .../static/scripts/services/ConfigService.js | 17 +++++ .../resources/static/styles/common-style.css | 9 ++- .../angular/angular-bootstrap-confirm.min.js | 8 +++ 14 files changed, 146 insertions(+), 55 deletions(-) create mode 100644 apollo-portal/src/main/resources/static/vendor/angular/angular-bootstrap-confirm.min.js diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java index 07107a3cf..c83cca3c6 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/NamespaceRepository.java @@ -8,7 +8,7 @@ import com.ctrip.framework.apollo.biz.entity.Namespace; public interface NamespaceRepository extends PagingAndSortingRepository { - List findByAppIdAndClusterName(String appId, String clusterName); + List findByAppIdAndClusterNameOrderByIdAsc(String appId, String clusterName); Namespace findByAppIdAndClusterNameAndNamespaceName(String appId, String clusterName, String namespaceName); } diff --git a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java index dbc4454ba..70ffc150a 100644 --- a/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java +++ b/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java @@ -49,7 +49,7 @@ public class NamespaceService { } public List findNamespaces(String appId, String clusterName) { - List groups = namespaceRepository.findByAppIdAndClusterName(appId, clusterName); + List groups = namespaceRepository.findByAppIdAndClusterNameOrderByIdAsc(appId, clusterName); if (groups == null) { return Collections.emptyList(); } diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java index 93ebdc1e3..d15dc1a00 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java @@ -121,6 +121,10 @@ public class AdminServiceAPI { .format("apps/%s/clusters/%s/namespaces/%s/items", appId, clusterName, namespace), item, ItemDTO.class).getBody(); } + + public void deleteItem( Env env, long itemId){ + restTemplate.delete(getAdminServiceHost(env) + "items/" + itemId); + } } @Service diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalConfigController.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalConfigController.java index f00a4fd2d..709dacb07 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalConfigController.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalConfigController.java @@ -77,6 +77,14 @@ public class PortalConfigController { return configService.createOrUpdateItem(appId, Env.valueOf(env), clusterName, namespaceName, item); } + @RequestMapping(value = "/envs/{env}/items/{itemId}", method = RequestMethod.DELETE) + public void deleteItem(@PathVariable String env, @PathVariable long itemId){ + if (itemId <= 0){ + throw new BadRequestException("item id invalid"); + } + configService.deleteItem(Env.valueOf(env), itemId); + } + @RequestMapping(value = "/apps/{appId}/env/{env}/clusters/{clusterName}/namespaces/{namespaceName}/release", method = RequestMethod.POST, consumes = { "application/json"}) public ReleaseDTO createRelease(@PathVariable String appId, diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalConfigService.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalConfigService.java index f8963f1df..17620206d 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalConfigService.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalConfigService.java @@ -81,7 +81,10 @@ public class PortalConfigService { item.setNamespaceId(namespace.getId()); return itemAPI.createOrUpdateItem(appId, env, clusterName, namespaceName, item); + } + public void deleteItem(Env env, long itemId){ + itemAPI.deleteItem(env, itemId); } /** * createRelease config items diff --git a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/txtresolver/PropertyResolver.java b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/txtresolver/PropertyResolver.java index 98587aeee..fb1f51758 100644 --- a/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/txtresolver/PropertyResolver.java +++ b/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/txtresolver/PropertyResolver.java @@ -28,10 +28,6 @@ public class PropertyResolver implements ConfigTextResolver { @Override public ItemChangeSets resolve(long namespaceId, String configText, List baseItems) { - if (StringUtils.isEmpty(configText)){ - throw new BadRequestException("config text can not be empty"); - } - Map oldLineNumMapItem = BeanUtils.mapByKey("lineNum", baseItems); Map oldKeyMapItem = BeanUtils.mapByKey("key", baseItems); diff --git a/apollo-portal/src/main/resources/static/config.html b/apollo-portal/src/main/resources/static/config.html index 2fed90233..6d6b0aa90 100644 --- a/apollo-portal/src/main/resources/static/config.html +++ b/apollo-portal/src/main/resources/static/config.html @@ -198,7 +198,7 @@ + ng-click="setCommitNamespace(namespace)"> @@ -249,17 +249,17 @@ - - - + + + - - - + + + - - - + + + @@ -279,6 +279,12 @@ data-toggle="modal" data-target="#itemModal" ng-click="editItem(namespace, config.item)"> +   + @@ -358,6 +364,29 @@ + + +