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
cd55a0dd
Commit
cd55a0dd
authored
Feb 28, 2017
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app's admin can create private namespace. & default create namespace when create…
app's admin can create private namespace. & default create namespace when create public appnamespace
parent
12a00739
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
204 additions
and
82 deletions
+204
-82
ClusterController.java
...ork/apollo/adminservice/controller/ClusterController.java
+2
-2
AppNamespaceRepository.java
...amework/apollo/biz/repository/AppNamespaceRepository.java
+2
-0
AdminService.java
.../com/ctrip/framework/apollo/biz/service/AdminService.java
+1
-1
AppNamespaceService.java
...rip/framework/apollo/biz/service/AppNamespaceService.java
+10
-7
ClusterService.java
...om/ctrip/framework/apollo/biz/service/ClusterService.java
+9
-9
NamespaceBranchService.java
.../framework/apollo/biz/service/NamespaceBranchService.java
+1
-1
NamespaceService.java
.../ctrip/framework/apollo/biz/service/NamespaceService.java
+4
-5
PermissionValidator.java
...ramework/apollo/portal/component/PermissionValidator.java
+23
-18
PortalConfig.java
...ramework/apollo/portal/component/config/PortalConfig.java
+8
-0
NamespaceController.java
...amework/apollo/portal/controller/NamespaceController.java
+20
-8
PageSettingController.java
...ework/apollo/portal/controller/PageSettingController.java
+27
-0
PageSetting.java
.../ctrip/framework/apollo/portal/entity/vo/PageSetting.java
+24
-0
AppNamespaceService.java
.../framework/apollo/portal/service/AppNamespaceService.java
+1
-4
app.html
apollo-portal/src/main/resources/static/app.html
+1
-0
setting.html
apollo-portal/src/main/resources/static/app/setting.html
+1
-0
cluster.html
apollo-portal/src/main/resources/static/cluster.html
+1
-0
config.html
apollo-portal/src/main/resources/static/config.html
+1
-0
history.html
apollo-portal/src/main/resources/static/config/history.html
+1
-0
sync.html
apollo-portal/src/main/resources/static/config/sync.html
+1
-0
index.html
apollo-portal/src/main/resources/static/index.html
+1
-0
namespace.html
apollo-portal/src/main/resources/static/namespace.html
+28
-14
role.html
apollo-portal/src/main/resources/static/namespace/role.html
+1
-0
manage.html
apollo-portal/src/main/resources/static/open/manage.html
+1
-0
NamespaceController.js
...esources/static/scripts/controller/NamespaceController.js
+11
-11
directive.js
.../src/main/resources/static/scripts/directive/directive.js
+5
-1
CommonService.js
...c/main/resources/static/scripts/services/CommonService.js
+17
-0
server_config.html
apollo-portal/src/main/resources/static/server_config.html
+1
-0
nav.html
...lo-portal/src/main/resources/static/views/common/nav.html
+1
-1
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ClusterController.java
View file @
cd55a0dd
...
...
@@ -39,9 +39,9 @@ public class ClusterController {
}
if
(
autoCreatePrivateNamespace
)
{
entity
=
clusterService
.
saveWith
CreatePrivateNamespace
(
entity
);
entity
=
clusterService
.
saveWith
InstanceOfAppNamespaces
(
entity
);
}
else
{
entity
=
clusterService
.
saveWithout
CreatePrivateNamespace
(
entity
);
entity
=
clusterService
.
saveWithout
InstanceOfAppNamespaces
(
entity
);
}
dto
=
BeanUtils
.
transfrom
(
ClusterDTO
.
class
,
entity
);
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/AppNamespaceRepository.java
View file @
cd55a0dd
...
...
@@ -20,6 +20,8 @@ public interface AppNamespaceRepository extends PagingAndSortingRepository<AppNa
List
<
AppNamespace
>
findByAppIdAndIsPublic
(
String
appId
,
boolean
isPublic
);
List
<
AppNamespace
>
findByAppId
(
String
appId
);
List
<
AppNamespace
>
findFirst500ByIdGreaterThanOrderByIdAsc
(
long
id
);
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AdminService.java
View file @
cd55a0dd
...
...
@@ -30,7 +30,7 @@ public class AdminService {
clusterService
.
createDefaultCluster
(
appId
,
createBy
);
namespaceService
.
createPrivateNamespace
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
createBy
);
namespaceService
.
instanceOfAppNamespaces
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
createBy
);
return
app
;
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java
View file @
cd55a0dd
...
...
@@ -8,7 +8,6 @@ import com.ctrip.framework.apollo.biz.entity.Cluster;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.repository.AppNamespaceRepository
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
...
...
@@ -47,6 +46,10 @@ public class AppNamespaceService {
return
appNamespaceRepository
.
findByNameAndIsPublicTrue
(
namespaceName
);
}
public
List
<
AppNamespace
>
findByAppId
(
String
appId
)
{
return
appNamespaceRepository
.
findByAppId
(
appId
);
}
public
List
<
AppNamespace
>
findPublicNamespacesByNames
(
Set
<
String
>
namespaceNames
)
{
if
(
namespaceNames
==
null
||
namespaceNames
.
isEmpty
())
{
return
Collections
.
emptyList
();
...
...
@@ -100,14 +103,12 @@ public class AppNamespaceService {
appNamespace
.
setId
(
0
);
//protection
appNamespace
.
setDataChangeCreatedBy
(
createBy
);
appNamespace
.
setDataChangeLastModifiedBy
(
createBy
);
appNamespace
=
appNamespaceRepository
.
save
(
appNamespace
);
if
(!
appNamespace
.
isPublic
())
{
linkPrivateAppNamespaceInAllCluster
(
appNamespace
.
getAppId
(),
appNamespace
.
getName
(),
createBy
);
}
instanceOfAppNamespaceInAllCluster
(
appNamespace
.
getAppId
(),
appNamespace
.
getName
(),
createBy
);
auditService
.
audit
(
AppNamespace
.
class
.
getSimpleName
(),
appNamespace
.
getId
(),
Audit
.
OP
.
INSERT
,
createBy
);
auditService
.
audit
(
AppNamespace
.
class
.
getSimpleName
(),
appNamespace
.
getId
(),
Audit
.
OP
.
INSERT
,
createBy
);
return
appNamespace
;
}
...
...
@@ -122,8 +123,9 @@ public class AppNamespaceService {
return
managedNs
;
}
private
void
linkPrivate
AppNamespaceInAllCluster
(
String
appId
,
String
namespaceName
,
String
createBy
)
{
private
void
instanceOf
AppNamespaceInAllCluster
(
String
appId
,
String
namespaceName
,
String
createBy
)
{
List
<
Cluster
>
clusters
=
clusterService
.
findParentClusters
(
appId
);
for
(
Cluster
cluster
:
clusters
)
{
Namespace
namespace
=
new
Namespace
();
namespace
.
setClusterName
(
cluster
.
getName
());
...
...
@@ -131,6 +133,7 @@ public class AppNamespaceService {
namespace
.
setNamespaceName
(
namespaceName
);
namespace
.
setDataChangeCreatedBy
(
createBy
);
namespace
.
setDataChangeLastModifiedBy
(
createBy
);
namespaceService
.
save
(
namespace
);
}
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ClusterService.java
View file @
cd55a0dd
...
...
@@ -39,7 +39,7 @@ public class ClusterService {
return
clusterRepository
.
findByAppIdAndName
(
appId
,
name
);
}
public
Cluster
findOne
(
long
clusterId
){
public
Cluster
findOne
(
long
clusterId
)
{
return
clusterRepository
.
findOne
(
clusterId
);
}
...
...
@@ -59,18 +59,18 @@ public class ClusterService {
}
@Transactional
public
Cluster
saveWith
CreatePrivateNamespace
(
Cluster
entity
)
{
public
Cluster
saveWith
InstanceOfAppNamespaces
(
Cluster
entity
)
{
Cluster
savedCluster
=
saveWithout
CreatePrivateNamespace
(
entity
);
Cluster
savedCluster
=
saveWithout
InstanceOfAppNamespaces
(
entity
);
namespaceService
.
createPrivateNamespace
(
savedCluster
.
getAppId
(),
savedCluster
.
getName
(),
savedCluster
.
getDataChangeCreatedBy
());
namespaceService
.
instanceOfAppNamespaces
(
savedCluster
.
getAppId
(),
savedCluster
.
getName
(),
savedCluster
.
getDataChangeCreatedBy
());
return
savedCluster
;
}
@Transactional
public
Cluster
saveWithout
CreatePrivateNamespace
(
Cluster
entity
)
{
public
Cluster
saveWithout
InstanceOfAppNamespaces
(
Cluster
entity
)
{
if
(!
isClusterNameUnique
(
entity
.
getAppId
(),
entity
.
getName
()))
{
throw
new
BadRequestException
(
"cluster not unique"
);
}
...
...
@@ -108,7 +108,7 @@ public class ClusterService {
managedCluster
=
clusterRepository
.
save
(
managedCluster
);
auditService
.
audit
(
Cluster
.
class
.
getSimpleName
(),
managedCluster
.
getId
(),
Audit
.
OP
.
UPDATE
,
managedCluster
.
getDataChangeLastModifiedBy
());
managedCluster
.
getDataChangeLastModifiedBy
());
return
managedCluster
;
}
...
...
@@ -128,9 +128,9 @@ public class ClusterService {
auditService
.
audit
(
Cluster
.
class
.
getSimpleName
(),
cluster
.
getId
(),
Audit
.
OP
.
INSERT
,
createBy
);
}
public
List
<
Cluster
>
findChildClusters
(
String
appId
,
String
parentClusterName
){
public
List
<
Cluster
>
findChildClusters
(
String
appId
,
String
parentClusterName
)
{
Cluster
parentCluster
=
findOne
(
appId
,
parentClusterName
);
if
(
parentCluster
==
null
){
if
(
parentCluster
==
null
)
{
throw
new
BadRequestException
(
"parent cluster not exist"
);
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceBranchService.java
View file @
cd55a0dd
...
...
@@ -52,7 +52,7 @@ public class NamespaceBranchService {
//create child cluster
Cluster
childCluster
=
createChildCluster
(
appId
,
parentCluster
,
namespaceName
,
operator
);
Cluster
createdChildCluster
=
clusterService
.
saveWithout
CreatePrivateNamespace
(
childCluster
);
Cluster
createdChildCluster
=
clusterService
.
saveWithout
InstanceOfAppNamespaces
(
childCluster
);
//create child namespace
childNamespace
=
createNamespaceBranch
(
appId
,
createdChildCluster
.
getName
(),
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
View file @
cd55a0dd
...
...
@@ -313,12 +313,11 @@ public class NamespaceService {
}
@Transactional
public
void
createPrivateNamespace
(
String
appId
,
String
clusterName
,
String
createBy
)
{
public
void
instanceOfAppNamespaces
(
String
appId
,
String
clusterName
,
String
createBy
)
{
//load all private app namespace
List
<
AppNamespace
>
privateAppNamespaces
=
appNamespaceService
.
findPrivateAppNamespace
(
appId
);
//create all private namespace
for
(
AppNamespace
appNamespace
:
privateAppNamespaces
)
{
List
<
AppNamespace
>
appNamespaces
=
appNamespaceService
.
findByAppId
(
appId
);
for
(
AppNamespace
appNamespace
:
appNamespaces
)
{
Namespace
ns
=
new
Namespace
();
ns
.
setAppId
(
appId
);
ns
.
setClusterName
(
clusterName
);
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/PermissionValidator.java
View file @
cd55a0dd
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
component
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.constant.PermissionType
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
...
...
@@ -16,53 +17,57 @@ public class PermissionValidator {
private
UserInfoHolder
userInfoHolder
;
@Autowired
private
RolePermissionService
rolePermissionService
;
@Autowired
private
PortalConfig
portalConfig
;
public
boolean
hasModifyNamespacePermission
(
String
appId
,
String
namespaceName
)
{
return
rolePermissionService
.
userHasPermission
(
userInfoHolder
.
getUser
().
getUserId
(),
PermissionType
.
MODIFY_NAMESPACE
,
RoleUtils
.
buildNamespaceTargetId
(
appId
,
namespaceName
));
PermissionType
.
MODIFY_NAMESPACE
,
RoleUtils
.
buildNamespaceTargetId
(
appId
,
namespaceName
));
}
public
boolean
hasReleaseNamespacePermission
(
String
appId
,
String
namespaceName
)
{
return
rolePermissionService
.
userHasPermission
(
userInfoHolder
.
getUser
().
getUserId
(),
PermissionType
.
RELEASE_NAMESPACE
,
RoleUtils
.
buildNamespaceTargetId
(
appId
,
namespaceName
));
PermissionType
.
RELEASE_NAMESPACE
,
RoleUtils
.
buildNamespaceTargetId
(
appId
,
namespaceName
));
}
public
boolean
hasDeleteNamespacePermission
(
String
appId
)
{
return
hasAssignRolePermission
(
appId
)
||
isSuperAdmin
();
}
public
boolean
hasOperateNamespacePermission
(
String
appId
,
String
namespaceName
){
public
boolean
hasOperateNamespacePermission
(
String
appId
,
String
namespaceName
)
{
return
hasModifyNamespacePermission
(
appId
,
namespaceName
)
||
hasReleaseNamespacePermission
(
appId
,
namespaceName
);
}
public
boolean
hasAssignRolePermission
(
String
appId
)
{
return
rolePermissionService
.
userHasPermission
(
userInfoHolder
.
getUser
().
getUserId
(),
PermissionType
.
ASSIGN_ROLE
,
appId
);
PermissionType
.
ASSIGN_ROLE
,
appId
);
}
public
boolean
hasCreateNamespacePermission
(
String
appId
)
{
return
rolePermissionService
.
userHasPermission
(
userInfoHolder
.
getUser
().
getUserId
(),
PermissionType
.
CREATE_NAMESPACE
,
appId
);
}
public
boolean
hasCreateClusterPermission
(
String
appId
)
{
return
rolePermissionService
.
userHasPermission
(
userInfoHolder
.
getUser
().
getUserId
(),
PermissionType
.
CREATE_CLUSTER
,
appId
);
PermissionType
.
CREATE_NAMESPACE
,
appId
);
}
public
boolean
hasCreateAppNamespacePermission
(
String
appId
,
AppNamespace
appNamespace
)
{
boolean
isPublicAppNamespace
=
appNamespace
.
isPublic
();
if
(
isPublicAppNamespace
)
{
if
(
portalConfig
.
canAppAdminCreatePrivateNamespace
()
||
isPublicAppNamespace
)
{
return
hasCreateNamespacePermission
(
appId
);
}
else
{
return
rolePermissionService
.
isSuperAdmin
(
userInfoHolder
.
getUser
().
getUserId
());
}
return
isSuperAdmin
();
}
public
boolean
hasCreateClusterPermission
(
String
appId
)
{
return
rolePermissionService
.
userHasPermission
(
userInfoHolder
.
getUser
().
getUserId
(),
PermissionType
.
CREATE_CLUSTER
,
appId
);
}
public
boolean
isAppAdmin
(
String
appId
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/component/config/PortalConfig.java
View file @
cd55a0dd
...
...
@@ -153,6 +153,14 @@ public class PortalConfig extends RefreshableConfig {
return
getValue
(
"email.template.release.module.rules"
,
""
);
}
public
String
wikiAddress
()
{
return
getValue
(
"wiki.address"
,
"https://github.com/ctripcorp/apollo/wiki"
);
}
public
boolean
canAppAdminCreatePrivateNamespace
()
{
return
getBooleanProperty
(
"admin.createPrivateNamespace.switch"
,
true
);
}
/***
* The following configurations are used in ctrip profile
**/
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
View file @
cd55a0dd
...
...
@@ -11,6 +11,7 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceCreationModel
;
import
com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO
;
...
...
@@ -62,6 +63,9 @@ public class NamespaceController {
private
RoleInitializationService
roleInitializationService
;
@Autowired
private
RolePermissionService
rolePermissionService
;
@Autowired
private
PortalConfig
portalConfig
;
@RequestMapping
(
value
=
"/appnamespaces/public"
,
method
=
RequestMethod
.
GET
)
public
List
<
AppNamespace
>
findPublicAppNamespaces
()
{
...
...
@@ -119,14 +123,7 @@ public class NamespaceController {
}
}
//default assign modify、release namespace role to namespace creator
String
loginUser
=
userInfoHolder
.
getUser
().
getUserId
();
rolePermissionService
.
assignRoleToUsers
(
RoleUtils
.
buildNamespaceRoleName
(
appId
,
namespaceName
,
RoleType
.
MODIFY_NAMESPACE
),
Sets
.
newHashSet
(
loginUser
),
loginUser
);
rolePermissionService
.
assignRoleToUsers
(
RoleUtils
.
buildNamespaceRoleName
(
appId
,
namespaceName
,
RoleType
.
RELEASE_NAMESPACE
),
Sets
.
newHashSet
(
loginUser
),
loginUser
);
assignNamespaceRoleToOperator
(
appId
,
namespaceName
);
return
ResponseEntity
.
ok
().
build
();
}
...
...
@@ -169,6 +166,10 @@ public class NamespaceController {
appNamespace
.
setDataChangeLastModifiedBy
(
operator
);
AppNamespace
createdAppNamespace
=
appNamespaceService
.
createAppNamespaceInLocal
(
appNamespace
);
if
(
portalConfig
.
canAppAdminCreatePrivateNamespace
()
||
createdAppNamespace
.
isPublic
())
{
assignNamespaceRoleToOperator
(
appId
,
appNamespace
.
getName
());
}
publisher
.
publishEvent
(
new
AppNamespaceCreationEvent
(
createdAppNamespace
));
return
createdAppNamespace
;
...
...
@@ -196,4 +197,15 @@ public class NamespaceController {
}
private
void
assignNamespaceRoleToOperator
(
String
appId
,
String
namespaceName
)
{
//default assign modify、release namespace role to namespace creator
String
operator
=
userInfoHolder
.
getUser
().
getUserId
();
rolePermissionService
.
assignRoleToUsers
(
RoleUtils
.
buildNamespaceRoleName
(
appId
,
namespaceName
,
RoleType
.
MODIFY_NAMESPACE
),
Sets
.
newHashSet
(
operator
),
operator
);
rolePermissionService
.
assignRoleToUsers
(
RoleUtils
.
buildNamespaceRoleName
(
appId
,
namespaceName
,
RoleType
.
RELEASE_NAMESPACE
),
Sets
.
newHashSet
(
operator
),
operator
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PageSettingController.java
0 → 100644
View file @
cd55a0dd
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.entity.vo.PageSetting
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
public
class
PageSettingController
{
@Autowired
private
PortalConfig
portalConfig
;
@RequestMapping
(
value
=
"/page-settings"
,
method
=
RequestMethod
.
GET
)
public
PageSetting
getPageSetting
()
{
PageSetting
setting
=
new
PageSetting
();
setting
.
setWikiAddress
(
portalConfig
.
wikiAddress
());
setting
.
setCanAppAdminCreatePrivateNamespace
(
portalConfig
.
canAppAdminCreatePrivateNamespace
());
return
setting
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/PageSetting.java
0 → 100644
View file @
cd55a0dd
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
vo
;
public
class
PageSetting
{
private
String
wikiAddress
;
private
boolean
canAppAdminCreatePrivateNamespace
;
public
String
getWikiAddress
()
{
return
wikiAddress
;
}
public
void
setWikiAddress
(
String
wikiAddress
)
{
this
.
wikiAddress
=
wikiAddress
;
}
public
boolean
isCanAppAdminCreatePrivateNamespace
()
{
return
canAppAdminCreatePrivateNamespace
;
}
public
void
setCanAppAdminCreatePrivateNamespace
(
boolean
canAppAdminCreatePrivateNamespace
)
{
this
.
canAppAdminCreatePrivateNamespace
=
canAppAdminCreatePrivateNamespace
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java
View file @
cd55a0dd
...
...
@@ -77,10 +77,7 @@ public class AppNamespaceService {
AppNamespace
createdAppNamespace
=
appNamespaceRepository
.
save
(
appNamespace
);
//如果是私有的app namespace 要默认初始化权限,如果是公共的,则在关联此namespace的时候初始化权限
if
(!
createdAppNamespace
.
isPublic
())
{
roleInitializationService
.
initNamespaceRoles
(
appNamespace
.
getAppId
(),
appNamespace
.
getName
());
}
roleInitializationService
.
initNamespaceRoles
(
appNamespace
.
getAppId
(),
appNamespace
.
getName
());
return
createdAppNamespace
;
}
...
...
apollo-portal/src/main/resources/static/app.html
View file @
cd55a0dd
...
...
@@ -118,6 +118,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/AppUtils.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/OrganizationService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/directive.js"
></script>
...
...
apollo-portal/src/main/resources/static/app/setting.html
View file @
cd55a0dd
...
...
@@ -186,6 +186,7 @@
<script
type=
"application/javascript"
src=
"../scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/PermissionService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/OrganizationService.js"
></script>
...
...
apollo-portal/src/main/resources/static/cluster.html
View file @
cd55a0dd
...
...
@@ -127,6 +127,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/ClusterService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/AppUtils.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/directive.js"
></script>
...
...
apollo-portal/src/main/resources/static/config.html
View file @
cd55a0dd
...
...
@@ -389,6 +389,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/PermissionService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/NamespaceService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/CommitService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/NamespaceLockService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/InstanceService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/FavoriteService.js"
></script>
...
...
apollo-portal/src/main/resources/static/config/history.html
View file @
cd55a0dd
...
...
@@ -267,6 +267,7 @@
<script
type=
"application/javascript"
src=
"../scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/ReleaseService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/ReleaseHistoryService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/ConfigService.js"
></script>
...
...
apollo-portal/src/main/resources/static/config/sync.html
View file @
cd55a0dd
...
...
@@ -234,6 +234,7 @@
<script
type=
"application/javascript"
src=
"../scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/ConfigService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/AppUtils.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/controller/config/SyncConfigController.js"
></script>
...
...
apollo-portal/src/main/resources/static/index.html
View file @
cd55a0dd
...
...
@@ -125,6 +125,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/FavoriteService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/AppUtils.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive/directive.js"
></script>
...
...
apollo-portal/src/main/resources/static/namespace.html
View file @
cd55a0dd
...
...
@@ -23,7 +23,11 @@
<div
class=
"panel"
>
<header
class=
"panel-heading"
>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
新建Namespace
</div>
<div
class=
"col-md-6"
>
新建Namespace
<small><a
target=
"_blank"
href=
"https://github.com/ctripcorp/apollo/wiki/Apollo%E6%A0%B8%E5%BF%83%E6%A6%82%E5%BF%B5%E4%B9%8B%E2%80%9CNamespace%E2%80%9D"
>
(点击了解更多Namespace相关知识)
</a>
</small>
</div>
<div
class=
"col-md-6 text-right"
>
<button
type=
"button"
class=
"btn btn-info"
ng-click=
"back()"
>
返回到项目首页
</button>
...
...
@@ -37,26 +41,32 @@
<div
class=
"alert alert-info no-radius"
>
<strong>
Tips:
</strong>
<ul
ng-show=
"type == 'link'"
>
<li>
公共namespace所属的应用通过关联公共namespace来配置公共部分的配置
</li>
<li>
其它应用可以通过关联公共namespace来覆盖公共部分的配置
</li>
<li>
如果其它应用不需要覆盖公共部分的配置,那么无需关联公共namespace
</li>
<li>
应用可以通过关联公共namespace来覆盖公共Namespace的配置
</li>
<li>
如果应用不需要覆盖公共Namespace的配置,那么无需关联公共Namespace
</li>
</ul>
<ul
ng-show=
"type == 'create'"
>
<ul
ng-show=
"type == 'create' && appNamespace.isPublic"
>
<li>
公共的Namespace的配置能被任何项目读取
</li>
<li>
通过创建
一个公共的n
amespace可以实现公共组件的配置,或多个应用共享同一份配置的需求
通过创建
公共N
amespace可以实现公共组件的配置,或多个应用共享同一份配置的需求
</li>
<li>
创建完公共的namespace且关联到当前应用后,就可以配置公共部分的配置了
</li>
<li>
如果其它应用需要覆盖公共部分的配置,可以在其它应用那里关联公共的namespace,然后在关联的namespace里面配置需要覆盖的配置即可
</li>
<li>
如果其它应用不需要覆盖公共部分的配置,那么就不需要在其它应用那里关联公共的namespace
</li>
<li>
如果其它应用需要覆盖公共部分的配置,可以在其它应用那里关联公共Namespace,然后在关联的Namespace里面配置需要覆盖的配置即可
</li>
<li>
如果其它应用不需要覆盖公共部分的配置,那么就不需要在其它应用那里关联公共Namespace
</li>
</ul>
<ul
ng-show=
"type == 'create' && !appNamespace.isPublic"
>
<li>
私有Namespace的配置只能被所属的应用获取到
</li>
<li>
通过创建一个私有的Namespace可以实现分组管理配置
</li>
<li>
私有Namespace的格式可以是xml、yml、yaml、json. 您可以通过Apollo-client中ConfigFile接口来获取非properties格式Namespace的内容
</li>
</ul>
</div>
<div
class=
"row text-right"
style=
"padding-right: 20px;"
>
<div
class=
"btn-group btn-group-sm"
role=
"group"
aria-label=
"..."
>
<button
type=
"button"
class=
"btn btn-default"
ng-class=
"{active:type=='link'}"
ng-click=
"switchType('link')"
>
关联
已存在的
Namespace
ng-click=
"switchType('link')"
>
关联
公共
Namespace
</button>
<button
type=
"button"
class=
"btn btn-default"
ng-class=
"{active:type=='create'}"
ng-click=
"switchType('create')"
>
创建
新的
Namespace
ng-click=
"switchType('create')"
>
创建Namespace
</button>
</div>
</div>
...
...
@@ -65,7 +75,7 @@
<form
class=
"form-horizontal"
name=
"namespaceForm"
valdr-type=
"AppNamespace"
style=
"margin-top: 30px;"
ng-show=
"step == 1"
ng-submit=
"createNamespace()"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
应用ID
</label>
<label
class=
"col-sm-3 control-label"
>
AppId
</label>
<div
class=
"col-sm-6"
valdr-form-group
>
<label
class=
"form-control-static"
ng-bind=
"appId"
></label>
</div>
...
...
@@ -93,7 +103,9 @@
ng-model=
"appNamespace.name"
>
</div>
</div>
<div
class=
"col-sm-2"
ng-if=
"hasRootPermission"
>
<!--public namespace can only be properties -->
<div
class=
"col-sm-2"
ng-show=
"!appNamespace.isPublic"
>
<select
class=
"form-control"
name=
"format"
ng-model=
"appNamespace.format"
>
<option
value=
"properties"
>
properties
</option>
<option
value=
"xml"
>
xml
</option>
...
...
@@ -103,10 +115,11 @@
</select>
</div>
<span
ng-show=
"appNamespace.isPublic"
ng-bind=
"concatNamespace()"
style=
"line-height: 34px;"
></span>
</div>
<div
class=
"form-group"
ng-show=
"type == 'create' &&
hasRootPermission
"
>
<div
class=
"form-group"
ng-show=
"type == 'create' &&
(pageSetting.canAppAdminCreatePrivateNamespace || hasRootPermission)
"
>
<label
class=
"col-sm-3 control-label"
>
<apollorequiredfield></apollorequiredfield>
类型
</label>
...
...
@@ -184,6 +197,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/NamespaceService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/PermissionService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/AppUtils.js"
></script>
...
...
apollo-portal/src/main/resources/static/namespace/role.html
View file @
cd55a0dd
...
...
@@ -126,6 +126,7 @@
<script
type=
"application/javascript"
src=
"../scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/PermissionService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/AppUtils.js"
></script>
...
...
apollo-portal/src/main/resources/static/open/manage.html
View file @
cd55a0dd
...
...
@@ -172,6 +172,7 @@
<script
type=
"application/javascript"
src=
"../scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/PermissionService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/OrganizationService.js"
></script>
<script
type=
"application/javascript"
src=
"../scripts/services/ConsumerService.js"
></script>
...
...
apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js
View file @
cd55a0dd
namespace_module
.
controller
(
"LinkNamespaceController"
,
[
'$scope'
,
'$location'
,
'$window'
,
'toastr'
,
'AppService'
,
'AppUtil'
,
'NamespaceService'
,
'PermissionService'
,
'PermissionService'
,
'CommonService'
,
function
(
$scope
,
$location
,
$window
,
toastr
,
AppService
,
AppUtil
,
NamespaceService
,
PermissionService
)
{
PermissionService
,
CommonService
)
{
var
params
=
AppUtil
.
parseParams
(
$location
.
$$url
);
$scope
.
appId
=
params
.
appid
;
...
...
@@ -16,6 +16,10 @@ namespace_module.controller("LinkNamespaceController",
$scope
.
hasRootPermission
=
result
.
hasPermission
;
});
CommonService
.
getPageSetting
().
then
(
function
(
setting
)
{
$scope
.
pageSetting
=
setting
;
});
NamespaceService
.
find_public_namespaces
().
then
(
function
(
result
)
{
var
publicNamespaces
=
[];
result
.
forEach
(
function
(
item
)
{
...
...
@@ -112,27 +116,23 @@ namespace_module.controller("LinkNamespaceController",
}
else
{
var
namespaceNameLength
=
$scope
.
concatNamespace
().
length
;
if
(
namespaceNameLength
>
32
){
if
(
namespaceNameLength
>
32
)
{
toastr
.
error
(
"namespace名称不能大于32个字符. 部门前缀"
+
(
namespaceNameLength
-
$scope
.
appNamespace
.
name
.
length
)
+
"个字符, 名称"
+
$scope
.
appNamespace
.
name
.
length
+
"个字符"
);
return
;
}
$scope
.
submitBtnDisabled
=
true
;
NamespaceService
.
createAppNamespace
(
$scope
.
appId
,
$scope
.
appNamespace
).
then
(
function
(
result
)
{
$scope
.
step
=
2
;
setTimeout
(
function
()
{
$scope
.
submitBtnDisabled
=
false
;
if
(
$scope
.
appNamespace
.
isPublic
)
{
$window
.
location
.
reload
();
}
else
{
//private的直接link并且跳转到授权页面
$window
.
location
.
href
=
"/namespace/role.html?#/appid="
+
$scope
.
appId
+
"&namespaceName="
+
result
.
name
;
}
$window
.
location
.
href
=
"/namespace/role.html?#/appid="
+
$scope
.
appId
+
"&namespaceName="
+
result
.
name
;
},
1000
);
},
function
(
result
)
{
$scope
.
submitBtnDisabled
=
false
;
...
...
apollo-portal/src/main/resources/static/scripts/directive/directive.js
View file @
cd55a0dd
/** navbar */
directive_module
.
directive
(
'apollonav'
,
function
(
$compile
,
$window
,
toastr
,
AppUtil
,
AppService
,
EnvService
,
UserService
)
{
function
(
$compile
,
$window
,
toastr
,
AppUtil
,
AppService
,
EnvService
,
UserService
,
CommonService
)
{
return
{
restrict
:
'E'
,
templateUrl
:
'../../views/common/nav.html'
,
...
...
@@ -8,6 +8,10 @@ directive_module.directive('apollonav',
replace
:
true
,
link
:
function
(
scope
,
element
,
attrs
)
{
CommonService
.
getPageSetting
().
then
(
function
(
setting
)
{
scope
.
pageSetting
=
setting
;
});
scope
.
sourceApps
=
[];
scope
.
copyedApps
=
[];
...
...
apollo-portal/src/main/resources/static/scripts/services/CommonService.js
0 → 100644
View file @
cd55a0dd
appService
.
service
(
'CommonService'
,
[
'$resource'
,
'$q'
,
'AppUtil'
,
function
(
$resource
,
$q
,
AppUtil
)
{
var
resource
=
$resource
(
''
,
{},
{
page_setting
:
{
method
:
'GET'
,
isArray
:
false
,
url
:
'/page-settings'
}
});
return
{
getPageSetting
:
function
()
{
return
AppUtil
.
ajax
(
resource
.
page_setting
,
{});
}
}
}]);
apollo-portal/src/main/resources/static/server_config.html
View file @
cd55a0dd
...
...
@@ -84,6 +84,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/AppService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/CommonService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/ServerConfigService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/ServerConfigController.js"
></script>
...
...
apollo-portal/src/main/resources/static/views/common/nav.html
View file @
cd55a0dd
...
...
@@ -21,7 +21,7 @@
<ul
class=
"nav navbar-nav navbar-right"
>
<li>
<a
href=
"
http://conf.ctripcorp.com/display/FRAM/Apollo
"
target=
"_blank"
>
<a
href=
"
{{pageSetting.wikiAddress}}
"
target=
"_blank"
>
<span
class=
"glyphicon glyphicon-question-sign"
></span>
帮助
</a>
</li>
...
...
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