Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
apollo
Commits
7c5a188a
Commit
7c5a188a
authored
Aug 12, 2018
by
nobodyiam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add query function for portal server config page
parent
3f2dee28
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
9 deletions
+60
-9
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java
...work/apollo/portal/controller/ServerConfigController.java
+6
-1
apollo-portal/src/main/resources/static/scripts/controller/ServerConfigController.js
...urces/static/scripts/controller/ServerConfigController.js
+26
-2
apollo-portal/src/main/resources/static/scripts/services/ServerConfigService.js
.../resources/static/scripts/services/ServerConfigService.js
+15
-0
apollo-portal/src/main/resources/static/server_config.html
apollo-portal/src/main/resources/static/server_config.html
+13
-6
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java
View file @
7c5a188a
...
...
@@ -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
);
}
}
apollo-portal/src/main/resources/static/scripts/controller/ServerConfigController.js
View file @
7c5a188a
...
...
@@ -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
);
})
}
}]);
apollo-portal/src/main/resources/static/scripts/services/ServerConfigService.js
View file @
7c5a188a
...
...
@@ -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
;
}
}
}]);
apollo-portal/src/main/resources/static/server_config.html
View file @
7c5a188a
...
...
@@ -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>
...
...
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