You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by dg...@apache.org on 2021/01/04 14:13:39 UTC
[incubator-datalab] 02/03: [DATALAB-2182]: Fixed bugs and added
improvements to configuration page
This is an automated email from the ASF dual-hosted git repository.
dgnatyshyn pushed a commit to branch DATALAB-2201
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
commit a6f146ed0cfeb42ccb9d8be8b3a5538de12b54f4
Author: Dmytro_Gnatyshyn <di...@ukr.net>
AuthorDate: Mon Jan 4 12:51:37 2021 +0200
[DATALAB-2182]: Fixed bugs and added improvements to configuration page
---
.../configuration/configuration.component.html | 35 ++++++++++++++--------
.../configuration/configuration.component.ts | 31 ++++++++++++-------
.../resources/webapp/src/app/app.routing.module.ts | 3 +-
.../resources/webapp/src/app/core/core.module.ts | 2 ++
.../src/app/core/services/healthStatus.service.ts | 4 +++
.../src/app/core/services/projectAdmin.guard.ts | 31 +++++++++++++++++++
.../src/app/shared/navbar/navbar.component.html | 4 +--
7 files changed, 84 insertions(+), 26 deletions(-)
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.html b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.html
index 8aab7c8..6ddd080 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.html
@@ -19,18 +19,20 @@
<div class="base-retreat">
<div class="sub-nav">
- <button mat-raised-button class="butt"
- (click)="action('save')"
- [disabled]="!services['provisioning-service'].isConfigChanged && !services['self-service'].isConfigChanged && !services['billing'].isConfigChanged"
- >
- Save
- </button>
- <button mat-raised-button class="butt"
- (click)="action('discard')"
- [disabled]="!services['provisioning-service'].isConfigChanged && !services['self-service'].isConfigChanged && !services['billing'].isConfigChanged"
- >
- Discard changes
- </button>
+ <ng-template [ngIf]="activeTab.index !== 0">
+ <button mat-raised-button class="butt"
+ (click)="action('save')"
+ [disabled]="!services['provisioning-service'].isConfigChanged && !services['self-service'].isConfigChanged && !services['billing'].isConfigChanged"
+ >
+ Save
+ </button>
+ <button mat-raised-button class="butt"
+ (click)="action('discard')"
+ [disabled]="!services['provisioning-service'].isConfigChanged && !services['self-service'].isConfigChanged && !services['billing'].isConfigChanged"
+ >
+ Discard changes
+ </button>
+ </ng-template>
<button mat-raised-button class="butt" (click)="refreshConfig()">
<i class="material-icons refresh-icon">autorenew</i>Refresh
</button>
@@ -58,7 +60,14 @@
</p>
</li>
</ul>
- <button mat-raised-button type="button" class="butt action" (click)="restartServices()">Restart</button>
+ <button
+ mat-raised-button type="button"
+ class="butt action"
+ (click)="restartServices()"
+ [disabled]="isServiceSelected()"
+ >
+ Restart
+ </button>
</div>
</section>
</div>
diff --git a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts
index 5e0d1f9..1e19fc6 100644
--- a/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/administration/configuration/configuration.component.ts
@@ -25,6 +25,7 @@ import {Router} from '@angular/router';
import {ConfigurationService} from '../../core/services/configutration.service';
import 'brace';
import 'brace/mode/yaml';
+import {ToastrService} from 'ngx-toastr';
@Component({
selector: 'datalab-configuration',
@@ -65,7 +66,8 @@ export class ConfigurationComponent implements OnInit {
private appRoutingService: AppRoutingService,
private configurationService: ConfigurationService,
private router: Router,
- public dialog: MatDialog
+ public dialog: MatDialog,
+ public toastr: ToastrService,
) { }
ngOnInit() {
@@ -112,7 +114,9 @@ export class ConfigurationComponent implements OnInit {
private setServiceConfig(service, config) {
this.configurationService.setServiceConfig(service, config).subscribe(res => {
this.getServicesConfig(service);
- }
+ this.toastr.success('Service configuration saved!', 'Success!');
+ },
+ error => this.toastr.error('Service configuration is not saved', 'Oops!')
);
}
@@ -158,21 +162,28 @@ export class ConfigurationComponent implements OnInit {
action: 'Restart services', message: this.confirmMessages.restartService
}, panelClass: 'modal-sm' })
.afterClosed().subscribe(result => {
- this.configurationService.restartServices(this.services['self-service'].selected,
- this.services['provisioning-service'].selected,
- this.services['billing'].selected
- )
- .subscribe(res => {
- this.clearSelectedServices();
+ if (result) {
+ this.configurationService.restartServices(this.services['self-service'].selected,
+ this.services['provisioning-service'].selected,
+ this.services['billing'].selected
+ )
+ .subscribe(res => {
+ this.clearSelectedServices();
+ this.toastr.success('Service restarting started!', 'Success!');
+ },
+ error => this.toastr.error('Service restarting failed', 'Oops!')
+ );
}
- );
-
});
}
public configUpdate(service: string) {
this.services[service].isConfigChanged = this.services[service].config !== this.services[service].serverConfig;
}
+
+ public isServiceSelected(): boolean {
+ return Object.keys(this.services).every(service => !this.services[service].selected);
+ }
}
@Component({
diff --git a/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts b/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
index 4b7d06c..f25f5ae 100644
--- a/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/app.routing.module.ts
@@ -36,6 +36,7 @@ import { AuthorizationGuard, CheckParamsGuard, CloudProviderGuard, AdminGuard, A
import {AuditComponent} from './reports/audit/audit.component';
import {ConfigurationComponent} from './administration/configuration/configuration.component';
import {OdahuComponent} from './administration/odahu/odahu.component';
+import {ProjectAdminGuard} from './core/services/projectAdmin.guard';
const routes: Routes = [{
path: 'login',
@@ -77,7 +78,7 @@ const routes: Routes = [{
}, {
path: 'configuration',
component: ConfigurationComponent,
- canActivate: [AuthorizationGuard, AdminGuard]
+ canActivate: [AuthorizationGuard, AdminGuard, ProjectAdminGuard]
},
{
path: 'swagger',
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/core.module.ts b/services/self-service/src/main/resources/webapp/src/app/core/core.module.ts
index 3cfd504..20a4512 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/core.module.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/core.module.ts
@@ -50,6 +50,7 @@ import { ErrorInterceptor } from './interceptors/error.interceptor';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import {ConfigurationService} from './services/configutration.service';
import {AuditGuard, OdahuDeploymentService} from './services';
+import {ProjectAdminGuard} from './services/projectAdmin.guard';
@NgModule({
imports: [CommonModule],
@@ -67,6 +68,7 @@ export class CoreModule {
ApplicationSecurityService,
AuthorizationGuard,
AdminGuard,
+ ProjectAdminGuard,
AuditGuard,
CloudProviderGuard,
CheckParamsGuard,
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/healthStatus.service.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/healthStatus.service.ts
index 09f902e..204e712 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/services/healthStatus.service.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/healthStatus.service.ts
@@ -135,6 +135,10 @@ export class HealthStatusService {
this.appRoutingService.redirectToNoAccessPage();
return false;
}
+ if (parameter === 'project-admin' && !data.admin && data.projectAdmin) {
+ this.appRoutingService.redirectToNoAccessPage();
+ return false;
+ }
}
return true;
}));
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/projectAdmin.guard.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/projectAdmin.guard.ts
new file mode 100644
index 0000000..2e49f33
--- /dev/null
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/projectAdmin.guard.ts
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
+import { HealthStatusService } from './healthStatus.service';
+
+@Injectable()
+export class ProjectAdminGuard implements CanActivate {
+ constructor(private _healthStatus: HealthStatusService) { }
+
+ canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
+ return this._healthStatus.isPassageway('project-admin');
+ }
+}
diff --git a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
index 8a64a8c..aecaef1 100644
--- a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
+++ b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
@@ -99,9 +99,9 @@
<span *ngIf="isExpanded; else env">Environment Management</span>
<ng-template #env><i class="material-icons">settings</i></ng-template>
</a>
- <a class="sub-nav-item" [style.margin-left.px]="isExpanded ? '30' : '0'"
+ <a *ngIf="healthStatus?.admin" class="sub-nav-item" [style.margin-left.px]="isExpanded ? '30' : '0'"
[routerLink]="['/configuration']" [routerLinkActive]="['active']"
- [routerLinkActiveOptions]="{exact:true}">
+ [routerLinkActiveOptions]="{exact:true}" >
<span *ngIf="isExpanded; else env">Configuration</span>
<ng-template #env><i class="material-icons">settings</i></ng-template>
</a>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org