Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
1437f2b9
Commit
1437f2b9
authored
Jun 02, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server config has page to config
parent
9f28a766
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
179 additions
and
8 deletions
+179
-8
PortalSettings.java
...ava/com/ctrip/framework/apollo/portal/PortalSettings.java
+1
-3
PortalServerConfigController.java
...pollo/portal/controller/PortalServerConfigController.java
+51
-0
ServerConfigRepository.java
...work/apollo/portal/repository/ServerConfigRepository.java
+0
-3
app.js
apollo-portal/src/main/resources/static/scripts/app.js
+3
-2
ServerConfigController.js
...urces/static/scripts/controller/ServerConfigController.js
+15
-0
ServerConfigService.js
.../resources/static/scripts/services/ServerConfigService.js
+19
-0
server_config.html
apollo-portal/src/main/resources/static/server_config.html
+90
-0
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/PortalSettings.java
View file @
1437f2b9
package
com
.
ctrip
.
framework
.
apollo
.
portal
;
import
com.google.common.collect.Lists
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -58,8 +57,7 @@ public class PortalSettings {
//初始化portal支持操作的环境集合,线上的portal可能支持所有的环境操作,而线下环境则支持一部分.
// 每个环境的portal支持哪些环境配置在数据库里
ServerConfig
serverConfig
=
serverConfigRepository
.
findByKey
(
"apollo.portal.envs"
);
// TODO: 16/5/24 线上环境暂时从本地配置里拿,之后也放在数据库上并提供界面可操作
if
(
serverConfig
!=
null
){
//如果db有配置则从db里取
if
(
serverConfig
!=
null
){
String
[]
configedEnvs
=
serverConfig
.
getValue
().
split
(
","
);
allStrEnvs
=
Arrays
.
asList
(
configedEnvs
);
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalServerConfigController.java
0 → 100644
View file @
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
View file @
1437f2b9
...
...
@@ -5,9 +5,6 @@ import com.ctrip.framework.apollo.portal.entity.po.ServerConfig;
import
org.springframework.data.repository.PagingAndSortingRepository
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
interface
ServerConfigRepository
extends
PagingAndSortingRepository
<
ServerConfig
,
Long
>
{
ServerConfig
findByKey
(
String
key
);
}
apollo-portal/src/main/resources/static/scripts/app.js
View file @
1437f2b9
...
...
@@ -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
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'
]);
//namespace
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
View file @
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
View file @
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
View file @
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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment