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
83ae4032
Commit
83ae4032
authored
Jul 28, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rollback 优化
parent
4d79b4f7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
113 additions
and
52 deletions
+113
-52
ReleaseCompareResult.java
...amework/apollo/portal/entity/vo/ReleaseCompareResult.java
+37
-6
ReleaseService.java
...ctrip/framework/apollo/portal/service/ReleaseService.java
+10
-3
config.html
apollo-portal/src/main/resources/static/config.html
+52
-21
PageCommon.js
...lo-portal/src/main/resources/static/scripts/PageCommon.js
+3
-11
ConfigNamespaceController.js
...ic/scripts/controller/config/ConfigNamespaceController.js
+9
-9
namespace-panel-directive.js
...ces/static/scripts/directive/namespace-panel-directive.js
+1
-1
namespace-panel.html
...ain/resources/static/views/component/namespace-panel.html
+1
-1
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java
View file @
83ae4032
...
...
@@ -5,18 +5,49 @@ import java.util.List;
public
class
ReleaseCompareResult
{
private
List
<
EntityPair
<
KVEntity
>
>
changes
=
new
LinkedList
<>();
private
List
<
Change
>
changes
=
new
LinkedList
<>();
public
void
addEntityPair
(
KVEntity
firstEntity
,
KVEntity
secondEntity
)
{
changes
.
add
(
new
EntityPair
<>(
firstEntity
,
secondEntity
));
public
void
addEntityPair
(
ChangeType
type
,
KVEntity
firstEntity
,
KVEntity
secondEntity
)
{
changes
.
add
(
new
Change
(
type
,
new
EntityPair
<>(
firstEntity
,
secondEntity
)
));
}
public
List
<
EntityPair
<
KVEntity
>
>
getChanges
()
{
public
List
<
Change
>
getChanges
()
{
return
changes
;
}
public
void
setChanges
(
List
<
EntityPair
<
KVEntity
>>
changes
)
{
public
void
setChanges
(
List
<
Change
>
changes
)
{
this
.
changes
=
changes
;
}
public
class
Change
{
private
ChangeType
type
;
private
EntityPair
<
KVEntity
>
entity
;
public
Change
(
ChangeType
type
,
EntityPair
<
KVEntity
>
entity
)
{
this
.
type
=
type
;
this
.
entity
=
entity
;
}
public
ChangeType
getType
()
{
return
type
;
}
public
void
setType
(
ChangeType
type
)
{
this
.
type
=
type
;
}
public
EntityPair
<
KVEntity
>
getEntity
()
{
return
entity
;
}
public
void
setEntity
(
EntityPair
<
KVEntity
>
entity
)
{
this
.
entity
=
entity
;
}
}
public
enum
ChangeType
{
ADD
,
MODIFY
,
DELETE
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java
View file @
83ae4032
...
...
@@ -98,9 +98,15 @@ public class ReleaseService {
String
key
=
entry
.
getKey
();
String
firstValue
=
entry
.
getValue
();
String
secondValue
=
secondItems
.
get
(
key
);
if
(!
Objects
.
equal
(
firstValue
,
secondValue
))
{
compareResult
.
addEntityPair
(
new
KVEntity
(
key
,
firstValue
),
new
KVEntity
(
key
,
secondValue
));
//added
if
(
secondValue
==
null
)
{
compareResult
.
addEntityPair
(
ReleaseCompareResult
.
ChangeType
.
DELETE
,
new
KVEntity
(
key
,
firstValue
),
new
KVEntity
(
key
,
secondValue
));
}
else
if
(!
Objects
.
equal
(
firstValue
,
secondValue
))
{
compareResult
.
addEntityPair
(
ReleaseCompareResult
.
ChangeType
.
MODIFY
,
new
KVEntity
(
key
,
firstValue
),
new
KVEntity
(
key
,
secondValue
));
}
}
//deleted in firstRelease
...
...
@@ -108,7 +114,8 @@ public class ReleaseService {
String
key
=
entry
.
getKey
();
String
value
=
entry
.
getValue
();
if
(
firstItems
.
get
(
key
)
==
null
)
{
compareResult
.
addEntityPair
(
new
KVEntity
(
key
,
""
),
new
KVEntity
(
key
,
value
));
compareResult
.
addEntityPair
(
ReleaseCompareResult
.
ChangeType
.
ADD
,
new
KVEntity
(
key
,
""
),
new
KVEntity
(
key
,
value
));
}
}
...
...
apollo-portal/src/main/resources/static/config.html
View file @
83ae4032
...
...
@@ -97,7 +97,7 @@
pre-release-ns=
"prepareReleaseNamespace"
create-item=
"createItem"
edit-item=
"editItem"
pre-delete-item=
"preDeleteItem"
commit-change=
"commitChange"
show-rollback-tips=
"showRollbackTips
"
></apollonspanel>
pre-rollback=
"preRollback
"
></apollonspanel>
</div>
<!-- delete modal-->
...
...
@@ -116,9 +116,9 @@
apollo-detail=
"'您不能发布哟~ 编辑和发布不能为同一个人'"
apollo-show-cancel-btn=
"false"
></apolloconfirmdialog>
<apolloconfirmdialog
apollo-dialog-id=
"'rollback
Tips
'"
apollo-title=
"'回滚'"
apollo-detail=
"'
此操作将会回滚到上一个发布版本,且作废当前版本。
确定要回滚吗?'"
apollo-show-cancel-btn=
"true"
apollo-confirm=
"
preR
ollback"
></apolloconfirmdialog>
<apolloconfirmdialog
apollo-dialog-id=
"'rollback
AlertDialog
'"
apollo-title=
"'回滚'"
apollo-detail=
"'确定要回滚吗?'"
apollo-show-cancel-btn=
"true"
apollo-confirm=
"
r
ollback"
></apolloconfirmdialog>
<!--create createRelease modal-->
...
...
@@ -325,29 +325,37 @@
<!--rollback-->
<form
class=
"modal fade form-horizontal"
id=
"rollbackModal"
tabindex=
"-1"
role=
"dialog"
ng-submit=
"
rollback
()"
>
ng-submit=
"
showRollbackAlertDialog
()"
>
<div
class=
"modal-dialog"
role=
"document"
style=
"width: 960px"
>
<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>
</div>
<div
class=
"modal-body"
>
<div
class=
"row text-center"
>
<div
class=
"modal-title text-center"
>
<span
style=
"font-size: 18px;"
ng-bind=
"firstRelease.name"
></span>
<span
style=
"font-size: 18px;"
>
回滚到
</span>
<span
style=
"font-size: 18px;"
ng-bind=
"secondRelease.name"
></span>
</div>
</div>
<div
class=
"modal-body"
>
<div
class=
"alert alert-warning"
role=
"alert"
>
此操作将会回滚到上一个发布版本,且当前版本作废,但不影响正在修改的配置。可在发布历史页面查看当前生效的版本
<a
target=
"_blank"
href=
"/config/history.html?#/appid={{toRollbackNamespace.baseInfo.appId}}&env={{pageContext.env}}&clusterName={{toRollbackNamespace.baseInfo.clusterName}}&namespaceName={{toRollbackNamespace.baseInfo.namespaceName}}"
>
点击查看
</a>
</div>
<div
class=
"form-group"
style=
"margin-top: 15px;"
>
<label
class=
"col-sm-2 control-label"
>
Changes:
</label>
<div
class=
"col-sm-10"
ng-if=
"releaseCompareResult.length > 0"
>
<table
class=
"table table-bordered table-striped text-center table-hover"
>
<!--properties format-->
<div
class=
"col-sm-12"
ng-if=
"releaseCompareResult.length > 0 && toRollbackNamespace.isPropertiesFormat"
>
<table
class=
"table table-bordered table-striped text-center table-hover"
ng-if=
"toRollbackNamespace.isPropertiesFormat"
>
<thead>
<tr>
<th>
Type
</th>
<th>
Key
</th>
<th>
...
...
@@ -360,22 +368,45 @@
</thead>
<tbody>
<tr
ng-repeat=
"pair in releaseCompareResult"
>
<td
width=
"20%"
ng-bind=
"pair.firstEntity.key"
>
<tr
ng-repeat=
"change in releaseCompareResult"
>
<td
width=
"10%"
>
<span
ng-show=
"change.type == 'ADD'"
>
新增
</span>
<span
ng-show=
"change.type == 'MODIFY'"
>
更新
</span>
<span
ng-show=
"change.type == 'DELETE'"
>
删除
</span>
</td>
<td
width=
"20%"
ng-bind=
"change.entity.firstEntity.key"
>
</td>
<td
width=
"
40%"
ng-bind=
"pair
.firstEntity.value"
>
<td
width=
"
35%"
ng-bind=
"change.entity
.firstEntity.value"
>
</td>
<td
width=
"
40%"
ng-bind=
"pair
.secondEntity.value"
>
<td
width=
"
35%"
ng-bind=
"change.entity
.secondEntity.value"
>
</td>
</tr>
</tbody>
</table>
</div>
<div
class=
"col-sm-5"
>
<span
ng-if=
"releaseCompareResult.length == 0"
>
<!--file format -->
<div
class=
"col-sm-12"
ng-if=
"releaseCompareResult.length > 0 && !toRollbackNamespace.isPropertiesFormat"
>
<div
ng-repeat=
"change in releaseCompareResult"
ng-if=
"!toRollbackNamespace.isPropertiesFormat"
>
<h5>
回滚前
</h5>
<textarea
class=
"form-control no-radius"
rows=
"20"
ng-disabled=
"true"
ng-bind=
"change.entity.firstEntity.value"
>
</textarea>
<hr>
<h5>
回滚后
</h5>
<textarea
class=
"form-control no-radius"
rows=
"20"
ng-disabled=
"true"
ng-bind=
"change.entity.secondEntity.value"
>
</textarea>
</div>
</div>
<div
class=
"col-sm-12 text-center"
ng-if=
"releaseCompareResult.length == 0"
>
<h4>
配置没有变化
</
span
>
</
h4
>
</div>
</div>
...
...
@@ -384,7 +415,7 @@
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
取消
</button>
<button
type=
"submit"
class=
"btn btn-danger"
ng-if=
"releaseCompareResult.length > 0"
ng-disabled=
"rollbackBtnDisabled"
>
确定
回滚
ng-disabled=
"rollbackBtnDisabled"
>
回滚
</button>
</div>
</div>
...
...
apollo-portal/src/main/resources/static/scripts/PageCommon.js
View file @
83ae4032
...
...
@@ -12,23 +12,15 @@ $(document).ready(function () {
zindex
:
'1000'
});
// bootstrap tooltip
// bootstrap tooltip
& textarea scroll
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
();
});
$
(
"textarea"
).
niceScroll
({
styler
:
"fb"
,
cursorcolor
:
"#fff"
});
},
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 @
83ae4032
...
...
@@ -26,7 +26,7 @@ application_module.controller("ConfigNamespaceController",
$scope
.
release
=
release
;
$scope
.
showRollback
Tips
=
showRollbackTips
;
$scope
.
showRollback
AlertDialog
=
showRollbackAlertDialog
;
$scope
.
preRollback
=
preRollback
;
...
...
@@ -152,21 +152,20 @@ application_module.controller("ConfigNamespaceController",
);
}
var
toRollbackNamespace
=
{};
function
showRollbackTips
(
namespace
)
{
toRollbackNamespace
=
namespace
;
$
(
"#rollbackTips"
).
modal
(
'show'
);
function
showRollbackAlertDialog
()
{
$
(
"#rollbackModal"
).
modal
(
'hide'
);
$
(
"#rollbackAlertDialog"
).
modal
(
'show'
);
}
function
preRollback
()
{
$scope
.
toRollbackNamespace
=
{};
function
preRollback
(
namespace
)
{
$scope
.
toRollbackNamespace
=
namespace
;
//load latest two active releases
ReleaseService
.
findActiveRelease
(
$rootScope
.
pageContext
.
appId
,
$rootScope
.
pageContext
.
env
,
$rootScope
.
pageContext
.
clusterName
,
toRollbackNamespace
.
baseInfo
.
namespaceName
,
0
,
2
)
$scope
.
toRollbackNamespace
.
baseInfo
.
namespaceName
,
0
,
2
)
.
then
(
function
(
result
)
{
if
(
result
.
length
<=
1
)
{
toastr
.
error
(
"没有可以回滚的发布历史"
);
...
...
@@ -180,6 +179,7 @@ application_module.controller("ConfigNamespaceController",
$scope
.
secondRelease
.
id
)
.
then
(
function
(
result
)
{
$scope
.
releaseCompareResult
=
result
.
changes
;
$
(
"#rollbackModal"
).
modal
(
'show'
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"对比失败"
);
...
...
apollo-portal/src/main/resources/static/scripts/directive/namespace-panel-directive.js
View file @
83ae4032
...
...
@@ -12,7 +12,7 @@ directive_module.directive('apollonspanel',
env
:
'='
,
cluster
:
'='
,
preReleaseNs
:
'='
,
showRollbackTips
:
'='
,
preRollback
:
'='
,
createItem
:
'='
,
editItem
:
'='
,
preDeleteItem
:
'='
,
...
...
apollo-portal/src/main/resources/static/views/component/namespace-panel.html
View file @
83ae4032
...
...
@@ -33,7 +33,7 @@
<button
type=
"button"
class=
"btn btn-default btn-sm J_tableview_btn"
ng-show=
"namespace.hasReleasePermission"
ng-click=
"
showRollbackTips
(namespace)"
>
ng-click=
"
preRollback
(namespace)"
>
<img
src=
"img/rollback.png"
>
回滚
</button>
...
...
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