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
5359d441
Commit
5359d441
authored
Jun 21, 2016
by
Jason Song
Committed by
GitHub
Jun 21, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #280 from lepdou/0620_27
多处细节优化
parents
b9813f17
f98b344c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
100 additions
and
80 deletions
+100
-80
AppController.java
...rip/framework/apollo/portal/controller/AppController.java
+1
-1
AppService.java
...com/ctrip/framework/apollo/portal/service/AppService.java
+2
-6
app.html
apollo-portal/src/main/resources/static/app.html
+9
-10
config.html
apollo-portal/src/main/resources/static/config.html
+2
-2
CreateAppController.js
...esources/static/scripts/controller/CreateAppController.js
+12
-2
ConfigNamespaceController.js
...tatic/scripts/controller/app/ConfigNamespaceController.js
+11
-0
AppRoleController.js
...urces/static/scripts/controller/role/AppRoleController.js
+62
-57
NamespaceRoleController.js
...static/scripts/controller/role/NamespaceRoleController.js
+0
-0
common-style.css
...-portal/src/main/resources/static/styles/common-style.css
+0
-1
ServiceExceptionTest.java
...m/ctrip/framework/apollo/portal/ServiceExceptionTest.java
+1
-1
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java
View file @
5359d441
...
...
@@ -77,7 +77,7 @@ public class AppController {
}
appService
.
enrichUserInfo
(
app
);
App
createdApp
=
appService
.
create
OrUpdateAppInLocal
(
app
);
App
createdApp
=
appService
.
create
(
app
);
publisher
.
publishEvent
(
new
AppCreationEvent
(
createdApp
));
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppService.java
View file @
5359d441
...
...
@@ -22,7 +22,6 @@ import com.ctrip.framework.apollo.core.exception.BadRequestException;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.auth.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo
;
import
com.ctrip.framework.apollo.portal.listener.AppCreationEvent
;
import
com.ctrip.framework.apollo.portal.repository.AppRepository
;
@Service
...
...
@@ -45,8 +44,6 @@ public class AppService {
@Autowired
private
AppRepository
appRepository
;
@Autowired
private
ApplicationEventPublisher
publisher
;
public
List
<
App
>
findAll
()
{
Iterable
<
App
>
apps
=
appRepository
.
findAll
();
...
...
@@ -87,13 +84,12 @@ public class AppService {
@Transactional
public
App
create
OrUpdateAppInLocal
(
App
app
)
{
public
App
create
(
App
app
)
{
String
appId
=
app
.
getAppId
();
App
managedApp
=
appRepository
.
findByAppId
(
appId
);
if
(
managedApp
!=
null
)
{
BeanUtils
.
copyEntityProperties
(
app
,
managedApp
);
return
appRepository
.
save
(
managedApp
);
throw
new
BadRequestException
(
String
.
format
(
"app id %s already exists!"
,
app
.
getAppId
()));
}
else
{
App
createdApp
=
appRepository
.
save
(
app
);
namespaceService
.
createDefaultAppNamespace
(
appId
);
...
...
apollo-portal/src/main/resources/static/app.html
View file @
5359d441
...
...
@@ -35,32 +35,31 @@
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用AppId
</label>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appAppId"
ng-model=
"app.appId"
required
>
required
>
<small>
(CMS上申请的App Id)
</small>
</div>
</div>
<div
class=
"form-group"
>
<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
>
<small>
(建议格式 xx-yy-zz 例:apollo-server)
</small>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用负责人
</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"
><apollorequiredfiled></apollorequiredfiled>
邮箱地址
</label>
<div
class=
"col-sm-4"
>
<input
type=
"email"
class=
"form-control"
ng-model=
"app.ownerEmail"
required
>
<div
class=
"col-sm-6"
>
<div
class=
"input-group"
>
<input
type=
"text"
class=
"form-control"
name=
"appOwner"
ng-model=
"app.ownerName"
required
>
<div
class=
"input-group-addon"
ng-bind=
"emailPostfix"
></div>
</div>
<small>
(负责人具有项目管理的最高权限,比如分配配置的修改权,发布权等)
</small>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-sm-offset-2 col-sm-10"
>
<button
type=
"submit"
class=
"btn btn-
default"
>
创建
</button>
<button
type=
"submit"
class=
"btn btn-
primary"
>
提交
</button>
</div>
</div>
</form>
...
...
apollo-portal/src/main/resources/static/config.html
View file @
5359d441
...
...
@@ -96,7 +96,7 @@
<div
class=
"row"
>
<div
class=
"col-md-2"
><img
src=
"img/user_manage.png"
class=
"i-20"
></div>
<div
class=
"col-md-10 hidden-xs"
>
<p
class=
"btn-title"
>
项目
管理员
</p>
<p
class=
"btn-title"
>
项目
负责人
</p>
</div>
</div>
</a>
...
...
@@ -365,7 +365,7 @@
apollo-detail=
"'确定要删除配置吗?'"
apollo-confirm=
"deleteItem"
></apolloconfirmdialog>
<apolloconfirmdialog
apollo-dialog-id=
"'releaseNoPermissionDialog'"
apollo-title=
"'发布'"
apollo-detail=
"'您没有发布权限哦~'"
apollo-detail=
"'您没有发布权限哦~
请找 ' + masterUsers + ' 分配权限
'"
apollo-show-cancel-btn=
"false"
></apolloconfirmdialog>
<!--create release modal-->
...
...
apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js
View file @
5359d441
create_app_module
.
controller
(
'CreateAppController'
,
[
'$scope'
,
'$window'
,
'toastr'
,
'AppService'
,
'AppUtil'
,
'OrganizationService'
,
function
(
$scope
,
$window
,
toastr
,
AppService
,
AppUtil
,
OrganizationService
)
{
create_app_module
.
controller
(
'CreateAppController'
,
[
'$scope'
,
'$window'
,
'toastr'
,
'AppService'
,
'
UserService'
,
'
AppUtil'
,
'OrganizationService'
,
function
(
$scope
,
$window
,
toastr
,
AppService
,
UserService
,
AppUtil
,
OrganizationService
)
{
OrganizationService
.
find_organizations
().
then
(
function
(
result
)
{
var
organizations
=
[];
...
...
@@ -19,6 +19,15 @@ create_app_module.controller('CreateAppController', ['$scope', '$window', 'toast
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"load organizations error"
);
});
$scope
.
app
=
{};
UserService
.
load_user
().
then
(
function
(
result
)
{
$scope
.
app
.
ownerName
=
result
.
userId
;
},
function
(
result
)
{
});
$scope
.
emailPostfix
=
"@ctrip.com"
;
$scope
.
create
=
function
()
{
var
selectedOrg
=
$
(
'#organization'
).
select2
(
'data'
)[
0
];
...
...
@@ -29,6 +38,7 @@ create_app_module.controller('CreateAppController', ['$scope', '$window', 'toast
$scope
.
app
.
orgId
=
selectedOrg
.
id
;
$scope
.
app
.
orgName
=
selectedOrg
.
name
;
$scope
.
app
.
ownerEmail
=
$scope
.
app
.
ownerName
+
$scope
.
emailPostfix
;
AppService
.
create
(
$scope
.
app
).
then
(
function
(
result
)
{
toastr
.
success
(
'添加成功!'
);
...
...
apollo-portal/src/main/resources/static/scripts/controller/app/ConfigNamespaceController.js
View file @
5359d441
...
...
@@ -66,6 +66,17 @@ application_module.controller("ConfigNamespaceController",
});
};
PermissionService
.
get_app_role_users
(
$rootScope
.
pageContext
.
appId
)
.
then
(
function
(
result
)
{
var
masterUsers
=
''
;
result
.
masterUsers
.
forEach
(
function
(
user
)
{
masterUsers
+=
user
.
userId
+
','
;
});
$scope
.
masterUsers
=
masterUsers
.
substring
(
0
,
masterUsers
.
length
-
1
);
},
function
(
result
)
{
});
$scope
.
switchView
=
function
(
namespace
,
viewType
)
{
if
(
namespace_view_type
.
TEXT
==
viewType
)
{
namespace
.
text
=
parseModel2Text
(
namespace
);
...
...
apollo-portal/src/main/resources/static/scripts/controller/role/AppRoleController.js
View file @
5359d441
role_module
.
controller
(
'AppRoleController'
,
[
'$scope'
,
'$location'
,
'$window'
,
'toastr'
,
'AppService'
,
'AppUtil'
,
'PermissionService'
,
function
(
$scope
,
$location
,
$window
,
toastr
,
AppService
,
AppUtil
,
PermissionService
)
{
var
params
=
AppUtil
.
parseParams
(
$location
.
$$url
);
$scope
.
pageContext
=
{
appId
:
params
.
appid
};
PermissionService
.
has_assign_user_permission
(
$scope
.
pageContext
.
appId
)
.
then
(
function
(
result
)
{
$scope
.
hasAssignUserPermission
=
result
.
hasPermission
;
},
function
(
reslt
)
{
});
PermissionService
.
get_app_role_users
(
$scope
.
pageContext
.
appId
)
.
then
(
function
(
result
)
{
$scope
.
appRoleUsers
=
result
;
},
function
(
result
)
{
});
$scope
.
toAssignMasterRoleUser
=
''
;
$scope
.
assignMasterRoleToUser
=
function
()
{
PermissionService
.
assign_master_role
(
$scope
.
pageContext
.
appId
,
$scope
.
toAssignMasterRoleUser
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"添加成功"
);
reloadPage
();
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"添加失败"
);
});
};
$scope
.
removeMasterRoleFromUser
=
function
(
user
)
{
if
(
$scope
.
appRoleUsers
.
masterUsers
.
length
<=
1
){
$
(
'#warning'
).
modal
(
'show'
);
return
;
}
PermissionService
.
remove_master_role
(
$scope
.
pageContext
.
appId
,
user
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"删除成功"
);
reloadPage
();
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"删除失败"
);
});
};
function
reloadPage
()
{
setInterval
(
function
()
{
location
.
reload
(
true
);
},
1000
);
}
}]);
role_module
.
controller
(
'AppRoleController'
,
[
'$scope'
,
'$location'
,
'$window'
,
'toastr'
,
'AppService'
,
'AppUtil'
,
'PermissionService'
,
function
(
$scope
,
$location
,
$window
,
toastr
,
AppService
,
AppUtil
,
PermissionService
)
{
var
params
=
AppUtil
.
parseParams
(
$location
.
$$url
);
$scope
.
pageContext
=
{
appId
:
params
.
appid
};
PermissionService
.
has_assign_user_permission
(
$scope
.
pageContext
.
appId
)
.
then
(
function
(
result
)
{
$scope
.
hasAssignUserPermission
=
result
.
hasPermission
;
},
function
(
reslt
)
{
});
PermissionService
.
get_app_role_users
(
$scope
.
pageContext
.
appId
)
.
then
(
function
(
result
)
{
$scope
.
appRoleUsers
=
result
;
},
function
(
result
)
{
});
$scope
.
toAssignMasterRoleUser
=
''
;
$scope
.
assignMasterRoleToUser
=
function
()
{
PermissionService
.
assign_master_role
(
$scope
.
pageContext
.
appId
,
$scope
.
toAssignMasterRoleUser
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"添加成功"
);
$scope
.
appRoleUsers
.
masterUsers
.
push
({
userId
:
$scope
.
toAssignMasterRoleUser
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"添加失败"
);
});
};
$scope
.
removeMasterRoleFromUser
=
function
(
user
)
{
if
(
$scope
.
appRoleUsers
.
masterUsers
.
length
<=
1
)
{
$
(
'#warning'
).
modal
(
'show'
);
return
;
}
PermissionService
.
remove_master_role
(
$scope
.
pageContext
.
appId
,
user
)
.
then
(
function
(
result
)
{
toastr
.
success
(
"删除成功"
);
removeUserFromList
(
$scope
.
appRoleUsers
.
masterUsers
,
user
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"删除失败"
);
});
};
function
removeUserFromList
(
list
,
user
)
{
var
index
=
0
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
if
(
list
[
i
].
userId
==
user
)
{
index
=
i
;
break
;
}
}
list
.
splice
(
index
,
1
);
}
}]);
apollo-portal/src/main/resources/static/scripts/controller/role/NamespaceRoleController.js
View file @
5359d441
This diff is collapsed.
Click to expand it.
apollo-portal/src/main/resources/static/styles/common-style.css
View file @
5359d441
...
...
@@ -127,7 +127,6 @@ table th {
.apps
.apps-description
{
color
:
gray
;
font-family
:
"Apple Color Emoji"
;
font-size
:
16px
;
}
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/ServiceExceptionTest.java
View file @
5359d441
...
...
@@ -61,7 +61,7 @@ public class ServiceExceptionTest extends AbstractPortalTest {
new
HttpServerErrorException
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
"admin server error"
,
new
Gson
().
toJson
(
errorAttributes
).
getBytes
(),
Charset
.
defaultCharset
());
when
(
appService
.
create
OrUpdateAppInLocal
(
any
(
App
.
class
))).
thenThrow
(
adminException
);
when
(
appService
.
create
(
any
(
App
.
class
))).
thenThrow
(
adminException
);
App
app
=
generateSampleApp
();
try
{
...
...
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