Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
feee5e3
First changes to management of kombit users.
AugustHA-Iterator Jan 6, 2022
97a552e
i18n translations
AugustHA-Iterator Jan 7, 2022
ba61ff9
Made the form page for entering email and wanted organizations. Redir…
AugustHA-Iterator Jan 20, 2022
6e88ad1
Merge branch 'stage' into feature/IOT-1249_ManageKombitUsers
AugustHA-Iterator Jan 20, 2022
9377428
NewKombitUser page done, ready for user information page
AugustHA-Iterator Jan 20, 2022
b6132fa
User page. Need to fix console error "undefined length"
AugustHA-Iterator Jan 25, 2022
fac5dd7
Merge branch 'stage' into feature/IOT-1249_ManageKombitUsers
AugustHA-Iterator Jan 25, 2022
746399f
Changed name so it's more clear that it's requestedOrganizations and …
AugustHA-Iterator Jan 31, 2022
e3fa2a5
moved help and log out buttons to top right corner
AugustHA-Iterator Feb 7, 2022
ad2bfff
Next step is to fit padding in top bar. Styling.
AugustHA-Iterator Feb 7, 2022
112f210
Css styling
AugustHA-Iterator Feb 14, 2022
931c34f
removing if statement. Top bar should visible when first time enterin…
AugustHA-Iterator Feb 14, 2022
e97d9bf
Sending an array of ids instead of org object. OBS on undefined on find.
AugustHA-Iterator Feb 21, 2022
572f4f3
fixed undefined on find. Changed some variable names. Removed search …
AugustHA-Iterator Feb 28, 2022
58e7036
Made admin/users so there is two tables. One for existing users and o…
AugustHA-Iterator Feb 28, 2022
f8b5ca7
Made acceptuser page when some user is requesting access to organizat…
AugustHA-Iterator Mar 14, 2022
f05bc67
Can only press once. Also changed back so new-user back is only calle…
AugustHA-Iterator Apr 4, 2022
603f3f6
Changed some endpoints so page is allowed
AugustHA-Iterator Apr 27, 2022
59c25f4
Merge branch 'stage' into feature/IOT-1249_ManageKombitUsers
AugustHA-Iterator Apr 28, 2022
1f88eb0
Changed RejectUserDto to have all the info about the rejected user
May 17, 2022
ba80f31
Merge remote-tracking branch 'origin/stage' into feature/IOT-1249_Man…
May 17, 2022
bc5cc58
Minor code style improvements
May 17, 2022
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
2 changes: 2 additions & 0 deletions src/app/admin/admin-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { UsersComponent } from './users/users.component';
import { ApiKeyComponent } from './api-key/api-key.component';
import { ApiKeyListComponent } from './api-key/api-key-list/api-key-list.component';
import { ApiKeyEditComponent } from './api-key/api-key-edit/api-key-edit.component';
import { AcceptUserComponent } from './users/accept-user/accept-user.component';


