Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhangjian1949
apollo
提交
1437f2b9
apollo
项目概览
zhangjian1949
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1437f2b9
编写于
6月 02, 2016
作者:
L
lepdou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
server config has page to config
上级
9f28a766
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
179 addition
and
8 deletion
+179
-8
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/PortalSettings.java
...ava/com/ctrip/framework/apollo/portal/PortalSettings.java
+1
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalServerConfigController.java
...pollo/portal/controller/PortalServerConfigController.java
+51
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/ServerConfigRepository.java
...work/apollo/portal/repository/ServerConfigRepository.java
+0
-3
apollo-portal/src/main/resources/static/scripts/app.js
apollo-portal/src/main/resources/static/scripts/app.js
+3
-2
apollo-portal/src/main/resources/static/scripts/controller/ServerConfigController.js
...urces/static/scripts/controller/ServerConfigController.js
+15
-0
apollo-portal/src/main/resources/static/scripts/services/ServerConfigService.js
.../resources/static/scripts/services/ServerConfigService.js
+19
-0
apollo-portal/src/main/resources/static/server_config.html
apollo-portal/src/main/resources/static/server_config.html
+90
-0
未找到文件。
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/PortalSettings.java
浏览文件 @
1437f2b9
package
com.ctrip.framework.apollo.portal
;
package
com.ctrip.framework.apollo.portal
;
import
com.google.common.collect.Lists
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -58,8 +57,7 @@ public class PortalSettings {
...
@@ -58,8 +57,7 @@ public class PortalSettings {
//初始化portal支持操作的环境集合,线上的portal可能支持所有的环境操作,而线下环境则支持一部分.
//初始化portal支持操作的环境集合,线上的portal可能支持所有的环境操作,而线下环境则支持一部分.
// 每个环境的portal支持哪些环境配置在数据库里
// 每个环境的portal支持哪些环境配置在数据库里
ServerConfig
serverConfig
=
serverConfigRepository
.
findByKey
(
"apollo.portal.envs"
);
ServerConfig
serverConfig
=
serverConfigRepository
.
findByKey
(
"apollo.portal.envs"
);
// TODO: 16/5/24 线上环境暂时从本地配置里拿,之后也放在数据库上并提供界面可操作
if
(
serverConfig
!=
null
){
if
(
serverConfig
!=
null
){
//如果db有配置则从db里取
String
[]
configedEnvs
=
serverConfig
.
getValue
().
split
(
","
);
String
[]
configedEnvs
=
serverConfig
.
getValue
().
split
(
","
);
allStrEnvs
=
Arrays
.
asList
(
configedEnvs
);
allStrEnvs
=
Arrays
.
asList
(
configedEnvs
);
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalServerConfigController.java
0 → 100644
浏览文件 @
1437f2b9
package
com.ctrip.framework.apollo.portal.controller
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.entity.po.ServerConfig
;
import
com.ctrip.framework.apollo.portal.repository.ServerConfigRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
;
/**
* 配置中心本身需要一些配置,这些配置放在数据库里面
*/
@RestController
public
class
PortalServerConfigController
{
@Autowired
private
ServerConfigRepository
serverConfigRepository
;
@RequestMapping
(
value
=
"/server/config"
,
method
=
RequestMethod
.
POST
)
public
ServerConfig
createOrUpdate
(
@RequestBody
ServerConfig
serverConfig
)
{
if
(
serverConfig
==
null
||
StringUtils
.
isContainEmpty
(
serverConfig
.
getKey
(),
serverConfig
.
getValue
()))
{
throw
new
BadRequestException
(
"request payload contains empty"
);
}
// TODO: 16/6/2 接入sso之后改成当前登录用户
String
modifiedBy
=
"admin"
;
ServerConfig
storedConfig
=
serverConfigRepository
.
findByKey
(
serverConfig
.
getKey
());
if
(
storedConfig
==
null
)
{
//create
serverConfig
.
setDataChangeCreatedBy
(
modifiedBy
);
serverConfig
.
setDataChangeLastModifiedBy
(
modifiedBy
);
return
serverConfigRepository
.
save
(
serverConfig
);
}
else
{
//update
BeanUtils
.
copyEntityProperties
(
serverConfig
,
storedConfig
);
storedConfig
.
setDataChangeLastModifiedBy
(
modifiedBy
);
return
serverConfigRepository
.
save
(
storedConfig
);
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/ServerConfigRepository.java
浏览文件 @
1437f2b9
...
@@ -5,9 +5,6 @@ import com.ctrip.framework.apollo.portal.entity.po.ServerConfig;
...
@@ -5,9 +5,6 @@ import com.ctrip.framework.apollo.portal.entity.po.ServerConfig;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
interface
ServerConfigRepository
extends
PagingAndSortingRepository
<
ServerConfig
,
Long
>
{
public
interface
ServerConfigRepository
extends
PagingAndSortingRepository
<
ServerConfig
,
Long
>
{
ServerConfig
findByKey
(
String
key
);
ServerConfig
findByKey
(
String
key
);
}
}
apollo-portal/src/main/resources/static/scripts/app.js
浏览文件 @
1437f2b9
...
@@ -13,12 +13,13 @@ var index_module = angular.module('index', ['toastr', 'app.service', 'app.util',
...
@@ -13,12 +13,13 @@ var index_module = angular.module('index', ['toastr', 'app.service', 'app.util',
//项目主页
//项目主页
var
application_module
=
angular
.
module
(
'
application
'
,
[
'
app.service
'
,
'
apollo.directive
'
,
'
app.util
'
,
'
toastr
'
,
'
angular-loading-bar
'
]);
var
application_module
=
angular
.
module
(
'
application
'
,
[
'
app.service
'
,
'
apollo.directive
'
,
'
app.util
'
,
'
toastr
'
,
'
angular-loading-bar
'
]);
//创建项目页面
//创建项目页面
var
create_app_module
=
angular
.
module
(
'
create_app
'
,
[
'
ngResource
'
,
'
apollo.directive
'
,
'
toastr
'
,
'
app.service
'
,
'
app.util
'
,
'
angular-loading-bar
'
]);
var
create_app_module
=
angular
.
module
(
'
create_app
'
,
[
'
apollo.directive
'
,
'
toastr
'
,
'
app.service
'
,
'
app.util
'
,
'
angular-loading-bar
'
]);
//配置同步页面
//配置同步页面
var
sync_item_module
=
angular
.
module
(
'
sync_item
'
,
[
'
app.service
'
,
'
apollo.directive
'
,
'
app.util
'
,
'
toastr
'
,
'
angular-loading-bar
'
]);
var
sync_item_module
=
angular
.
module
(
'
sync_item
'
,
[
'
app.service
'
,
'
apollo.directive
'
,
'
app.util
'
,
'
toastr
'
,
'
angular-loading-bar
'
]);
//namespace
//namespace
var
namespace_module
=
angular
.
module
(
'
namespace
'
,
[
'
app.service
'
,
'
apollo.directive
'
,
'
app.util
'
,
'
toastr
'
,
'
angular-loading-bar
'
]);
var
namespace_module
=
angular
.
module
(
'
namespace
'
,
[
'
app.service
'
,
'
apollo.directive
'
,
'
app.util
'
,
'
toastr
'
,
'
angular-loading-bar
'
]);
//server config
var
server_config_module
=
angular
.
module
(
'
server_config
'
,
[
'
app.service
'
,
'
apollo.directive
'
,
'
app.util
'
,
'
toastr
'
,
'
angular-loading-bar
'
]);
...
...
apollo-portal/src/main/resources/static/scripts/controller/ServerConfigController.js
0 → 100644
浏览文件 @
1437f2b9
server_config_module
.
controller
(
'
ServerConfigController
'
,
[
'
$scope
'
,
'
$window
'
,
'
toastr
'
,
'
ServerConfigService
'
,
'
AppUtil
'
,
function
(
$scope
,
$window
,
toastr
,
ServerConfigService
,
AppUtil
)
{
$scope
.
serverConfig
=
{};
$scope
.
create
=
function
()
{
ServerConfigService
.
create
(
$scope
.
serverConfig
).
then
(
function
(
result
)
{
toastr
.
success
(
"
添加成功
"
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
添加失败
"
);
});
};
}]);
apollo-portal/src/main/resources/static/scripts/services/ServerConfigService.js
0 → 100644
浏览文件 @
1437f2b9
appService
.
service
(
'
ServerConfigService
'
,
[
'
$resource
'
,
'
$q
'
,
function
(
$resource
,
$q
)
{
var
server_config_resource
=
$resource
(
''
,
{},
{
create_server_config
:
{
method
:
'
POST
'
,
url
:
'
/server/config
'
}
});
return
{
create
:
function
(
serverConfig
)
{
var
d
=
$q
.
defer
();
server_config_resource
.
create_server_config
({},
serverConfig
,
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
d
.
reject
(
result
);
});
return
d
.
promise
;
}
}
}]);
apollo-portal/src/main/resources/static/server_config.html
0 → 100644
浏览文件 @
1437f2b9
<!doctype html>
<html
ng-app=
"server_config"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
<!-- styles -->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"vendor/bootstrap/css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"vendor/angular/angular-toastr-1.4.1.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
'all'
href=
"vendor/angular/loading-bar.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styles/common-style.css"
>
<title>
应用配置
</title>
</head>
<body>
<apollonav></apollonav>
<div
class=
"container-fluid apollo-container"
>
<div
class=
"row"
>
<div
class=
"col-md-8 col-md-offset-2"
>
<div
class=
"panel"
>
<header
class=
"panel-heading"
>
应用配置
</header>
<div
class=
"panel-body"
>
<form
class=
"form-horizontal"
ng-controller=
"ServerConfigController"
ng-submit=
"create()"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
<apollorequiredfiled></apollorequiredfiled>
key
</label>
<div
class=
"col-sm-9"
>
<input
type=
"text"
class=
"form-control"
name=
"key"
ng-model=
"serverConfig.key"
required
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
<apollorequiredfiled></apollorequiredfiled>
value
</label>
<div
class=
"col-sm-9"
>
<textarea
class=
"form-control"
rows=
"4"
name=
"comment"
ng-model=
"serverConfig.value"
></textarea>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
comment
</label>
<div
class=
"col-sm-9"
>
<textarea
class=
"form-control"
rows=
"4"
name=
"comment"
ng-model=
"serverConfig.comment"
></textarea>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-sm-offset-2 col-sm-10"
>
<button
type=
"submit"
class=
"btn btn-default"
>
提交
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div
ng-include=
"'views/common/footer.html'"
></div>
<!--angular-->
<script
src=
"vendor/angular/angular.min.js"
></script>
<script
src=
"vendor/angular/angular-route.min.js"
></script>
<script
src=
"vendor/angular/angular-resource.min.js"
></script>
<script
src=
"vendor/angular/angular-toastr-1.4.1.tpls.min.js"
></script>
<script
src=
"vendor/angular/loading-bar.min.js"
></script>
<!-- jquery.js -->
<script
src=
"vendor/jquery.min.js"
type=
"text/javascript"
></script>
<!-- bootstrap.js -->
<script
src=
"vendor/bootstrap/js/bootstrap.min.js"
type=
"text/javascript"
></script>
<script
type=
"application/javascript"
src=
"scripts/app.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/AppUtils.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/ServerConfigService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/ServerConfigController.js"
></script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录