Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature:关联 namespace界面,可以一次选择多个namespace #4437

Merged
merged 7 commits into from
Jul 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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