Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wrr-cat
apollo
提交
eb37797f
apollo
项目概览
wrr-cat
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
eb37797f
编写于
5月 20, 2016
作者:
L
lepdou
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #211 from lepdou/table_view
table view cru
上级
3808305a
6aaa2773
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
437 addition
and
143 deletion
+437
-143
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
...mework/apollo/adminservice/controller/ItemController.java
+7
-0
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java
...ctrip/framework/apollo/biz/repository/ItemRepository.java
+1
-0
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+11
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+6
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalConfigController.java
...work/apollo/portal/controller/PortalConfigController.java
+35
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalConfigService.java
.../framework/apollo/portal/service/PortalConfigService.java
+5
-0
apollo-portal/src/main/resources/static/app.html
apollo-portal/src/main/resources/static/app.html
+4
-4
apollo-portal/src/main/resources/static/config.html
apollo-portal/src/main/resources/static/config.html
+147
-56
apollo-portal/src/main/resources/static/config/sync.html
apollo-portal/src/main/resources/static/config/sync.html
+1
-1
apollo-portal/src/main/resources/static/scripts/controller/app/ConfigNamespaceController.js
...tatic/scripts/controller/app/ConfigNamespaceController.js
+126
-36
apollo-portal/src/main/resources/static/scripts/directive.js
apollo-portal/src/main/resources/static/scripts/directive.js
+31
-16
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
...c/main/resources/static/scripts/services/ConfigService.js
+53
-15
apollo-portal/src/main/resources/static/styles/common-style.css
...-portal/src/main/resources/static/styles/common-style.css
+6
-7
apollo-portal/src/main/resources/static/views/component/env-selector.html
...c/main/resources/static/views/component/env-selector.html
+3
-3
application.pid
application.pid
+1
-0
未找到文件。
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
浏览文件 @
eb37797f
...
...
@@ -36,7 +36,14 @@ public class ItemController {
BeanUtils
.
copyEntityProperties
(
entity
,
managedEntity
);
entity
=
itemService
.
update
(
managedEntity
);
}
else
{
Item
lastItem
=
itemService
.
findLastOne
(
appId
,
clusterName
,
namespaceName
);
int
lineNum
=
1
;
if
(
lastItem
!=
null
){
lineNum
=
lastItem
.
getLineNum
()
+
1
;
}
entity
.
setLineNum
(
lineNum
);
entity
.
setDataChangeCreatedBy
(
user
.
getUsername
());
entity
.
setDataChangeLastModifiedBy
(
user
.
getUsername
());
entity
=
itemService
.
save
(
entity
);
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java
浏览文件 @
eb37797f
...
...
@@ -12,4 +12,5 @@ public interface ItemRepository extends PagingAndSortingRepository<Item, Long> {
List
<
Item
>
findByNamespaceIdOrderByLineNumAsc
(
Long
namespaceId
);
Item
findFirst1ByNamespaceIdOrderByLineNumDesc
(
Long
namespaceId
);
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemService.java
浏览文件 @
eb37797f
...
...
@@ -45,6 +45,17 @@ public class ItemService {
return
item
;
}
public
Item
findLastOne
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
Namespace
namespace
=
namespaceRepository
.
findByAppIdAndClusterNameAndNamespaceName
(
appId
,
clusterName
,
namespaceName
);
if
(
namespace
==
null
)
{
throw
new
NotFoundException
(
String
.
format
(
"namespace not found for %s %s %s"
,
appId
,
clusterName
,
namespaceName
));
}
Item
item
=
itemRepository
.
findFirst1ByNamespaceIdOrderByLineNumDesc
(
namespace
.
getId
());
return
item
;
}
public
Item
findOne
(
long
itemId
)
{
Item
item
=
itemRepository
.
findOne
(
itemId
);
return
item
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
浏览文件 @
eb37797f
...
...
@@ -115,6 +115,12 @@ public class AdminServiceAPI {
.
format
(
"apps/%s/clusters/%s/namespaces/%s/itemset"
,
appId
,
clusterName
,
namespace
),
changeSets
,
Void
.
class
);
}
public
ItemDTO
createOrUpdateItem
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
ItemDTO
item
){
return
restTemplate
.
postForEntity
(
getAdminServiceHost
(
env
)
+
String
.
format
(
"apps/%s/clusters/%s/namespaces/%s/items"
,
appId
,
clusterName
,
namespace
),
item
,
ItemDTO
.
class
).
getBody
();
}
}
@Service
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PortalConfigController.java
浏览文件 @
eb37797f
...
...
@@ -37,7 +37,7 @@ public class PortalConfigController {
@RequestBody
NamespaceTextModel
model
)
{
if
(
model
==
null
)
{
throw
new
BadRequestException
(
"request payload shoud not be null"
);
throw
new
BadRequestException
(
"request payload shou
l
d not be null"
);
}
model
.
setAppId
(
appId
);
model
.
setClusterName
(
clusterName
);
...
...
@@ -51,13 +51,39 @@ public class PortalConfigController {
configService
.
updateConfigItemByText
(
model
);
}
@RequestMapping
(
value
=
"/apps/{appId}/env/{env}/clusters/{clusterName}/namespaces/{namespaceName}/item"
,
method
=
RequestMethod
.
POST
)
public
ItemDTO
createItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
ItemDTO
item
){
if
(
StringUtils
.
isContainEmpty
(
appId
,
env
,
clusterName
,
namespaceName
)){
throw
new
BadRequestException
(
"request payload should not be contain empty."
);
}
if
(!
isValidItem
(
item
)
&&
item
.
getNamespaceId
()
<=
0
){
throw
new
BadRequestException
(
"request model is invalid"
);
}
return
configService
.
createOrUpdateItem
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
,
item
);
}
@RequestMapping
(
value
=
"/apps/{appId}/env/{env}/clusters/{clusterName}/namespaces/{namespaceName}/item"
,
method
=
RequestMethod
.
PUT
)
public
ItemDTO
updateItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
ItemDTO
item
){
if
(
StringUtils
.
isContainEmpty
(
appId
,
env
,
clusterName
,
namespaceName
)){
throw
new
BadRequestException
(
"request payload should not be contain empty."
);
}
if
(!
isValidItem
(
item
)){
throw
new
BadRequestException
(
"request model is invalid"
);
}
return
configService
.
createOrUpdateItem
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
,
item
);
}
@RequestMapping
(
value
=
"/apps/{appId}/env/{env}/clusters/{clusterName}/namespaces/{namespaceName}/release"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
"application/json"
})
public
ReleaseDTO
createRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
NamespaceReleaseModel
model
)
{
if
(
model
==
null
)
{
throw
new
BadRequestException
(
"request payload shoud not be null"
);
throw
new
BadRequestException
(
"request payload shou
l
d not be null"
);
}
model
.
setAppId
(
appId
);
model
.
setClusterName
(
clusterName
);
...
...
@@ -77,7 +103,7 @@ public class PortalConfigController {
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
){
if
(
StringUtils
.
isContainEmpty
(
appId
,
env
,
clusterName
,
namespaceName
)){
throw
new
BadRequestException
(
"appid,env,cluster name,namespace name can not be
null
"
);
throw
new
BadRequestException
(
"appid,env,cluster name,namespace name can not be
empty
"
);
}
return
configService
.
findItems
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
...
...
@@ -87,7 +113,7 @@ public class PortalConfigController {
"application/json"
})
public
List
<
ItemDiffs
>
diff
(
@RequestBody
NamespaceSyncModel
model
){
if
(
model
==
null
){
throw
new
BadRequestException
(
"request payload shoud not be null"
);
throw
new
BadRequestException
(
"request payload shou
l
d not be null"
);
}
if
(
model
.
isInvalid
())
{
throw
new
BadRequestException
(
"request model is invalid"
);
...
...
@@ -100,7 +126,7 @@ public class PortalConfigController {
"application/json"
})
public
ResponseEntity
<
Void
>
update
(
@RequestBody
NamespaceSyncModel
model
){
if
(
model
==
null
){
throw
new
BadRequestException
(
"request payload shoud not be null"
);
throw
new
BadRequestException
(
"request payload shou
l
d not be null"
);
}
if
(
model
.
isInvalid
())
{
throw
new
BadRequestException
(
"request model is invalid"
);
...
...
@@ -109,4 +135,8 @@ public class PortalConfigController {
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
build
();
}
private
boolean
isValidItem
(
ItemDTO
item
){
return
item
!=
null
&&
!
StringUtils
.
isContainEmpty
(
item
.
getKey
(),
item
.
getValue
());
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/PortalConfigService.java
浏览文件 @
eb37797f
...
...
@@ -71,6 +71,11 @@ public class PortalConfigService {
}
}
public
ItemDTO
createOrUpdateItem
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
ItemDTO
item
){
return
itemAPI
.
createOrUpdateItem
(
appId
,
env
,
clusterName
,
namespaceName
,
item
);
}
/**
* createRelease config items
*/
...
...
apollo-portal/src/main/resources/static/app.html
浏览文件 @
eb37797f
...
...
@@ -25,26 +25,26 @@
<div
class=
"panel-body"
>
<form
class=
"form-horizontal"
ng-controller=
"CreateAppController"
ng-submit=
"create()"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><
font
style=
"color: red"
>
*
</font
>
应用ID
</label>
<label
class=
"col-sm-2 control-label"
><
apollorequiredfiled></apollorequiredfiled
>
应用ID
</label>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appAppId"
ng-model=
"app.appId"
required
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><
font
style=
"color: red"
>
*
</font
>
应用名称
</label>
<label
class=
"col-sm-2 control-label"
><
apollorequiredfiled></apollorequiredfiled
>
应用名称
</label>
<div
class=
"col-sm-5"
>
<input
type=
"text"
class=
"form-control"
name=
"appName"
ng-model=
"app.name"
required
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><
font
style=
"color: red"
>
*
</font
>
应用Owner
</label>
<label
class=
"col-sm-2 control-label"
><
apollorequiredfiled></apollorequiredfiled
>
应用Owner
</label>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appOwner"
ng-model=
"app.ownerName"
required
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><
font
style=
"color: red"
>
*
</font
>
邮箱地址
</label>
<label
class=
"col-sm-2 control-label"
><
apollorequiredfiled></apollorequiredfiled
>
邮箱地址
</label>
<div
class=
"col-sm-4"
>
<input
type=
"email"
class=
"form-control"
ng-model=
"app.ownerEmail"
required
>
</div>
...
...
apollo-portal/src/main/resources/static/config.html
浏览文件 @
eb37797f
...
...
@@ -108,7 +108,8 @@
<div
class=
"checkbox"
ng-repeat=
"env in missEnvs"
>
<label>
<input
type=
"checkbox"
name=
"selectedEnvs[]"
value=
"{{env}}"
ng-checked=
"selectedEnvs.indexOf(env) > -1"
ng-click=
"toggleSelection(env)"
><span
ng-bind=
"env"
><span/>
ng-checked=
"selectedEnvs.indexOf(env) > -1"
ng-click=
"toggleSelection(env)"
><span
ng-bind=
"env"
></span>
</label>
</div>
</div>
...
...
@@ -116,7 +117,8 @@
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
关闭
</button>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
ng-click=
"createEnvs()"
>
添加
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
ng-click=
"createEnvs()"
>
添加
</button>
</div>
</div>
...
...
@@ -132,7 +134,8 @@
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<b
ng-bind=
"namespace.namespace.namespaceName"
></b>
<span
class=
"label label-primary"
ng-show=
"namespace.itemModifiedCnt > 0"
>
有修改
<span
class=
"label label-primary"
ng-show=
"namespace.itemModifiedCnt > 0"
>
有修改
<span
class=
"badge"
ng-bind=
"namespace.itemModifiedCnt"
></span></span>
</div>
<div
class=
"col-md-4"
>
...
...
@@ -153,7 +156,7 @@
<button
type=
"button"
class=
"btn btn-default btn-sm J_tableview_btn"
>
授权
</button>
<a
type=
"button"
target=
"_blank"
<a
type=
"button"
href=
"config/sync.html?#/appid={{pageContext.appId}}&env={{pageContext.env}}&clusterName={{pageContext.clusterName}}&namespaceName={{namespace.namespace.namespaceName}}"
class=
"btn btn-default btn-sm J_tableview_btn"
>
同步
</a>
...
...
@@ -182,7 +185,8 @@
</div>
<div
class=
"col-md-1 text-right"
>
<a
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"取消修改"
ng-show=
"namespace.isTextEditing"
ng-click=
"toggleTextEditStatus(namespace)"
>
ng-show=
"namespace.isTextEditing && namespace.viewType == 'text'"
ng-click=
"toggleTextEditStatus(namespace)"
>
<span
class=
"glyphicon glyphicon-remove"
aria-hidden=
"true"
></span>
</a>
<a
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"修改配置"
...
...
@@ -193,9 +197,17 @@
<a
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"提交修改"
data-toggle=
"modal"
data-target=
"#commitModal"
ng-show=
"namespace.isTextEditing"
ng-click=
"saveDraft(namespace)"
>
ng-show=
"namespace.isTextEditing && namespace.viewType == 'text'"
ng-click=
"saveDraft(namespace)"
>
<span
class=
"glyphicon glyphicon-ok"
aria-hidden=
"true"
></span>
</a>
<a
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"添加配置"
ng-show=
"namespace.viewType == 'table'"
data-toggle=
"modal"
data-target=
"#itemModal"
ng-click=
"createItem(namespace)"
>
<span
class=
"glyphicon glyphicon-plus"
aria-hidden=
"true"
></span>
</a>
</div>
</div>
</header>
...
...
@@ -203,13 +215,14 @@
<!--text view-->
<textarea
class=
"form-control"
rows=
"{{namespace.itemCnt}}"
style=
"border-radius: 0px"
ng-show=
"namespace.viewType == 'text'"
ng-disabled=
"!namespace.isTextEditing"
ng-model=
"namespace.text"
ng-bind=
"namespace.text"
>
ng-disabled=
"!namespace.isTextEditing"
ng-model=
"namespace.text"
ng-bind=
"namespace.text"
>
</textarea>
<!--table view-->
<div
class=
"namespace-view-table"
>
<table
class=
"table table-bordered table-striped text-center table-hover"
ng-show=
"namespace.viewType == 'table'"
>
ng-show=
"namespace.viewType == 'table'
&& namespace.items.length > 0
"
>
<thead>
<tr>
<th>
...
...
@@ -227,29 +240,45 @@
<th>
最后修改时间
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<tr
title=
"点击查看"
data-toggle=
"modal"
data-target=
"#oldValueModal"
ng-repeat=
"config in namespace.items"
ng-class=
"{warning:config.modified}"
ng-if=
"config.item.key"
ng-click=
"watchItem(config.item.key, config.item.value, config.oldValue)"
>
<td
width=
"25%"
>
<tr
ng-repeat=
"config in namespace.items"
ng-class=
"{warning:config.isModified}"
ng-if=
"config.item.key"
>
<td
width=
"20%"
>
<span
ng-bind=
"config.item.key | limitTo: 20"
></span>
<span
ng-bind=
"config.item.key.length > 20 ? '...' :''"
></span>
</td>
<td
width=
"
30%"
>
<td
width=
"
25%"
>
<span
ng-bind=
"config.item.value | limitTo: 20"
></span>
<span
ng-bind=
"config.item.value.length > 20 ? '...': ''"
></span>
</td>
<td
width=
"20%"
>
<td
width=
"20%"
>
<span
ng-bind=
"config.item.comment | limitTo: 20"
></span>
<span
ng-bind=
"config.item.comment.length > 20 ?'...' : ''"
></span>
</td>
<td
width=
"10%"
ng-bind=
"config.item.lastModifiedBy"
>
</td>
<td
width=
"15%"
ng-bind=
"config.item.lastModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'"
>
<td
width=
"15%"
ng-bind=
"config.item.lastModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'"
>
</td>
<td
width=
"10%"
>
<span
class=
"glyphicon glyphicon-eye-open"
aria-hidden=
"true"
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"查看"
data-toggle=
"modal"
data-target=
"#itemModal"
ng-click=
"retrieveItem(config.item, config.oldValue)"
>
</span>
<span
class=
"glyphicon glyphicon-edit"
aria-hidden=
"true"
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"修改"
data-toggle=
"modal"
data-target=
"#itemModal"
ng-click=
"editItem(namespace, config.item)"
>
</span>
</td>
</tr>
...
...
@@ -304,78 +333,140 @@
</div>
</div>
<!--
view old value Modal
-->
<div
class=
"modal fade"
id=
"
oldValue
Modal"
tabindex=
"-1"
role=
"dialog"
>
<!--
commit modify config modal
-->
<div
class=
"modal fade"
id=
"
commit
Modal"
tabindex=
"-1"
role=
"dialog"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header panel-primary"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
<h4
class=
"modal-title"
>
{{watch.key}}
</h4>
</div>
<div
class=
"modal-body"
style=
"word-wrap: break-word;"
>
{{watch.value}}
<div
ng-show=
"watch.oldValue"
>
<hr>
<b>
已发布的值:
</b>
{{watch.oldValue}}
<h4
class=
"modal-title"
>
Commit changes
</h4>
</div>
<div
class=
"modal-body"
>
<textarea
rows=
"4"
class=
"form-control"
style=
"width:570px;"
placeholder=
"Add an optional extended description..."
ng-model=
"commitComment"
></textarea>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
关闭
</button>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
ng-click=
"commitChange()"
>
提交
</button>
</div>
</div>
</div>
</div>
<!-- commit modify config modal-->
<div
class=
"modal fade"
id=
"commitModal"
tabindex=
"-1"
role=
"dialog"
>
<!--create release modal-->
<form
class=
"modal fade form-horizontal"
id=
"releaseModal"
tabindex=
"-1"
role=
"dialog"
ng-submit=
"release()"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header panel-primary"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
<h4
class=
"modal-title"
>
Commit changes
</h4>
<h4
class=
"modal-title"
>
发布
</h4>
</div>
<div
class=
"modal-body"
>
<textarea
rows=
"4"
class=
"form-control"
style=
"width:570px;"
placeholder=
"Add an optional extended description..."
ng-model=
"commitComment"
></textarea>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
<apollorequiredfiled></apollorequiredfiled>
Release Name:
</label>
<div
class=
"col-sm-9"
>
<input
type=
"text"
class=
"form-control"
placeholder=
"input release title"
ng-model=
"releaseTitle"
ng-required=
"true"
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
Comment:
</label>
<div
class=
"col-sm-9"
>
<textarea
rows=
"4"
class=
"form-control"
style=
"margin-top: 15px;"
ng-model=
"releaseComment"
placeholder=
"Add an optional extended description..."
></textarea>
</div>
</div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
关闭
</button>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
ng-click=
"commitChange()"
>
提交
<button
type=
"submit"
class=
"btn btn-primary"
>
提交
</button>
</div>
</div>
</div>
</
div
>
</
form
>
<!--
create release
modal-->
<
div
class=
"modal fade"
id=
"releaseModal"
tabindex=
"-1"
role=
"dialog
"
>
<!--
table mode item
modal-->
<
form
class=
"modal fade form-horizontal"
id=
"itemModal"
role=
"dialog"
ng-submit=
"doItem()
"
>
<div
class=
"modal-dialog"
role=
"document"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header panel-primary"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span></button>
<h4
class=
"modal-title"
>
发布
</h4>
<h4
class=
"modal-title"
>
<span
ng-show=
"tableViewOperType == 'create'"
>
添加配置项
</span>
<span
ng-show=
"tableViewOperType == 'retrieve'"
>
查看配置项
</span>
<span
ng-show=
"tableViewOperType == 'update'"
>
修改配置项
</span>
</h4>
</div>
<div
class=
"modal-body"
>
<input
type=
"text"
class=
"form-control"
placeholder=
"input release title"
ng-model=
"releaseTitle"
required=
"required"
>
<textarea
rows=
"4"
class=
"form-control"
style=
"margin-top: 15px;"
ng-model=
"releaseComment"
placeholder=
"Add an optional extended description..."
></textarea>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
Key
</label>
<div
class=
"col-sm-10"
>
<input
type=
"text"
class=
"form-control"
ng-model=
"item.key"
ng-required=
"true"
ng-disabled=
"tableViewOperType != 'create'"
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
Value
</label>
<div
class=
"col-sm-10"
>
<textarea
type=
"text"
class=
"form-control"
rows=
"4"
ng-model=
"item.value"
ng-required=
"true"
ng-disabled=
"tableViewOperType == 'retrieve'"
>
</textarea>
</div>
</div>
<div
class=
"form-group"
ng-show=
"tableViewOperType == 'retrieve'"
>
<label
class=
"col-sm-2 control-label"
>
Released Value
</label>
<div
class=
"col-sm-10"
>
<textarea
type=
"text"
class=
"form-control"
rows=
"4"
ng-model=
"item.oldValue"
ng-disabled=
"true"
ng-show=
"item.oldVale"
>
</textarea>
<span
ng-show=
"!item.oldVale"
>
这是新增的配置
</span>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
Comment
</label>
<div
class=
"col-sm-10"
>
<textarea
class=
"form-control"
ng-model=
"item.comment"
rows=
"4"
ng-disabled=
"tableViewOperType == 'retrieve'"
>
</textarea>
</div>
</div>
<div
class=
"form-group"
ng-show=
"tableViewOperType != 'retrieve'"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
选择集群
</label>
<div
class=
"col-sm-10"
>
<apolloclusterselector
apollo-app-id=
"pageContext.appId"
apollo-default-checked=
"false"
apollo-select=
"collectSelectedClusters"
></apolloclusterselector>
</div>
</div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
关闭
</button>
<button
type=
"submit"
class=
"btn btn-primary"
data-dismiss=
"modal"
ng-click=
"release()"
>
提交
<button
type=
"button"
class=
"btn btn-default"
ng-click=
"switchToEdit()"
ng-show=
"tableViewOperType == 'retrieve'"
>
修改
</button>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
关闭
</button>
<button
type=
"submit"
class=
"btn btn-primary"
ng-show=
"tableViewOperType != 'retrieve'"
>
提交
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
apollo-portal/src/main/resources/static/config/sync.html
浏览文件 @
eb37797f
...
...
@@ -60,7 +60,7 @@
<label
class=
"control-label"
>
需要同步的配置
</label>
</div>
<div
class=
"col-sm-10"
>
<table
class=
"table table-bordered table-striped table-hover"
>
<table
class=
"table table-bordered table-striped table-hover"
>
<thead>
<tr>
<td><input
type=
"checkbox"
ng-click=
"toggleItemsCheckedStatus()"
></td>
...
...
apollo-portal/src/main/resources/static/scripts/controller/app/ConfigNamespaceController.js
浏览文件 @
eb37797f
...
...
@@ -5,42 +5,50 @@ application_module.controller("ConfigNamespaceController",
////// namespace //////
var
namespace_view_type
=
{
TEXT
:
'
text
'
,
TEXT
:
'
text
'
,
TABLE
:
'
table
'
,
LOG
:
'
log
'
};
$rootScope
.
refreshNamespaces
=
function
(
viewType
)
{
if
(
$rootScope
.
pageContext
.
env
==
''
){
if
(
$rootScope
.
pageContext
.
env
==
''
)
{
return
;
}
ConfigService
.
load_all_namespaces
(
$rootScope
.
pageContext
.
appId
,
$rootScope
.
pageContext
.
env
,
$rootScope
.
pageContext
.
clusterName
,
viewType
).
then
(
ConfigService
.
load_all_namespaces
(
$rootScope
.
pageContext
.
appId
,
$rootScope
.
pageContext
.
env
,
$rootScope
.
pageContext
.
clusterName
,
viewType
).
then
(
function
(
result
)
{
$scope
.
namespaces
=
result
;
//初始化视图
if
(
$scope
.
namespaces
)
{
$scope
.
namespaces
.
forEach
(
function
(
item
)
{
item
.
isModify
=
false
;
$scope
.
namespaces
.
forEach
(
function
(
namespace
)
{
if
(
!
viewType
)
{
//default text view
$scope
.
switchView
(
item
,
namespace_view_type
.
TEXT
);
$scope
.
switchView
(
namespace
,
namespace_view_type
.
TABLE
);
}
else
if
(
viewType
==
namespace_view_type
.
TABLE
)
{
item
.
viewType
=
namespace_view_type
.
TABLE
;
namespace
.
viewType
=
namespace_view_type
.
TABLE
;
}
item
.
isTextEditing
=
false
;
namespace
.
isTextEditing
=
false
;
});
}
setInterval
(
function
()
{
$
(
'
[data-tooltip="tooltip"]
'
).
tooltip
();
},
2500
);
$
(
'
.namespace-view-table
'
).
bind
(
'
mousewheel DOMMouseScroll
'
,
function
(
e
)
{
var
e0
=
e
.
originalEvent
,
delta
=
e0
.
wheelDelta
||
-
e0
.
detail
;
this
.
scrollTop
+=
(
delta
<
0
?
1
:
-
1
)
*
30
;
e
.
preventDefault
();
});
},
2500
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
加载配置信息出错
"
);
});
}
}
;
////// global view oper //////
...
...
@@ -69,7 +77,7 @@ application_module.controller("ConfigNamespaceController",
}
else
{
result
+=
item
.
item
.
comment
+
"
\n
"
;
}
itemCnt
++
;
itemCnt
++
;
});
namespace
.
itemCnt
=
itemCnt
>
MAX_ROW_SIZE
?
MAX_ROW_SIZE
:
itemCnt
+
3
;
...
...
@@ -87,8 +95,10 @@ application_module.controller("ConfigNamespaceController",
$scope
.
commitComment
=
''
;
//更新配置
$scope
.
commitChange
=
function
()
{
ConfigService
.
modify_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
$scope
.
pageContext
.
clusterName
,
$scope
.
draft
.
namespace
.
namespaceName
,
$scope
.
draft
.
text
,
ConfigService
.
modify_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
$scope
.
pageContext
.
clusterName
,
$scope
.
draft
.
namespace
.
namespaceName
,
$scope
.
draft
.
text
,
$scope
.
draft
.
namespace
.
id
,
$scope
.
commitComment
).
then
(
function
(
result
)
{
toastr
.
success
(
"
更新成功
"
);
...
...
@@ -104,30 +114,20 @@ application_module.controller("ConfigNamespaceController",
);
};
//文本编辑框状态切换
$scope
.
toggleTextEditStatus
=
function
(
namespace
)
{
namespace
.
isTextEditing
=
!
namespace
.
isTextEditing
;
if
(
namespace
.
isTextEditing
){
//切换为编辑状态,保存一下原来值
if
(
namespace
.
isTextEditing
)
{
//切换为编辑状态,保存一下原来值
$scope
.
draft
.
backupText
=
namespace
.
text
;
}
else
{
if
(
$scope
.
draft
.
backupText
){
//取消编辑,则复原
}
else
{
if
(
$scope
.
draft
.
backupText
)
{
//取消编辑,则复原
namespace
.
text
=
$scope
.
draft
.
backupText
;
}
}
};
////// table view oper //////
$scope
.
watch
=
{};
//查看配置
$scope
.
watchItem
=
function
(
key
,
value
,
oldValue
)
{
$scope
.
watch
.
key
=
key
;
$scope
.
watch
.
value
=
value
;
$scope
.
watch
.
oldValue
=
oldValue
;
};
/////// release ///////
var
releaseModal
=
$
(
'
#releaseModal
'
);
var
releaseNamespace
=
{};
$scope
.
prepareReleaseNamespace
=
function
(
namespace
)
{
...
...
@@ -138,9 +138,11 @@ application_module.controller("ConfigNamespaceController",
$scope
.
release
=
function
()
{
ConfigService
.
release
(
$rootScope
.
pageContext
.
appId
,
$rootScope
.
pageContext
.
env
,
$rootScope
.
pageContext
.
clusterName
,
releaseNamespace
.
namespace
.
namespaceName
,
$scope
.
releaseTitle
,
releaseNamespace
.
namespace
.
namespaceName
,
$scope
.
releaseTitle
,
$scope
.
releaseComment
).
then
(
function
(
result
)
{
releaseModal
.
modal
(
'
hide
'
);
toastr
.
success
(
"
发布成功
"
);
//refresh all namespace items
$rootScope
.
refreshNamespaces
();
...
...
@@ -152,6 +154,94 @@ application_module.controller("ConfigNamespaceController",
);
};
var
TABLE_VIEW_OPER_TYPE
=
{
RETRIEVE
:
'
retrieve
'
,
CREATE
:
'
create
'
,
UPDATE
:
'
update
'
};
$scope
.
tableViewOperType
=
''
,
$scope
.
item
=
{};
//查看配置
$scope
.
retrieveItem
=
function
(
item
,
oldValue
)
{
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
RETRIEVE
);
$scope
.
item
=
item
;
$scope
.
item
.
oldValue
=
oldValue
;
};
var
toOperationNamespaceName
=
''
;
//修改配置
$scope
.
editItem
=
function
(
namespace
,
item
)
{
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
UPDATE
);
$scope
.
item
=
item
;
toOperationNamespaceName
=
namespace
.
namespace
.
namespaceName
;
};
//新增配置
$scope
.
createItem
=
function
(
namespace
)
{
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
CREATE
);
$scope
.
item
=
{};
$scope
.
item
.
namespaceId
=
namespace
.
namespace
.
id
;
toOperationNamespaceName
=
namespace
.
namespace
.
namespaceName
;
};
$scope
.
switchToEdit
=
function
()
{
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
UPDATE
);
};
var
selectedClusters
=
[];
$scope
.
collectSelectedClusters
=
function
(
data
)
{
selectedClusters
=
data
;
};
function
switchTableViewOperType
(
type
)
{
$scope
.
tableViewOperType
=
type
;
}
var
itemModal
=
$
(
"
#itemModal
"
);
$scope
.
doItem
=
function
()
{
if
(
selectedClusters
.
length
==
0
)
{
toastr
.
error
(
"
请选择集群
"
);
}
else
{
selectedClusters
.
forEach
(
function
(
cluster
)
{
if
(
$scope
.
tableViewOperType
==
TABLE_VIEW_OPER_TYPE
.
CREATE
)
{
ConfigService
.
create_item
(
$rootScope
.
pageContext
.
appId
,
cluster
.
env
,
cluster
.
name
,
toOperationNamespaceName
,
$scope
.
item
).
then
(
function
(
result
)
{
toastr
.
success
(
"
[
"
+
cluster
.
env
+
"
,
"
+
cluster
.
name
+
"
]
"
,
"
创建成功
"
);
itemModal
.
modal
(
'
hide
'
);
$rootScope
.
refreshNamespaces
(
namespace_view_type
.
TABLE
);
},
function
(
result
)
{
AppUtil
.
errorMsg
(
result
);
});
}
else
if
(
$scope
.
tableViewOperType
==
TABLE_VIEW_OPER_TYPE
.
UPDATE
)
{
ConfigService
.
update_item
(
$rootScope
.
pageContext
.
appId
,
cluster
.
env
,
cluster
.
name
,
toOperationNamespaceName
,
$scope
.
item
).
then
(
function
(
result
)
{
toastr
.
success
(
"
[
"
+
cluster
.
env
+
"
,
"
+
cluster
.
name
+
"
]
"
,
"
更新成功
"
);
itemModal
.
modal
(
'
hide
'
);
$rootScope
.
refreshNamespaces
(
namespace_view_type
.
TABLE
);
},
function
(
result
)
{
AppUtil
.
errorMsg
(
result
);
});
}
});
}
};
$
(
'
.config-item-container
'
).
removeClass
(
'
hide
'
);
}]);
apollo-portal/src/main/resources/static/scripts/directive.js
浏览文件 @
eb37797f
/** navbar */
directive_module
.
directive
(
'
apollonav
'
,
function
(
$compile
,
$window
,
AppService
,
EnvService
)
{
return
{
...
...
@@ -44,14 +43,14 @@ directive_module.directive('apollonav', function ($compile, $window, AppService,
};
scope
.
jumpToConfigPage
=
function
()
{
if
(
selectedApp
.
appId
){
if
(
selectedApp
.
appId
)
{
var
needReloadPage
=
false
;
if
(
$window
.
location
.
href
.
indexOf
(
"
config.html
"
)
>
-
1
){
if
(
$window
.
location
.
href
.
indexOf
(
"
config.html
"
)
>
-
1
)
{
needReloadPage
=
true
;
}
$window
.
location
.
href
=
'
/config.html?#appid=
'
+
selectedApp
.
appId
;
if
(
needReloadPage
){
if
(
needReloadPage
)
{
$window
.
location
.
reload
();
}
}
...
...
@@ -72,10 +71,10 @@ directive_module.directive('apollonav', function ($compile, $window, AppService,
scope
.
copyedApps
[
--
selectedAppIdx
].
selected
=
true
;
}
}
else
if
(
event
.
keyCode
==
13
)
{
if
(
scope
.
shouldShowAppList
&&
selectedAppIdx
>
-
1
){
if
(
scope
.
shouldShowAppList
&&
selectedAppIdx
>
-
1
)
{
select
(
scope
.
copyedApps
[
selectedAppIdx
]);
event
.
preventDefault
();
}
else
{
}
else
{
scope
.
jumpToConfigPage
();
}
...
...
@@ -157,15 +156,21 @@ directive_module.directive('apolloclusterselector', function ($compile, $window,
scope
.
select
(
collectSelectedClusters
());
};
scope
.
switchSelect
=
function
(
o
)
{
scope
.
switchSelect
=
function
(
o
,
$event
)
{
o
.
checked
=
!
o
.
checked
;
$event
.
stopPropagation
();
scope
.
select
(
collectSelectedClusters
());
};
scope
.
toggleClusterCheckedStatus
=
function
(
cluster
)
{
cluster
.
checked
=
!
cluster
.
checked
;
scope
.
select
(
collectSelectedClusters
());
};
function
collectSelectedClusters
()
{
var
selectedClusters
=
[];
scope
.
clusters
.
forEach
(
function
(
cluster
)
{
if
(
cluster
.
checked
){
if
(
cluster
.
checked
)
{
cluster
.
clusterName
=
cluster
.
name
;
selectedClusters
.
push
(
cluster
);
}
...
...
@@ -177,3 +182,13 @@ directive_module.directive('apolloclusterselector', function ($compile, $window,
}
});
directive_module
.
directive
(
'
apollorequiredfiled
'
,
function
(
$compile
,
$window
)
{
return
{
restrict
:
'
E
'
,
template
:
'
<span style="color: red">*</span>
'
,
transclude
:
true
,
replace
:
true
}
});
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
浏览文件 @
eb37797f
...
...
@@ -5,10 +5,10 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
isArray
:
true
,
url
:
'
/apps/:appId/env/:env/clusters/:clusterName/namespaces
'
},
find_items
:{
method
:
'
GET
'
,
find_items
:
{
method
:
'
GET
'
,
isArray
:
true
,
url
:
'
/apps/:appId/env/:env/clusters/:clusterName/namespaces/:namespaceName/items
'
url
:
'
/apps/:appId/env/:env/clusters/:clusterName/namespaces/:namespaceName/items
'
},
modify_items
:
{
method
:
'
PUT
'
,
...
...
@@ -16,7 +16,7 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
},
release
:
{
method
:
'
POST
'
,
url
:
'
/apps/:appId/env/:env/clusters/:clusterName/namespaces/:namespaceName/release
'
url
:
'
/apps/:appId/env/:env/clusters/:clusterName/namespaces/:namespaceName/release
'
},
diff
:
{
method
:
'
POST
'
,
...
...
@@ -27,6 +27,14 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
method
:
'
PUT
'
,
url
:
'
/namespaces/:namespaceName/items
'
,
isArray
:
false
},
create_item
:
{
method
:
'
POST
'
,
url
:
'
/apps/:appId/env/:env/clusters/:clusterName/namespaces/:namespaceName/item
'
},
update_item
:
{
method
:
'
PUT
'
,
url
:
'
/apps/:appId/env/:env/clusters/:clusterName/namespaces/:namespaceName/item
'
}
});
...
...
@@ -70,7 +78,7 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
{
configText
:
configText
,
namespaceId
:
namespaceId
,
comment
:
comment
comment
:
comment
},
function
(
result
)
{
d
.
resolve
(
result
);
...
...
@@ -120,6 +128,36 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
d
.
reject
(
result
);
});
return
d
.
promise
;
},
create_item
:
function
(
appId
,
env
,
clusterName
,
namespaceName
,
item
)
{
var
d
=
$q
.
defer
();
config_source
.
create_item
({
appId
:
appId
,
env
:
env
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
},
item
,
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
d
.
reject
(
result
);
});
return
d
.
promise
;
},
update_item
:
function
(
appId
,
env
,
clusterName
,
namespaceName
,
item
)
{
var
d
=
$q
.
defer
();
config_source
.
update_item
({
appId
:
appId
,
env
:
env
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
},
item
,
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
d
.
reject
(
result
);
});
return
d
.
promise
;
}
}
...
...
apollo-portal/src/main/resources/static/styles/common-style.css
浏览文件 @
eb37797f
...
...
@@ -212,22 +212,21 @@ table th {
}
.namespace-view-table
{
max-height
:
700px
;
}
.namespace-view-table
table
{
table-layout
:
fixed
;
}
.namespace-view-table
tr
{
cursor
:
pointer
;
.namespace-view-table
table
{
table-layout
:
inherit
;
}
.namespace-view-table
td
{
word-wrap
:
break-word
;
}
.namespace-view-table
.glyphicon
{
cursor
:
pointer
;
}
.history-view
{
padding
:
50px
20px
;
...
...
apollo-portal/src/main/resources/static/views/component/env-selector.html
浏览文件 @
eb37797f
<table
class=
"table table-hover"
>
<table
class=
"table table-hover"
style=
"width: 250px"
>
<thead>
<tr>
<td><input
type=
"checkbox"
ng-checked=
"envAllSelected"
ng-click=
"toggleEnvsCheckedStatus()"
></td>
...
...
@@ -8,9 +8,9 @@
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"cluster in clusters
"
>
<tr
style=
"cursor: pointer"
ng-repeat=
"cluster in clusters"
ng-click=
"toggleClusterCheckedStatus(cluster)
"
>
<td
width=
"10%"
><input
type=
"checkbox"
ng-checked=
"cluster.checked"
ng-click=
"switchSelect(cluster)"
></td>
ng-click=
"switchSelect(cluster
, $event
)"
></td>
<td
width=
"30%"
ng-bind=
"cluster.env"
></td>
<td
width=
"60%"
ng-bind=
"cluster.name"
></td>
</tr>
...
...
application.pid
0 → 100644
浏览文件 @
eb37797f
19575
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录