const adminRoutes: Routes = [
Expand All @@ -32,6 +33,7 @@ const adminRoutes: Routes = [
{ path: 'new-user', component: UserEditComponent },
{ path: ':user-id', component: UserDetailComponent },
{ path: ':user-id/edit-user', component: UserEditComponent },
{ path: 'accept-user/:user-id/:org-id', component: AcceptUserComponent }
]
},
{
Expand Down
4 changes: 4 additions & 0 deletions src/app/admin/admin.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { ApiKeyComponent } from './api-key/api-key.component';
import { ApiKeyListComponent } from './api-key/api-key-list/api-key-list.component';
import { ApiKeyTableComponent } from './api-key/api-key-list/api-key-table/api-key-table.component';
import { ApiKeyEditComponent } from './api-key/api-key-edit/api-key-edit.component';
import { AwaitingUsersTableComponent } from './users/user-list/awaiting-users-table/awaiting-users-table.component';
import { AcceptUserComponent } from './users/accept-user/accept-user.component';

@NgModule({
declarations: [
Expand All @@ -54,6 +56,8 @@ import { ApiKeyEditComponent } from './api-key/api-key-edit/api-key-edit.compone
ApiKeyListComponent,
ApiKeyTableComponent,
ApiKeyEditComponent,
AwaitingUsersTableComponent,
AcceptUserComponent,
],
imports: [
AdminRoutingModule,
Expand Down
32 changes: 20 additions & 12 deletions src/app/admin/organisation/organisation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ import {
} from './organisation.model';
import { map, shareReplay } from 'rxjs/operators';
import { UserMinimalService } from '../users/user-minimal.service';
import { UpdateUserOrgsDto } from '../users/user.model';

@Injectable({
providedIn: 'root',
})
export class OrganisationService {
URL = 'organization';
URLMINIMAL = 'organization/minimal';
URLMINIMAL_NEWKOMBIT = 'kombitCreation/minimal';

constructor(
private restService: RestService,
private userMinimalService: UserMinimalService) { }
private userMinimalService: UserMinimalService
) {}

post(body: Organisation): Observable<OrganisationResponse> {
return this.restService.post(this.URL, body);
Expand All @@ -32,27 +35,32 @@ export class OrganisationService {
}

getOne(id: number): Observable<OrganisationResponse> {
return this.restService.get(this.URL, {}, id)
.pipe(
map(
(response: OrganisationResponse) => {
response.createdByName = this.userMinimalService.getUserNameFrom(response.createdBy);
response.updatedByName = this.userMinimalService.getUserNameFrom(response.updatedBy);
return response;
}
)
);
return this.restService.get(this.URL, {}, id).pipe(
map((response: OrganisationResponse) => {
response.createdByName = this.userMinimalService.getUserNameFrom(
response.createdBy
);
response.updatedByName = this.userMinimalService.getUserNameFrom(
response.updatedBy
);
return response;
})
);
}

getMinimal(): Observable<OrganisationGetMinimalResponse> {
return this.restService.get(this.URLMINIMAL, {}).pipe(shareReplay(1));
}

getMinimalNoPerm(): Observable<OrganisationGetMinimalResponse> {
return this.restService.get(this.URLMINIMAL_NEWKOMBIT, {}).pipe(shareReplay(1));
}

getMultiple(
limit: number = 1000,
offset: number = 0,
orderByColumn?: string,
orderByDirection?: string,
orderByDirection?: string
): Observable<OrganisationGetManyResponse> {
return this.restService.get(this.URL, {
limit,
Expand Down
6 changes: 6 additions & 0 deletions src/app/admin/permission/permission.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export class PermissionRequest {
automaticallyAddNewApplications = true;
}

export class PermissionRequestAcceptUser {
organizationId: number;
userId: number;
level: PermissionType;
}

export interface PermissionResponse {
type: PermissionType;
name: string;
Expand Down
7 changes: 7 additions & 0 deletions src/app/admin/permission/permission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
PermissionGetManyResponse,
PermissionResponse,
PermissionRequest,
PermissionRequestAcceptUser,
} from './permission.model';
import { map } from 'rxjs/operators';
import { UserMinimalService } from '../users/user-minimal.service';
Expand All @@ -25,6 +26,12 @@ export class PermissionService {
});
}

createPermissionAcceptUser(body: PermissionRequestAcceptUser): Observable<PermissionResponse> {
return this.restService.put(this.endpoint + '/acceptUser', body, undefined, {
observe: 'response',
});
}

updatePermission(
body: PermissionRequest,
id: number
Expand Down
70 changes: 70 additions & 0 deletions src/app/admin/users/accept-user/accept-user.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<div *ngIf="user">
<app-top-bar
[backButtonTitle]="backButtonTitle"
[title]="title"
></app-top-bar>

<form (ngSubmit)="onSubmit()" class="os2-form p-3 mt-4">
<div *ngIf="errorMessages" class="error-messages p-3">
<ul class="mb-0">
<li *ngFor="let error of errorMessages">
{{ error | translate }}
</li>
</ul>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="jumbotron">
<h3>
{{ 'USERS.ACCEPT-USER.QUESTION-ACCEPT' | translate }}
{{ user.name }}
</h3>
<mat-divider></mat-divider>

<div class="form-group mt-3 col-12">
<label class="form-label" for="level">{{
'PERMISSION.EDIT.TYPE' | translate
}}</label
>*
<select
id="level"
class="form-select"
name="level"
[(ngModel)]="permission.level"
required
[ngClass]="{
'is-invalid':
formFailedSubmit && errorFields.includes('organizationId'),
'is-valid':
formFailedSubmit && !errorFields.includes('organizationId')
}"
placeholder="'PERMISSION.EDIT.TYPE-PLACEHOLDER' | translate"
>
<option
*ngFor="let level of allowedLevels()"
[value]="level"
[selected]="level === permission.level"
>
{{ level }}</option
>
</select>
</div>
<div class="form-group mt-5">
<button
(click)="routeBack()"
class="btn btn-secondary"
type="button"
>
{{ 'GEN.CANCEL' | translate }}
</button>
<button class="btn btn-primary ml-2" type="submit">
{{ 'USERS.ACCEPT-USER.ACCEPT' | translate }}
</button>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
Empty file.
98 changes: 98 additions & 0 deletions src/app/admin/users/accept-user/accept-user.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import {
PermissionRequestAcceptUser,
PermissionType,
} from '@app/admin/permission/permission.model';
import { TranslateService } from '@ngx-translate/core';
import { ErrorMessageService } from '@shared/error-message.service';
import { Subscription } from 'rxjs';
import { UserResponse } from '../user.model';
import { UserService } from '../user.service';
import { Location } from '@angular/common';
import { PermissionService } from '@app/admin/permission/permission.service';

@Component({
selector: 'app-accept-user',
templateUrl: './accept-user.component.html',
styleUrls: ['./accept-user.component.scss'],
})
export class AcceptUserComponent implements OnInit {
public backButtonTitle: string;
permission = new PermissionRequestAcceptUser();
public title: string;
userId: number;
subscription: Subscription;
user: UserResponse;
errorFields: string[];
organizationId: number;
public formFailedSubmit = false;
errorMessages: any;

constructor(
private userService: UserService,
private location: Location,
private translate: TranslateService,
private route: ActivatedRoute,
private errorMessageService: ErrorMessageService,
private permissionService: PermissionService
) {}

ngOnInit(): void {
this.userId = +this.route.snapshot.paramMap.get('user-id');
this.organizationId = +this.route.snapshot.paramMap.get('org-id');
if (this.userId) {
this.getUser(this.userId);
}

this.translate
.get(['GEN.BACK', 'USERS.ACCEPT-USER.ACCEPT'])
.subscribe((translations) => {
this.backButtonTitle = translations['GEN.BACK'];
this.title = translations['USERS.ACCEPT-USER.ACCEPT'];
});
this.permission.userId = this.userId;
this.permission.organizationId = this.organizationId;
}

private getUser(id: number) {
this.subscription = this.userService
.getOne(id, false)
.subscribe((response) => {
this.user = response;
});
}

allowedLevels() {
return [
PermissionType.OrganizationAdmin,
PermissionType.Write,
PermissionType.Read,
];
}

private showError(err: HttpErrorResponse) {
const result = this.errorMessageService.handleErrorMessageWithFields(err);
this.errorFields = result.errorFields;
this.errorMessages = result.errorMessages;
}

routeBack(): void {
this.location.back();
}

onSubmit(): void {
this.permissionService
.createPermissionAcceptUser(this.permission)
.subscribe(
() => {
this.routeBack();
},
(error: HttpErrorResponse) => {
console.log(error);
this.showError(error);
}
);
}
}
80 changes: 80 additions & 0 deletions src/app/admin/users/new-kombit-user-page/new-user.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<app-top-bar></app-top-bar>

<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="jumbotron">
<h1>
{{ 'NEW_USER.FIRST_LOGIN' | translate }}
</h1>
<form (ngSubmit)="onSubmit()" #newUserForm="ngForm" class="p-3 mt-4">
<div *ngIf="errorMessages" class="error-messages p-3">
<ul class="mb-0">
<li *ngFor="let error of errorMessages">
{{ error | translate }}
</li>
</ul>
</div>
<div class="row">
<div class="form-group mt-3">
<label class="form-label" for="createNewKombitUserDto.email">{{
'USERS.EMAIL' | translate
}}</label
>*

<input
type="email"
class="form-control"
id="email"
maxlength="50"
required
name="email"
[(ngModel)]="createNewKombitUserFromFrontend.email"
[ngClass]="{
'is-invalid':
formFailedSubmit && errorFields.includes('email'),
'is-valid': formFailedSubmit && !errorFields.includes('email')
}"
/>
</div>

<div class="form-group mt-3 col-12">
<label class="form-label" for="groupType">{{
'NAV.ORGANISATIONS' | translate
}}</label
>*
<mat-form-field appearance="outline">
<mat-label>{{ 'NAV.ORGANISATIONS' | translate }}</mat-label>
<mat-select
multiple
name="organisations"
[compareWith]="compare"
[(ngModel)]="
createNewKombitUserFromFrontend.requestedOrganizations
"
panelClass="overflow-x-hidden"
aria-required="true"
>
<mat-select-search
[formControl]="organisationsFilterCtrl"
></mat-select-search>

<mat-option
*ngFor="let org of filteredOrganisations | async"
[value]="org"
>{{ org.name }}</mat-option
>
</mat-select>
</mat-form-field>
</div>
</div>
<div class="form-group mt-3">
<button class="btn btn-primary ml-2" type="submit">
{{ 'USERS.SAVE' | translate }}
</button>
</div>
</form>
</div>
</div>
</div>
</div>
Empty file.
Loading