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
6aaa2773
Commit
6aaa2773
authored
May 20, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
table view cru
parent
0b3ace80
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
147 additions
and
33 deletions
+147
-33
ItemController.java
...mework/apollo/adminservice/controller/ItemController.java
+7
-0
ItemRepository.java
...ctrip/framework/apollo/biz/repository/ItemRepository.java
+1
-0
ItemService.java
...a/com/ctrip/framework/apollo/biz/service/ItemService.java
+11
-0
AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+6
-0
PortalConfigController.java
...work/apollo/portal/controller/PortalConfigController.java
+35
-5
PortalConfigService.java
.../framework/apollo/portal/service/PortalConfigService.java
+5
-0
app.html
apollo-portal/src/main/resources/static/app.html
+4
-4
config.html
apollo-portal/src/main/resources/static/config.html
+0
-0
sync.html
apollo-portal/src/main/resources/static/config/sync.html
+1
-1
ConfigNamespaceController.js
...tatic/scripts/controller/app/ConfigNamespaceController.js
+0
-0
directive.js
apollo-portal/src/main/resources/static/scripts/directive.js
+23
-8
ConfigService.js
...c/main/resources/static/scripts/services/ConfigService.js
+43
-5
common-style.css
...-portal/src/main/resources/static/styles/common-style.css
+6
-7
env-selector.html
...c/main/resources/static/views/component/env-selector.html
+3
-3
application.pid
application.pid
+2
-0
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
This diff is collapsed.
Click to expand it.
apollo-portal/src/main/resources/static/config/sync.html
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
This diff is collapsed.
Click to expand it.
apollo-portal/src/main/resources/static/scripts/directive.js
View file @
6aaa2773
/** 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
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
...
...
@@ -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
View file @
6aaa2773
<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
View file @
6aaa2773
19575
\ No newline at end of file
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