Commit cd55a0dd by lepdou

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
......@@ -39,9 +39,9 @@ public class ClusterController {
}
if (autoCreatePrivateNamespace) {
entity = clusterService.saveWithCreatePrivateNamespace(entity);
entity = clusterService.saveWithInstanceOfAppNamespaces(entity);
} else {
entity = clusterService.saveWithoutCreatePrivateNamespace(entity);
entity = clusterService.saveWithoutInstanceOfAppNamespaces(entity);
}
dto = BeanUtils.transfrom(ClusterDTO.class, entity);
......
......@@ -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);
}
......@@ -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;
}
......
......@@ -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 linkPrivateAppNamespaceInAllCluster(String appId, String namespaceName, String createBy) {
private void instanceOfAppNamespaceInAllCluster(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);
}
}
......
......@@ -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 saveWithCreatePrivateNamespace(Cluster entity) {
public Cluster saveWithInstanceOfAppNamespaces(Cluster entity) {
Cluster savedCluster = saveWithoutCreatePrivateNamespace(entity);
Cluster savedCluster = saveWithoutInstanceOfAppNamespaces(entity);
namespaceService.createPrivateNamespace(savedCluster.getAppId(), savedCluster.getName(),
savedCluster.getDataChangeCreatedBy());
namespaceService.instanceOfAppNamespaces(savedCluster.getAppId(), savedCluster.getName(),
savedCluster.getDataChangeCreatedBy());
return savedCluster;
}
@Transactional
public Cluster saveWithoutCreatePrivateNamespace(Cluster entity){
public Cluster saveWithoutInstanceOfAppNamespaces(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");
}
......
......@@ -52,7 +52,7 @@ public class NamespaceBranchService {
//create child cluster
Cluster childCluster = createChildCluster(appId, parentCluster, namespaceName, operator);
Cluster createdChildCluster = clusterService.saveWithoutCreatePrivateNamespace(childCluster);
Cluster createdChildCluster = clusterService.saveWithoutInstanceOfAppNamespaces(childCluster);
//create child namespace
childNamespace = createNamespaceBranch(appId, createdChildCluster.getName(),
......
......@@ -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);
......
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) {
......
......@@ -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
**/
......
......@@ -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);
}
}
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;
}
}
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;
}
}
......@@ -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;
}
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
......@@ -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>
通过创建一个公共的namespace可以实现公共组件的配置,或多个应用共享同一份配置的需求
通过创建公共Namespace可以实现公共组件的配置,或多个应用共享同一份配置的需求
</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>
&nbsp;&nbsp;
<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>
......
......@@ -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>
......
......@@ -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>
......
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;
......
/** 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 = [];
......
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, {});
}
}
}]);
......@@ -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>
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment