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
aad80f8a
Commit
aad80f8a
authored
Jul 27, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步配置优化
parent
77c489d9
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
197 additions
and
139 deletions
+197
-139
ItemController.java
...mework/apollo/adminservice/controller/ItemController.java
+1
-11
ItemRepository.java
...ctrip/framework/apollo/biz/repository/ItemRepository.java
+1
-0
ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+3
-3
ItemSetService.java
...om/ctrip/framework/apollo/biz/service/ItemSetService.java
+4
-2
ItemDTO.java
...ain/java/com/ctrip/framework/apollo/core/dto/ItemDTO.java
+0
-34
ItemController.java
...ip/framework/apollo/portal/controller/ItemController.java
+18
-4
NamespaceVO.java
.../ctrip/framework/apollo/portal/entity/vo/NamespaceVO.java
+10
-0
NamespaceService.java
...rip/framework/apollo/portal/service/NamespaceService.java
+4
-3
config.html
apollo-portal/src/main/resources/static/config.html
+2
-2
sync.html
apollo-portal/src/main/resources/static/config/sync.html
+37
-40
PageCommon.js
...lo-portal/src/main/resources/static/scripts/PageCommon.js
+17
-3
ConfigNamespaceController.js
...ic/scripts/controller/config/ConfigNamespaceController.js
+2
-15
SyncConfigController.js
.../static/scripts/controller/config/SyncConfigController.js
+82
-14
namespace-panel-directive.js
...ces/static/scripts/directive/namespace-panel-directive.js
+1
-1
ConfigService.js
...c/main/resources/static/scripts/services/ConfigService.js
+3
-2
common-style.css
...-portal/src/main/resources/static/styles/common-style.css
+5
-0
namespace-panel.html
...ain/resources/static/views/component/namespace-panel.html
+7
-5
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
View file @
aad80f8a
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -131,16 +130,7 @@ public class ItemController {
public
List
<
ItemDTO
>
findItems
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
List
<
Item
>
items
=
itemService
.
findItems
(
appId
,
clusterName
,
namespaceName
);
List
<
ItemDTO
>
itemDTOs
=
new
LinkedList
<>();
for
(
Item
item
:
items
)
{
ItemDTO
itemDTO
=
BeanUtils
.
transfrom
(
ItemDTO
.
class
,
item
);
itemDTO
.
setLastModifiedBy
(
item
.
getDataChangeLastModifiedBy
());
itemDTO
.
setLastModifiedTime
(
item
.
getDataChangeLastModifiedTime
());
itemDTOs
.
add
(
itemDTO
);
}
return
itemDTOs
;
return
BeanUtils
.
batchTransform
(
ItemDTO
.
class
,
itemService
.
findItems
(
appId
,
clusterName
,
namespaceName
));
}
@RequestMapping
(
"/items/{itemId}"
)
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ItemRepository.java
View file @
aad80f8a
...
...
@@ -13,4 +13,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
View file @
aad80f8a
...
...
@@ -83,10 +83,10 @@ public class ItemService {
}
public
List
<
Item
>
findItems
(
String
appId
,
String
clusterName
,
String
namespaceName
)
{
Namespace
group
=
namespaceRepository
.
findByAppIdAndClusterNameAndNamespaceName
(
appId
,
clusterName
,
Namespace
namespace
=
namespaceRepository
.
findByAppIdAndClusterNameAndNamespaceName
(
appId
,
clusterName
,
namespaceName
);
if
(
group
!=
null
)
{
return
findItems
(
group
.
getId
());
if
(
namespace
!=
null
)
{
return
findItems
(
namespace
.
getId
());
}
else
{
return
Collections
.
emptyList
();
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
View file @
aad80f8a
...
...
@@ -12,6 +12,7 @@ import com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.core.dto.ItemDTO
;
import
com.ctrip.framework.apollo.core.exception.NotFoundException
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
...
...
@@ -50,9 +51,10 @@ public class ItemSetService {
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
beforeUpdateItem
=
itemService
.
findOne
(
entity
.
getId
());
if
(
beforeUpdateItem
!=
null
)
{
beforeUpdateItem
=
BeanUtils
.
transfrom
(
Item
.
class
,
beforeUpdateItem
);
if
(
beforeUpdateItem
==
null
)
{
throw
new
NotFoundException
(
String
.
format
(
"item not found.(key=%s)"
,
entity
.
getKey
())
);
}
beforeUpdateItem
=
BeanUtils
.
transfrom
(
Item
.
class
,
beforeUpdateItem
);
entity
.
setDataChangeLastModifiedBy
(
operator
);
Item
updatedItem
=
itemService
.
update
(
entity
);
...
...
apollo-core/src/main/java/com/ctrip/framework/apollo/core/dto/ItemDTO.java
View file @
aad80f8a
package
com
.
ctrip
.
framework
.
apollo
.
core
.
dto
;
import
java.util.Date
;
public
class
ItemDTO
extends
BaseDTO
{
...
...
@@ -16,10 +15,6 @@ public class ItemDTO extends BaseDTO{
private
int
lineNum
;
private
String
lastModifiedBy
;
private
Date
lastModifiedTime
;
public
ItemDTO
()
{
}
...
...
@@ -79,33 +74,4 @@ public class ItemDTO extends BaseDTO{
this
.
lineNum
=
lineNum
;
}
public
String
getLastModifiedBy
()
{
return
lastModifiedBy
;
}
public
void
setLastModifiedBy
(
String
lastModifiedBy
)
{
this
.
lastModifiedBy
=
lastModifiedBy
;
}
public
Date
getLastModifiedTime
()
{
return
lastModifiedTime
;
}
public
void
setLastModifiedTime
(
Date
lastModifiedTime
)
{
this
.
lastModifiedTime
=
lastModifiedTime
;
}
@Override
public
String
toString
()
{
return
"ItemDTO{"
+
"id="
+
id
+
", namespaceId="
+
namespaceId
+
", key='"
+
key
+
'\''
+
", value='"
+
value
+
'\''
+
", comment='"
+
comment
+
'\''
+
", lineNum="
+
lineNum
+
", lastModifiedBy='"
+
lastModifiedBy
+
'\''
+
", lastModifiedTime="
+
lastModifiedTime
+
'}'
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/
Config
Controller.java
→
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/
Item
Controller.java
View file @
aad80f8a
...
...
@@ -17,15 +17,16 @@ 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
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Collections
;
import
java.util.List
;
import
static
com
.
ctrip
.
framework
.
apollo
.
common
.
utils
.
RequestPrecondition
.
checkModel
;
@RestController
@RequestMapping
(
""
)
public
class
ConfigController
{
public
class
ItemController
{
@Autowired
private
ConfigService
configService
;
...
...
@@ -83,9 +84,22 @@ public class ConfigController {
@RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items"
)
public
List
<
ItemDTO
>
findItems
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
){
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestParam
(
defaultValue
=
"lineNum"
)
String
orderBy
){
return
configService
.
findItems
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
List
<
ItemDTO
>
items
=
configService
.
findItems
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
if
(
"lastModifyTime"
.
equals
(
orderBy
)){
Collections
.
sort
(
items
,
(
o1
,
o2
)
->
{
if
(
o1
.
getDataChangeLastModifiedTime
().
after
(
o2
.
getDataChangeLastModifiedTime
())){
return
-
1
;
}
if
(
o1
.
getDataChangeLastModifiedTime
().
before
(
o2
.
getDataChangeLastModifiedTime
())){
return
1
;
}
return
0
;
});
}
return
items
;
}
@RequestMapping
(
value
=
"/namespaces/{namespaceName}/diff"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/NamespaceVO.java
View file @
aad80f8a
...
...
@@ -11,6 +11,7 @@ public class NamespaceVO {
private
String
format
;
private
boolean
isPublic
;
private
String
parentAppId
;
private
String
comment
;
public
NamespaceDTO
getBaseInfo
()
{
...
...
@@ -61,6 +62,14 @@ public class NamespaceVO {
this
.
parentAppId
=
parentAppId
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
public
static
class
ItemVO
{
private
ItemDTO
item
;
private
boolean
isModified
;
...
...
@@ -109,6 +118,7 @@ public class NamespaceVO {
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
View file @
aad80f8a
...
...
@@ -91,7 +91,7 @@ public class NamespaceService {
NamespaceVO
namespaceVO
=
new
NamespaceVO
();
namespaceVO
.
setBaseInfo
(
namespace
);
fill
FormatAndIsPublicAndParentAppField
(
namespaceVO
);
fill
AppNamespaceProperties
(
namespaceVO
);
List
<
NamespaceVO
.
ItemVO
>
itemVos
=
new
LinkedList
<>();
namespaceVO
.
setItems
(
itemVos
);
...
...
@@ -130,7 +130,7 @@ public class NamespaceService {
return
namespaceVO
;
}
private
void
fill
FormatAndIsPublicAndParentAppField
(
NamespaceVO
namespace
)
{
private
void
fill
AppNamespaceProperties
(
NamespaceVO
namespace
)
{
NamespaceDTO
namespaceDTO
=
namespace
.
getBaseInfo
();
//先从当前appId下面找,包含私有的和公共的
...
...
@@ -140,6 +140,7 @@ public class NamespaceService {
if
(
appNamespace
==
null
)
{
appNamespace
=
appNamespaceService
.
findPublicAppNamespace
(
namespaceDTO
.
getNamespaceName
());
}
String
format
;
boolean
isPublic
;
if
(
appNamespace
==
null
)
{
...
...
@@ -149,10 +150,10 @@ public class NamespaceService {
format
=
appNamespace
.
getFormat
();
isPublic
=
appNamespace
.
isPublic
();
namespace
.
setParentAppId
(
appNamespace
.
getAppId
());
namespace
.
setComment
(
appNamespace
.
getComment
());
}
namespace
.
setFormat
(
format
);
namespace
.
setPublic
(
isPublic
);
}
private
List
<
NamespaceVO
.
ItemVO
>
parseDeletedItems
(
List
<
ItemDTO
>
newItems
,
Map
<
String
,
String
>
releaseItems
)
{
...
...
apollo-portal/src/main/resources/static/config.html
View file @
aad80f8a
...
...
@@ -178,10 +178,10 @@
<span
ng-bind=
"config.newValue | limitTo: 250"
></span>
<span
ng-bind=
"config.newValue.length > 250 ? '...': ''"
></span>
</td>
<td
width=
"15%"
ng-bind=
"config.item.
l
astModifiedBy"
>
<td
width=
"15%"
ng-bind=
"config.item.
dataChangeL
astModifiedBy"
>
</td>
<td
width=
"15%"
ng-bind=
"config.item.
l
astModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'"
>
ng-bind=
"config.item.
dataChangeL
astModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'"
>
</td>
</tr>
</tbody>
...
...
apollo-portal/src/main/resources/static/config/sync.html
View file @
aad80f8a
...
...
@@ -105,59 +105,56 @@
</div>
<!--step 2-->
<div
class=
"row"
ng-show=
"syncItemStep == 2"
ng-repeat=
"
diff in d
iffs"
>
<div
class=
"row"
ng-show=
"syncItemStep == 2"
ng-repeat=
"
clusterDiff in clusterD
iffs"
>
<h5
class=
"text-center"
>
环境:
<span
ng-bind=
"
d
iff.namespace.env"
></span>
集群:
<span
ng-bind=
"
d
iff.namespace.clusterName"
></span>
<span
ng-show=
"!
d
iff.extInfo"
>
Namespace:{{pageContext.namespaceName}}
</span>
环境:
<span
ng-bind=
"
clusterD
iff.namespace.env"
></span>
集群:
<span
ng-bind=
"
clusterD
iff.namespace.clusterName"
></span>
<span
ng-show=
"!
clusterD
iff.extInfo"
>
Namespace:{{pageContext.namespaceName}}
</span>
</h5>
<div
class=
"text-center"
ng-show=
"diff.diffs.createItems.length + diff.diffs.updateItems.length == 0 || diff.extInfo"
>
<font
ng-show=
"diff.diffs.createItems.length + diff.diffs.updateItems.length == 0 && !diff.extInfo"
>
没有更新的配置
</font>
<font
ng-show=
"diff.extInfo"
ng-bind=
"diff.extInfo"
></font>
<div
class=
"text-center"
ng-show=
"clusterDiff.diffs.createItems.length + clusterDiff.diffs.updateItems.length == 0 || clusterDiff.extInfo"
>
<span
ng-show=
"clusterDiff.diffs.createItems.length + clusterDiff.diffs.updateItems.length == 0 && !clusterDiff.extInfo"
>
没有更新的配置
</span>
<span
ng-show=
"clusterDiff.extInfo"
ng-bind=
"clusterDiff.extInfo"
></span>
,忽略同步
</div>
<div
class=
"row"
style=
"margin-top: 10px;"
ng-show=
"diff.diffs.createItems.length > 0"
>
<div
class=
"row"
style=
"margin-top: 10px;"
ng-show=
"clusterDiff.diffs.updateItems.length + clusterDiff.diffs.createItems.length > 0"
>
<div
class=
"form-horizontal"
>
<label
class=
"col-sm-2 control-label"
>
新增的配置
</label>
<div
class=
"col-sm-9"
>
<div
class=
"col-sm-12"
>
<table
class=
"table table-bordered table-striped table-hover"
>
<thead>
<tr>
<td>
key
</td>
<td>
value
</td>
<td>
comment
</td>
<td>
Type
</td>
<td>
Key
</td>
<td>
同步前
</td>
<td>
同步后
</td>
<td>
Comment
</td>
<td>
操作
</td>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"createItem in diff.diffs.createItems"
>
<td
width=
"30%"
ng-bind=
"createItem.key"
></td>
<td
width=
"40%"
ng-bind=
"createItem.value"
></td>
<td
width=
"30%"
ng-bind=
"createItem.comment"
></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div
class=
"row"
style=
"margin-top: 10px;"
ng-show=
"diff.diffs.updateItems.length > 0"
>
<div
class=
"form-horizontal"
>
<label
class=
"col-sm-2 control-label"
>
修改的配置
</label>
<div
class=
"col-sm-9"
>
<table
class=
"table table-bordered table-striped table-hover"
>
<thead>
<tr>
<td>
key
</td>
<td>
value
</td>
<td>
comment
</td>
<tr
ng-repeat=
"createItem in clusterDiff.diffs.createItems"
>
<td
width=
"5%"
>
新增
</td>
<td
width=
"15%"
ng-bind=
"createItem.key"
></td>
<td
width=
"30%"
></td>
<td
width=
"30%"
ng-bind=
"createItem.value"
></td>
<td
width=
"15%"
ng-bind=
"createItem.comment"
></td>
<td
width=
"5%"
>
<a
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"不同步该配置"
ng-click=
"removeItem(clusterDiff.diffs, 'create', createItem)"
>
删除
</a>
</td>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"updateItem in diff.diffs.updateItems"
>
<td
width=
"30%"
ng-bind=
"updateItem.key"
></td>
<td
width=
"40%"
ng-bind=
"updateItem.value"
></td>
<td
width=
"30%"
ng-bind=
"updateItem.comment"
></td>
<tr
ng-repeat=
"updateItem in clusterDiff.diffs.updateItems"
>
<td
width=
"5%"
>
更新
</td>
<td
width=
"15%"
ng-bind=
"updateItem.key"
></td>
<td
width=
"30%"
ng-bind=
"updateItem.oldValue"
></td>
<td
width=
"30%"
ng-bind=
"updateItem.value"
></td>
<td
width=
"15%"
ng-bind=
"updateItem.comment"
></td>
<td
width=
"5%"
>
<a
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"不同步该配置"
ng-click=
"removeItem(clusterDiff.diffs, 'update', updateItem)"
>
删除
</a>
</td>
</tr>
</tbody>
</table>
...
...
apollo-portal/src/main/resources/static/scripts/PageCommon.js
View file @
aad80f8a
$
(
document
).
ready
(
function
()
{
// nicescroll
$
(
"html"
).
niceScroll
({
styler
:
"fb"
,
cursorcolor
:
"#e8403f"
,
...
...
@@ -9,12 +11,24 @@ $(document).ready(function () {
cursorborder
:
''
,
zindex
:
'1000'
});
});
$
(
function
()
{
$
(
'[data-toggle="tooltip"]'
).
tooltip
()
// bootstrap tooltip
setInterval
(
function
()
{
$
(
'[data-tooltip="tooltip"]'
).
tooltip
();
$
(
'html'
).
bind
(
'mousewheel DOMMouseScroll'
,
function
(
e
)
{
var
e0
=
e
.
originalEvent
,
delta
=
e0
.
wheelDelta
||
-
e0
.
detail
;
this
.
scrollTop
+=
(
delta
<
0
?
1
:
-
1
)
*
30
;
e
.
preventDefault
();
});
},
2500
);
});
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
Date
.
prototype
.
Format
=
function
(
fmt
)
{
...
...
apollo-portal/src/main/resources/static/scripts/controller/config/ConfigNamespaceController.js
View file @
aad80f8a
...
...
@@ -73,26 +73,13 @@ application_module.controller("ConfigNamespaceController",
$rootScope
.
pageContext
.
clusterName
,
viewType
).
then
(
function
(
result
)
{
$scope
.
namespaces
=
result
;
setInterval
(
function
()
{
$
(
'[data-tooltip="tooltip"]'
).
tooltip
();
$
(
'.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
);
$scope
.
namespaces
=
result
;
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"加载配置信息出错"
);
});
}
;
}
function
commitChange
(
namespace
)
{
var
model
=
{
...
...
apollo-portal/src/main/resources/static/scripts/controller/config/SyncConfigController.js
View file @
aad80f8a
...
...
@@ -10,16 +10,18 @@ sync_item_module.controller("SyncItemController",
namespaceName
:
params
.
namespaceName
};
$scope
.
syncBtnDisabled
=
false
;
////// load items //////
ConfigService
.
find_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
$scope
.
pageContext
.
clusterName
,
$scope
.
pageContext
.
namespaceName
).
then
(
function
(
result
)
{
$scope
.
pageContext
.
clusterName
,
$scope
.
pageContext
.
namespaceName
,
"lastModifyTime"
)
.
then
(
function
(
result
)
{
$scope
.
sourceItems
=
[];
result
.
forEach
(
function
(
item
)
{
if
(
item
.
key
)
{
if
(
item
.
key
)
{
item
.
checked
=
false
;
$scope
.
sourceItems
.
push
(
item
);
}
...
...
@@ -37,15 +39,50 @@ sync_item_module.controller("SyncItemController",
})
};
var
syncData
=
{
syncToNamespaces
:
[],
syncItems
:
[]
};
$scope
.
diff
=
function
()
{
parseSyncSourceData
();
if
(
syncData
.
syncItems
.
length
==
0
)
{
toastr
.
warning
(
"请选择需要同步的配置"
);
return
;
}
if
(
syncData
.
syncToNamespaces
.
length
==
0
)
{
toastr
.
warning
(
"请选择集群"
);
return
;
}
$scope
.
hasDiff
=
false
;
ConfigService
.
diff
(
$scope
.
pageContext
.
namespaceName
,
parseSyncSourceData
()).
then
(
function
(
result
)
{
ConfigService
.
diff
(
$scope
.
pageContext
.
namespaceName
,
syncData
).
then
(
function
(
result
)
{
$scope
.
clusterDiffs
=
result
;
$scope
.
diffs
=
result
;
result
.
forEach
(
function
(
diff
)
{
$scope
.
clusterDiffs
.
forEach
(
function
(
clusterDiff
)
{
if
(
!
$scope
.
hasDiff
)
{
$scope
.
hasDiff
=
diff
.
diffs
.
createItems
.
length
+
diff
.
diffs
.
updateItems
.
length
>
0
;
$scope
.
hasDiff
=
clusterDiff
.
diffs
.
createItems
.
length
+
clusterDiff
.
diffs
.
updateItems
.
length
>
0
;
}
if
(
clusterDiff
.
diffs
.
updateItems
.
length
>
0
){
//赋予同步前的值
ConfigService
.
find_items
(
clusterDiff
.
namespace
.
appId
,
clusterDiff
.
namespace
.
env
,
clusterDiff
.
namespace
.
clusterName
,
clusterDiff
.
namespace
.
namespaceName
)
.
then
(
function
(
result
)
{
var
oldItemMap
=
{};
result
.
forEach
(
function
(
item
)
{
oldItemMap
[
item
.
key
]
=
item
.
value
;
});
clusterDiff
.
diffs
.
updateItems
.
forEach
(
function
(
item
)
{
item
.
oldValue
=
oldItemMap
[
item
.
key
];
})
});
}
});
$scope
.
syncItemNextStep
(
1
);
},
function
(
result
)
{
...
...
@@ -53,11 +90,39 @@ sync_item_module.controller("SyncItemController",
});
};
$scope
.
removeItem
=
function
(
diff
,
type
,
toRemoveItem
)
{
var
syncDataResult
=
[],
diffSetResult
=
[],
diffSet
;
if
(
type
==
'create'
)
{
diffSet
=
diff
.
createItems
;
}
else
{
diffSet
=
diff
.
updateItems
;
}
diffSet
.
forEach
(
function
(
item
)
{
if
(
item
.
key
!=
toRemoveItem
.
key
)
{
diffSetResult
.
push
(
item
);
}
});
if
(
type
==
'create'
)
{
diff
.
createItems
=
diffSetResult
;
}
else
{
diff
.
updateItems
=
diffSetResult
;
}
syncData
.
syncItems
.
forEach
(
function
(
item
)
{
if
(
item
.
key
!=
toRemoveItem
.
key
)
{
syncDataResult
.
push
(
item
);
}
});
syncData
.
syncItems
=
syncDataResult
;
};
$scope
.
syncItems
=
function
()
{
$scope
.
syncBtnDisabled
=
true
;
ConfigService
.
sync_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
namespaceName
,
parseSyncSourceData
()
).
then
(
function
(
result
)
{
syncData
).
then
(
function
(
result
)
{
$scope
.
syncItemStep
+=
1
;
$scope
.
syncSuccess
=
true
;
$scope
.
syncBtnDisabled
=
false
;
...
...
@@ -74,24 +139,25 @@ sync_item_module.controller("SyncItemController",
};
function
parseSyncSourceData
()
{
var
source
Data
=
{
sync
Data
=
{
syncToNamespaces
:
[],
syncItems
:
[]
};
var
namespaceName
=
$scope
.
pageContext
.
namespaceName
;
selectedClusters
.
forEach
(
function
(
cluster
)
{
if
(
cluster
.
checked
)
{
if
(
cluster
.
checked
)
{
cluster
.
clusterName
=
cluster
.
name
;
cluster
.
namespaceName
=
namespaceName
;
source
Data
.
syncToNamespaces
.
push
(
cluster
);
sync
Data
.
syncToNamespaces
.
push
(
cluster
);
}
});
$scope
.
sourceItems
.
forEach
(
function
(
item
)
{
if
(
item
.
checked
)
{
source
Data
.
syncItems
.
push
(
item
);
sync
Data
.
syncItems
.
push
(
item
);
}
});
return
source
Data
;
return
sync
Data
;
}
////// flow control ///////
...
...
@@ -107,6 +173,8 @@ sync_item_module.controller("SyncItemController",
$scope
.
switchSelect
=
function
(
o
)
{
o
.
checked
=
!
o
.
checked
;
}
};
}]);
apollo-portal/src/main/resources/static/scripts/directive/namespace-panel-directive.js
View file @
aad80f8a
...
...
@@ -215,7 +215,7 @@ directive_module.directive('apollonspanel',
var
itemCnt
=
0
;
namespace
.
items
.
forEach
(
function
(
item
)
{
//deleted key
if
(
!
item
.
item
.
l
astModifiedBy
)
{
if
(
!
item
.
item
.
dataChangeL
astModifiedBy
)
{
return
;
}
if
(
item
.
item
.
key
)
{
...
...
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
View file @
aad80f8a
...
...
@@ -53,13 +53,14 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
return
d
.
promise
;
},
find_items
:
function
(
appId
,
env
,
clusterName
,
namespaceName
)
{
find_items
:
function
(
appId
,
env
,
clusterName
,
namespaceName
,
orderBy
)
{
var
d
=
$q
.
defer
();
config_source
.
find_items
({
appId
:
appId
,
env
:
env
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
namespaceName
:
namespaceName
,
orderBy
:
orderBy
},
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
...
...
apollo-portal/src/main/resources/static/styles/common-style.css
View file @
aad80f8a
...
...
@@ -25,6 +25,10 @@ p, td, span {
word-break
:
break-all
;
}
table
{
text-align
:
center
;
}
.no-radius
{
border-radius
:
0px
;
}
...
...
@@ -359,6 +363,7 @@ table th {
height
:
200px
;
position
:
absolute
;
margin-left
:
0px
;
cursor
:
pointer
;
background
:
#ffffff
;
border
:
1px
solid
#ddd
;
overflow-y
:
scroll
;
...
...
apollo-portal/src/main/resources/static/views/component/namespace-panel.html
View file @
aad80f8a
<div
class=
"panel"
style=
"border-top: 0px;"
>
<div
class=
"row namespace-attribute-panel"
ng-if=
"namespace.isPublic"
>
<div
class=
"text-center namespace-attribute-public"
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"点击跳转到公共Namespace"
ng-click=
"goToParentAppConfigPage(namespace)"
>
title=
"点击跳转到公共Namespace"
>
<span
ng-show=
"namespace.parentAppId == namespace.baseInfo.appId"
>
公共
</span>
<span
ng-show=
"namespace.parentAppId != namespace.baseInfo.appId"
>
关联
</span>
<span
ng-show=
"namespace.parentAppId != namespace.baseInfo.appId"
ng-click=
"goToParentAppConfigPage(namespace)"
>
关联
</span>
</div>
</div>
<header
class=
"panel-heading"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<b
ng-bind=
"namespace.viewName"
style=
"font-size: 20px;"
></b>
<b
ng-bind=
"namespace.viewName"
style=
"font-size: 20px;"
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"{{namespace.comment}}"
></b>
<span
class=
"label label-info no-radius"
ng-bind=
"namespace.format"
></span>
<span
class=
"label label-primary no-radius"
ng-show=
"namespace.itemModifiedCnt > 0"
>
有修改
<span
class=
"badge label"
ng-bind=
"namespace.itemModifiedCnt"
></span></span>
...
...
@@ -168,10 +170,10 @@
<span
ng-bind=
"config.item.comment | limitTo: 250"
></span>
<span
ng-bind=
"config.item.comment.length > 250 ?'...' : ''"
></span>
</td>
<td
width=
"10%"
ng-bind=
"config.item.
l
astModifiedBy"
>
<td
width=
"10%"
ng-bind=
"config.item.
dataChangeL
astModifiedBy"
>
</td>
<td
width=
"15%"
ng-bind=
"config.item.
l
astModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'"
>
ng-bind=
"config.item.
dataChangeL
astModifiedTime | date: 'yyyy-MM-dd HH:mm:ss'"
>
</td>
<td
width=
"10%"
>
...
...
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