Skip to content

Commit

Permalink
feature:关联 namespace界面,可以一次选择多个namespace (#4437)
Browse files Browse the repository at this point in the history
* feat:关联 namespace界面,可以一次选择多个namespace

Signed-off-by: jianfei.zhang [email protected]

* feat:CHANGES.md

Signed-off-by: jianfei.zhang [email protected]

* fix: remove error function

* feat: 后端支持多namespace

* fix: redirect to config html
Signed-off-by: jianfei.zhang <[email protected]>

* fix: redirect to html
Signed-off-by: jianfei.zhang <[email protected]>

* Update CHANGES.md
  • Loading branch information
falser101 authored Jul 4, 2022
1 parent b229e00 commit 804ffae
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ Apollo 2.1.0
* [Upgrade mysql-connector-java version to fix possible transaction rollback failure issue](https://github.com/apolloconfig/apollo/pull/4425)
* [Remove database migration tool Flyway](https://github.com/apolloconfig/apollo/pull/4361)
* [Optimize Spring-Security Firewall Deny Request Response 400](https://github.com/apolloconfig/apollo/pull/4428)
* [Allow users to associate multiple public namespaces at a time](https://github.com/apolloconfig/apollo/pull/4437)
------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/11?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,12 @@ public ResponseEntity<Void> createNamespace(@PathVariable String appId,
@RequestBody List<NamespaceCreationModel> models) {

checkModel(!CollectionUtils.isEmpty(models));

String namespaceName = models.get(0).getNamespace().getNamespaceName();
String operator = userInfoHolder.getUser().getUserId();

roleInitializationService.initNamespaceRoles(appId, namespaceName, operator);
roleInitializationService.initNamespaceEnvRoles(appId, namespaceName, operator);

for (NamespaceCreationModel model : models) {
String namespaceName = model.getNamespace().getNamespaceName();
roleInitializationService.initNamespaceRoles(appId, namespaceName, operator);
roleInitializationService.initNamespaceEnvRoles(appId, namespaceName, operator);
NamespaceDTO namespace = model.getNamespace();
RequestPrecondition.checkArgumentsNotEmpty(model.getEnv(), namespace.getAppId(),
namespace.getClusterName(), namespace.getNamespaceName());
Expand All @@ -163,10 +161,9 @@ public ResponseEntity<Void> createNamespace(@PathVariable String appId,
String.format("create namespace fail. (env=%s namespace=%s)", model.getEnv(),
namespace.getNamespaceName()), e);
}
namespaceService.assignNamespaceRoleToOperator(appId, namespaceName,userInfoHolder.getUser().getUserId());
}

namespaceService.assignNamespaceRoleToOperator(appId, namespaceName,userInfoHolder.getUser().getUserId());

return ResponseEntity.ok().build();
}

Expand Down
2 changes: 1 addition & 1 deletion apollo-portal/src/main/resources/static/namespace.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
{{'Namespace.Namespace' | translate }}
</label>
<div class="col-sm-4" valdr-form-group>
<select id="namespaces">
<select multiple id="namespaces">
<option></option>
</select>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,38 @@ namespace_module.controller("LinkNamespaceController",
selectedClusters = data;
};
$scope.createNamespace = function () {
if ($scope.type == 'link') {
if (selectedClusters.length == 0) {
if ($scope.type === 'link') {
if (selectedClusters.length === 0) {
toastr.warning($translate.instant('Namespace.PleaseChooseCluster'));
return;
}

if ($scope.namespaceType == 1) {
var selectedNamespaceName = $('#namespaces').select2('data')[0].id;
if (!selectedNamespaceName) {
if ($scope.namespaceType === 1) {
var selectedNamespaceNames = $('#namespaces').select2('data');
var ids = []
selectedNamespaceNames.forEach(function (namespace) {
ids.push(namespace.id)
})
if (ids.length === 0) {
toastr.warning($translate.instant('Namespace.PleaseChooseNamespace'));
return;
}

$scope.namespaceName = selectedNamespaceName;
$scope.namespaceNames = ids;
}

var namespaceCreationModels = [];
selectedClusters.forEach(function (cluster) {
namespaceCreationModels.push({
env: cluster.env,
namespace: {
appId: $scope.appId,
clusterName: cluster.clusterName,
namespaceName: $scope.namespaceName
}
});
$scope.namespaceNames.forEach(function (namespace) {
namespaceCreationModels.push({
env: cluster.env,
namespace: {
appId: $scope.appId,
clusterName: cluster.clusterName,
namespaceName: namespace
}
});
})
});

$scope.submitBtnDisabled = true;
Expand All @@ -129,9 +135,14 @@ namespace_module.controller("LinkNamespaceController",
$scope.step = 2;
setInterval(function () {
$scope.submitBtnDisabled = false;
$window.location.href =
AppUtil.prefixPath() + '/namespace/role.html?#appid=' + $scope.appId
+ "&namespaceName=" + $scope.namespaceName;
if ($scope.namespaceNames.length === 1) {
$window.location.href =
AppUtil.prefixPath() + '/namespace/role.html?#appid=' + $scope.appId
+ "&namespaceName=" + $scope.namespaceNames[0];
} else {
$window.location.href =
AppUtil.prefixPath() + '/config.html?#/appid=' + $scope.appId;
}
}, 1000);
}, function (result) {
$scope.submitBtnDisabled = false;
Expand Down

0 comments on commit 804ffae

Please sign in to comment.