diff --git a/src/app/modules/shared/components/permissions-field/permissions-field.component.ts b/src/app/modules/shared/components/permissions-field/permissions-field.component.ts
index 7f3e0d7..59ba164 100644
--- a/src/app/modules/shared/components/permissions-field/permissions-field.component.ts
+++ b/src/app/modules/shared/components/permissions-field/permissions-field.component.ts
@@ -3,6 +3,10 @@ import {EmployeePermission, mapped_permissions} from "../../model/employee";
import {FormControl} from "@angular/forms";
import {AccountService} from "../../../accounts/services/account.service";
+// The current permissions field component. Workaround to be able to access a permission field in template. (See employee/AddComponent)
+// This workaround prevent the use of several permissions field component at the same time.
+export let currentPermissionsFieldComponent: PermissionsFieldComponent | null
+
@Component({
selector: 'cre-permissions-field',
templateUrl: './permissions-field.component.html',
@@ -35,6 +39,8 @@ export class PermissionsFieldComponent implements OnInit {
this.togglePermission(control, true)
})
}
+
+ currentPermissionsFieldComponent = this
}
togglePermission(permission: any, bypassValue?: boolean) {
diff --git a/src/app/modules/shared/components/subscribing.component.ts b/src/app/modules/shared/components/subscribing.component.ts
index d19ce1b..c73a786 100644
--- a/src/app/modules/shared/components/subscribing.component.ts
+++ b/src/app/modules/shared/components/subscribing.component.ts
@@ -4,6 +4,7 @@ import {Observable, Subject} from 'rxjs'
import {ActivatedRoute, Router} from '@angular/router'
import {UrlUtils} from '../utils/url.utils'
import {ErrorHandler, ErrorModel, ErrorService} from '../service/error.service'
+import {globalLoadingWheel} from './loading-wheel/loading-wheel.component'
export abstract class SubscribingComponent implements OnInit, OnDestroy {
protected subscribers$ = []
@@ -17,33 +18,48 @@ export abstract class SubscribingComponent implements OnInit, OnDestroy {
) {
}
- subscribe
(observable: Observable, resultConsumer: (T) => void, take_count = -1) {
+ subscribe(observable: Observable, resultConsumer: (T) => void, showWheel = false, take_count = -1) {
if (take_count >= 0) {
observable.pipe(take(take_count), takeUntil(this.destroy$))
} else {
observable.pipe(takeUntil(this.destroy$))
}
+ this.showLoadingWheel(showWheel)
this.subscribers$.push(observable.subscribe({
- next: resultConsumer,
- error: err => this.errorService.handleError(err)
+ next: t => {
+ resultConsumer(t)
+ this.hideLoadingWheel(showWheel)
+ },
+ error: err => {
+ this.errorService.handleError(err)
+ this.hideLoadingWheel(showWheel)
+ }
}))
}
- subscribeAndNavigate(observable: Observable, route: string) {
+ subscribeAndNavigate(observable: Observable, route: string, showWheel = true) {
this.subscribe(
observable,
() => this.urlUtils.navigateTo(route),
+ showWheel,
1
)
}
- subscribeEntityById(service: any, id: number, resultConsumer: (T) => void, notFoundRoute: string) {
+ subscribeEntityById(service: any, id: number, resultConsumer: (T) => void, notFoundRoute: string, showWheel = true) {
+ this.showLoadingWheel(showWheel)
this.subscribers$.push(service.getById(id)
.pipe(take(1), takeUntil(this.destroy$))
.subscribe({
- next: e => resultConsumer(e),
- error: err => this.handleNotFoundError(err, notFoundRoute)
+ next: e => {
+ resultConsumer(e)
+ this.hideLoadingWheel(showWheel)
+ },
+ error: err => {
+ this.handleNotFoundError(err, notFoundRoute)
+ this.hideLoadingWheel(showWheel)
+ }
}))
}
@@ -62,6 +78,18 @@ export abstract class SubscribingComponent implements OnInit, OnDestroy {
this.errorService.handleError(error)
}
}
+
+ protected showLoadingWheel(shouldShowWheel) {
+ if (shouldShowWheel) {
+ globalLoadingWheel.show()
+ }
+ }
+
+ protected hideLoadingWheel(shouldShowWheel) {
+ if (shouldShowWheel) {
+ globalLoadingWheel.hide()
+ }
+ }
}
export abstract class ErrorHandlingComponent extends SubscribingComponent implements ErrorHandler {
diff --git a/src/app/modules/shared/model/employee.ts b/src/app/modules/shared/model/employee.ts
index 711e30b..3fbb75d 100644
--- a/src/app/modules/shared/model/employee.ts
+++ b/src/app/modules/shared/model/employee.ts
@@ -3,6 +3,7 @@ export class Employee {
public id: number,
public firstName: string,
public lastName: string,
+ public explicitPermissions: EmployeePermission[],
public permissions: EmployeePermission[],
public group?: EmployeeGroup,
public lastLoginTime?: Date
diff --git a/src/app/modules/shared/service/api.service.ts b/src/app/modules/shared/service/api.service.ts
index 3deff1e..5389e7d 100644
--- a/src/app/modules/shared/service/api.service.ts
+++ b/src/app/modules/shared/service/api.service.ts
@@ -4,10 +4,10 @@ import {Observable, Subject} from 'rxjs'
import {environment} from '../../../../environments/environment'
import {AppState} from '../app-state'
import {Router} from '@angular/router'
-import {map, share, takeUntil} from 'rxjs/operators'
+import {map, share, takeUntil, tap} from 'rxjs/operators'
import {valueOr} from '../utils/utils'
import {ErrorService} from './error.service'
-import {AccountService} from '../../accounts/services/account.service'
+import {globalLoadingWheel} from '../components/loading-wheel/loading-wheel.component'
@Injectable({
providedIn: 'root'
diff --git a/src/app/modules/shared/shared.module.ts b/src/app/modules/shared/shared.module.ts
index 3d8407a..c2325f0 100644
--- a/src/app/modules/shared/shared.module.ts
+++ b/src/app/modules/shared/shared.module.ts
@@ -28,12 +28,14 @@ import {MatOptionModule} from '@angular/material/core'
import {MaterialFileInputModule} from 'ngx-material-file-input'
import {FileButtonComponent} from './file-button/file-button.component'
import {GlobalAlertHandlerComponent} from './components/global-alert-handler/global-alert-handler.component'
-import {MatSliderModule} from '@angular/material/slider';
-import { SliderFieldComponent } from './components/slider-field/slider-field.component'
+import {MatSliderModule} from '@angular/material/slider'
+import {SliderFieldComponent} from './components/slider-field/slider-field.component'
+import {LoadingWheelComponent} from './components/loading-wheel/loading-wheel.component'
+import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'
@NgModule({
- declarations: [HeaderComponent, EmployeeInfoComponent, LabeledIconComponent, ConfirmBoxComponent, PermissionsListComponent, PermissionsFieldComponent, NavComponent, EntityListComponent, EntityAddComponent, EntityEditComponent, FileButtonComponent, GlobalAlertHandlerComponent, SliderFieldComponent],
+ declarations: [HeaderComponent, EmployeeInfoComponent, LabeledIconComponent, ConfirmBoxComponent, PermissionsListComponent, PermissionsFieldComponent, NavComponent, EntityListComponent, EntityAddComponent, EntityEditComponent, FileButtonComponent, GlobalAlertHandlerComponent, SliderFieldComponent, LoadingWheelComponent],
exports: [
CommonModule,
HttpClientModule,
@@ -60,7 +62,8 @@ import { SliderFieldComponent } from './components/slider-field/slider-field.com
EntityAddComponent,
EntityEditComponent,
FileButtonComponent,
- GlobalAlertHandlerComponent
+ GlobalAlertHandlerComponent,
+ LoadingWheelComponent
],
imports: [
MatTabsModule,
@@ -76,6 +79,7 @@ import { SliderFieldComponent } from './components/slider-field/slider-field.com
MatSelectModule,
MatOptionModule,
MatSliderModule,
+ MatProgressSpinnerModule,
ReactiveFormsModule,
RouterModule,
CommonModule,
diff --git a/src/styles.sass b/src/styles.sass
index 5ece4d2..2e6f3f5 100644
--- a/src/styles.sass
+++ b/src/styles.sass
@@ -200,7 +200,7 @@ div.empty
left: 0
background-color: black
opacity: 0.4
- z-index: -1
+ z-index: 10
.color-warning
color: #fdd835