diff --git a/src/app/admin/api-key/api-key-edit/api-key-edit.component.html b/src/app/admin/api-key/api-key-edit/api-key-edit.component.html index 78251213..02c1d342 100644 --- a/src/app/admin/api-key/api-key-edit/api-key-edit.component.html +++ b/src/app/admin/api-key/api-key-edit/api-key-edit.component.html @@ -14,18 +14,18 @@ * @@ -35,11 +35,11 @@ * {{ permission.name }} @@ -48,6 +48,21 @@ +
+ + + {{ "API-KEY.EDIT.EXPIRATION-DATE-PLACEHOLDER" | translate }} + + + + {{ "API-KEY.EDIT.EXPIRATION-DATE-DESCRIPTION" | translate }} + +
+
@@ -60,34 +60,35 @@ *
- {{ "QUESTION.PERMISSION.SELECT-PERMISSION" | translate }}* {{ permission.name }} @@ -96,14 +97,32 @@
+
+ + + {{ "API-KEY.EDIT.EXPIRATION-DATE-PLACEHOLDER" | translate }} + + + + {{ "USERS.FORM.EXPIRATION-DATE-DESCRIPTION" | translate }} + +
+
- {{ "USERS.FORM.ACTIVE" | translate }}
-
+
- {{ "USERS.FORM.GLOBAL-ADMIN" | translate }}
diff --git a/src/app/admin/users/user-edit/user-edit.component.ts b/src/app/admin/users/user-edit/user-edit.component.ts index 65a9d256..e1fc0cc0 100644 --- a/src/app/admin/users/user-edit/user-edit.component.ts +++ b/src/app/admin/users/user-edit/user-edit.component.ts @@ -1,6 +1,6 @@ import { HttpErrorResponse } from "@angular/common/http"; import { Component, OnDestroy, OnInit } from "@angular/core"; -import { UntypedFormControl, UntypedFormGroup } from "@angular/forms"; +import { FormControl, UntypedFormControl, UntypedFormGroup } from "@angular/forms"; import { ActivatedRoute } from "@angular/router"; import { UserRequest } from "../user.model"; import { TranslateService } from "@ngx-translate/core"; @@ -36,6 +36,8 @@ export class UserEditComponent implements OnInit, OnDestroy { public isKombit: boolean; public canEdit: boolean; public permissionMultiCtrl: UntypedFormControl = new UntypedFormControl(); + serializedExpirationDate = new FormControl(undefined); + protected readonly now = new Date(); private _onDestroy = new Subject(); constructor( @@ -67,6 +69,35 @@ export class UserEditComponent implements OnInit, OnDestroy { this.getPermissions(this.sharedVariableService.getUserInfo().user.id); } + amIGlobalAdmin() { + this.isGlobalAdmin = this.meService.hasGlobalAdmin(); + } + + onSubmit(): void { + if (this.user.id) { + this.update(); + } else { + this.create(); + } + } + + routeBack(): void { + this.location.back(); + } + + public compare(matOptionValue: number, ngModelObject: number): boolean { + return matOptionValue === ngModelObject; + } + + ngOnDestroy() { + // prevent memory leak by unsubscribing + if (this.permissionsSubscription) { + this.permissionsSubscription.unsubscribe(); + } + this._onDestroy.next(); + this._onDestroy.complete(); + } + private getUser(id: number) { this.subscription = this.userService.getOne(id).subscribe(response => { this.user.name = response.name; @@ -76,16 +107,16 @@ export class UserEditComponent implements OnInit, OnDestroy { this.user.globalAdmin = response.permissions.some(perm => perm.name === PermissionType.GlobalAdmin); this.isKombit = response.nameId != null; this.user.permissionIds = response.permissions.map(pm => pm.id); + if (response.expiresOn) { + this.serializedExpirationDate.setValue(response.expiresOn); + } // We cannot set the password. }); } - amIGlobalAdmin() { - this.isGlobalAdmin = this.meService.hasGlobalAdmin(); - } - private create(): void { + this.user.expiresOn = this.serializedExpirationDate.value; this.userService.post(this.user).subscribe( () => { this.routeBack(); @@ -97,6 +128,7 @@ export class UserEditComponent implements OnInit, OnDestroy { } private update(): void { + this.user.expiresOn = this.serializedExpirationDate.value; this.userService.put(this.user, this.id).subscribe( response => { this.routeBack(); @@ -107,14 +139,6 @@ export class UserEditComponent implements OnInit, OnDestroy { ); } - onSubmit(): void { - if (this.user.id) { - this.update(); - } else { - this.create(); - } - } - private showError(error: HttpErrorResponse) { this.errorFields = []; this.errorMessages = []; @@ -135,14 +159,6 @@ export class UserEditComponent implements OnInit, OnDestroy { this.formFailedSubmit = true; } - routeBack(): void { - this.location.back(); - } - - public compare(matOptionValue: number, ngModelObject: number): boolean { - return matOptionValue === ngModelObject; - } - private getPermissions(userId: number) { this.permissionsSubscription = this.permissionService .getPermissionsWithoutUsers(this.meService.hasGlobalAdmin() ? undefined : userId) @@ -153,13 +169,4 @@ export class UserEditComponent implements OnInit, OnDestroy { } }); } - - ngOnDestroy() { - // prevent memory leak by unsubscribing - if (this.permissionsSubscription) { - this.permissionsSubscription.unsubscribe(); - } - this._onDestroy.next(); - this._onDestroy.complete(); - } } diff --git a/src/app/admin/users/user-list/user-table/user-table.component.html b/src/app/admin/users/user-list/user-table/user-table.component.html index c3461c8b..8c9e66e7 100644 --- a/src/app/admin/users/user-list/user-table/user-table.component.html +++ b/src/app/admin/users/user-list/user-table/user-table.component.html @@ -1,15 +1,15 @@
-
+
- +
- - @@ -17,20 +17,20 @@ - - - - - + + + + + + - - - + - - + +
+ {{ "USERS.NAME" | translate }} - + + {{ element.name }} + {{ "USERS.EMAIL" | translate }} +

{{ element.email }}

+ {{ "USERS.GLOBALADMIN" | translate }} +

{{ ((element.permissions | isGlobalAdmin) ? "USERS.GLOBAL_ADMIN.TRUE" : "USERS.GLOBAL_ADMIN.FALSE") | translate @@ -41,20 +41,30 @@ -

+ {{ "USERS.STATUS" | translate }} +

{{ element.active | activeDeactive }}

+ {{ "API-KEY.EXPIRES-ON" | translate }} + + {{ (element.expiresOn | dateOnly) ?? '-' }} + + {{ "USERS.LOGIN" | translate }} +

{{ element.lastLogin | tableDatePipe }}

@@ -66,22 +76,22 @@ -
+
diff --git a/src/app/admin/users/user-list/user-table/user-table.component.ts b/src/app/admin/users/user-list/user-table/user-table.component.ts index 823337ec..8176a7c6 100644 --- a/src/app/admin/users/user-list/user-table/user-table.component.ts +++ b/src/app/admin/users/user-list/user-table/user-table.component.ts @@ -16,7 +16,7 @@ import { MeService } from "@shared/services/me.service"; styleUrls: ["./user-table.component.scss"], }) export class UserTableComponent implements AfterViewInit { - displayedColumns: string[] = ["name", "email", "global", "status", "lastLogin", "menu"]; + displayedColumns: string[] = ["name", "email", "global", "status", "expiresOn", "lastLogin", "menu"]; data: UserResponse[]; public pageSize = environment.tablePageSize; diff --git a/src/app/admin/users/user.model.ts b/src/app/admin/users/user.model.ts index d2fb680e..745a57a0 100644 --- a/src/app/admin/users/user.model.ts +++ b/src/app/admin/users/user.model.ts @@ -9,7 +9,8 @@ export class UserRequest { active: boolean; globalAdmin: boolean; showWelcomeScreen: boolean; - permissionIds: number[] + permissionIds: number[]; + expiresOn?: Date; } export interface UserResponse { @@ -29,6 +30,7 @@ export interface UserResponse { awaitingConfirmation: boolean; showWelcomeScreen: boolean; requestedOrganizations: OrganisationResponse[]; + expiresOn?: Date; } export interface UserResponsePerRequestedOrganization extends Omit { diff --git a/src/app/shared/pipes/custom-date.pipe.ts b/src/app/shared/pipes/custom-date.pipe.ts index fe6fb94b..9a15624a 100644 --- a/src/app/shared/pipes/custom-date.pipe.ts +++ b/src/app/shared/pipes/custom-date.pipe.ts @@ -33,7 +33,7 @@ export class CustomDatePipeWithSecondsNoPrefix extends DatePipe implements PipeT }) export class CustomTableDatePipe extends DatePipe implements PipeTransform { transform(value: any, args?: any): any { - return super.transform(value, "dd MMM, yyyy - HH:mm"); + return super.transform(value, "dd-MM-yyyy kl. HH:mm"); } } @@ -42,7 +42,7 @@ export class CustomTableDatePipe extends DatePipe implements PipeTransform { }) export class CustomTableDateWithSecondsPipe extends DatePipe implements PipeTransform { transform(value: any, args?: any): any { - return super.transform(value, "dd MMM, yyyy - HH:mm:ss"); + return super.transform(value, "dd-MM-yyyy - HH:mm:ss"); } } @@ -51,6 +51,6 @@ export class CustomTableDateWithSecondsPipe extends DatePipe implements PipeTran }) export class DateOnlyPipe extends DatePipe implements PipeTransform { transform(value: any, args?: any): any { - return super.transform(value, "dd MMM, yyyy"); + return super.transform(value, "dd-MM-yyyy"); } } diff --git a/src/assets/i18n/da.json b/src/assets/i18n/da.json index 8a5111a2..5511211b 100644 --- a/src/assets/i18n/da.json +++ b/src/assets/i18n/da.json @@ -1184,7 +1184,8 @@ "PASSWORD-PLACEHOLDER": "Indtast eller redigér password", "ACTIVE": "Aktiveret", "GLOBAL-ADMIN": "Skal den nye bruger være global administrator?", - "SAVE": "Gem Bruger" + "SAVE": "Gem Bruger", + "EXPIRATION-DATE-DESCRIPTION": "Bruger deaktiveres automatisk på denne dato" }, "DETAIL": { "DROPDOWN": "Håndter Bruger", @@ -1315,12 +1316,17 @@ "NAME-PLACEHOLDER": "Indtast nøglens navn", "CANCEL": "Annuller", "SAVE": "Gem nøgle", - "CREATE-API-KEY": "Opret nøgle" + "CREATE-API-KEY": "Opret nøgle", + "EXPIRATION-DATE": "Deaktiveringsdato", + "EXPIRATION-DATE-PLACEHOLDER": "Deaktiveringsdato", + "EXPIRATION-DATE-DESCRIPTION": "Nøgle deaktiveres automatisk på denne dato" }, "TABLE-ROW": { "EDIT": "Redigér", "DELETE": "Slet" - } + }, + "STATUS": "Status", + "EXPIRES-ON": "Deaktiveringsdato" }, "NoUsersAdded": "Ingen brugergrupper er tilføjet", "FIWARE": {