未验证 提交 29793fbc 编写于 作者: J Jason Song 提交者: GitHub

Merge pull request #1357 from nobodyiam/portal-server-config

add query function for portal server config page
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -7,7 +7,7 @@
FROM openjdk:8-jre-alpine
MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.0.0
ENV VERSION 1.1.0-SNAPSHOT
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apollo-biz</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -7,7 +7,7 @@
FROM openjdk:8-jre-alpine
MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.0.0
ENV VERSION 1.1.0-SNAPSHOT
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apollo-demo</artifactId>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -9,7 +9,7 @@
FROM openjdk:8-jre-alpine
MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.0.0
ENV VERSION 1.1.0-SNAPSHOT
RUN echo "http://mirrors.aliyun.com/alpine/v3.6/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.6/community" >> /etc/apk/repositories \
......
......@@ -9,6 +9,7 @@ import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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;
......@@ -49,8 +50,12 @@ public class ServerConfigController {
storedConfig.setDataChangeLastModifiedBy(modifiedBy);
return serverConfigRepository.save(storedConfig);
}
}
@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@RequestMapping(value = "/server/config/{key:.+}", method = RequestMethod.GET)
public ServerConfig loadServerConfig(@PathVariable String key) {
return serverConfigRepository.findByKey(key);
}
}
......@@ -3,13 +3,37 @@ server_config_module.controller('ServerConfigController',
function ($scope, $window, toastr, ServerConfigService, AppUtil) {
$scope.serverConfig = {};
$scope.saveBtnDisabled = true;
$scope.create = function () {
ServerConfigService.create($scope.serverConfig).then(function (result) {
toastr.success("添加成功");
toastr.success("保存成功");
$scope.saveBtnDisabled = true;
$scope.serverConfig = result;
}, function (result) {
toastr.error(AppUtil.errorMsg(result), "添加失败");
toastr.error(AppUtil.errorMsg(result), "保存失败");
});
};
$scope.getServerConfigInfo = function () {
if (!$scope.serverConfig.key) {
toastr.warning("请输入key");
return;
}
ServerConfigService.getServerConfigInfo($scope.serverConfig.key).then(function (result) {
$scope.saveBtnDisabled = false;
if (!result.key) {
toastr.info("Key: " + $scope.serverConfig.key + " 不存在,点击保存后会创建该配置项");
return;
}
toastr.info("Key: " + $scope.serverConfig.key + " 已存在,点击保存后会覆盖该配置项");
$scope.serverConfig = result;
}, function (result) {
AppUtil.showErrorMsg(result);
})
}
}]);
......@@ -3,6 +3,10 @@ appService.service('ServerConfigService', ['$resource', '$q', function ($resourc
create_server_config: {
method: 'POST',
url: '/server/config'
},
get_server_config_info: {
method: 'GET',
url: '/server/config/:key'
}
});
return {
......@@ -14,6 +18,17 @@ appService.service('ServerConfigService', ['$resource', '$q', function ($resourc
d.reject(result);
});
return d.promise;
},
getServerConfigInfo: function (key) {
var d = $q.defer();
server_config_resource.get_server_config_info({
key: key
}, function (result) {
d.resolve(result);
}, function (result) {
d.reject(result);
});
return d.promise;
}
}
}]);
......@@ -21,18 +21,22 @@
<div class="panel">
<header class="panel-heading">
应用配置
<small>(维护ServerConfig表数据,如果已存在配置项则会覆盖,否则会创建配置项。配置更新后,一分钟后自动生效)</small>
<small>(维护ApolloPortalDB.ServerConfig表数据,如果已存在配置项则会覆盖,否则会创建配置项。配置更新后,一分钟后自动生效)</small>
</header>
<div class="panel-body">
<form class="form-horizontal" ng-controller="ServerConfigController" ng-submit="create()">
<form class="form-horizontal" ng-controller="ServerConfigController">
<div class="form-group">
<label class="col-sm-2 control-label">
<apollorequiredfield></apollorequiredfield>
key</label>
<div class="col-sm-9">
<div class="col-sm-8">
<input type="text" class="form-control" name="key" ng-model="serverConfig.key"
required>
<small>(修改配置前请先查询该配置信息)</small>
</div>
<div class="col-sm-1">
<button class="btn btn-info" ng-click="getServerConfigInfo()">查询</button>
</div>
</div>
<div class="form-group">
......@@ -40,7 +44,7 @@
<apollorequiredfield></apollorequiredfield>
value</label>
<div class="col-sm-9">
<textarea class="form-control" rows="4" name="comment" ng-model="serverConfig.value"></textarea>
<textarea class="form-control" rows="4" name="value" ng-model="serverConfig.value"></textarea>
</div>
</div>
<div class="form-group">
......@@ -53,8 +57,11 @@
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">提交</button>
<button type="submit" class="btn btn-primary"
ng-disabled="saveBtnDisabled"
ng-click="create()">
保存
</button>
</div>
</div>
</form>
......
......@@ -5,7 +5,7 @@
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId>
<version>1.0.0</version>
<version>1.1.0-SNAPSHOT</version>
<name>Apollo</name>
<packaging>pom</packaging>
<description>Ctrip Configuration Center</description>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册