Skip to content

Commit

Permalink
Merge branch 'stage' for release v.1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fcv-iteratorIt committed Jul 6, 2023
2 parents 874c661 + 5268542 commit 54244cc
Show file tree
Hide file tree
Showing 10 changed files with 221 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@
<mat-form-field>
<label class="form-label" for="name">{{'PERMISSION.EDIT.APPS' | translate}}</label>
<div class="col-12">
<mat-select [formControl]="applicationMultiCtrl" [multiple]="true"
panelClass="overflow-x-hidden" [(value)]="permission.applicationIds" id="applicationIds"
name="applicationIds" #multiSelect [compareWith]="compare">
<mat-select
id="applicationIds"
[formControl]="applicationMultiCtrl"
[multiple]="true"
panelClass="overflow-x-hidden"
[(value)]="permission.applicationIds"
name="applicationIds"
#multiSelect
[compareWith]="compare">
<app-mat-select-search [formControl]="applicationMultiFilterCtrl"></app-mat-select-search>
<mat-option *ngFor="let app of filteredApplicationsMulti | async" [value]="app.id">
{{app.name}}
Expand Down
150 changes: 75 additions & 75 deletions src/app/admin/permission/permission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,94 @@ import { Injectable } from '@angular/core';
import { RestService } from '../../shared/services/rest.service';
import { Observable } from 'rxjs';
import {
PermissionGetManyResponse,
PermissionResponse,
PermissionRequest,
PermissionRequestAcceptUser,
PermissionGetManyResponse,
PermissionResponse,
PermissionRequest,
PermissionRequestAcceptUser,
} from './permission.model';
import { map } from 'rxjs/operators';
import { UserMinimalService } from '../users/user-minimal.service';

@Injectable({
providedIn: 'root',
providedIn: 'root',
})
export class PermissionService {
endpoint = 'permission';
constructor(
private restService: RestService,
private userMinimalService: UserMinimalService
) {}
endpoint = 'permission';
constructor(
private restService: RestService,
private userMinimalService: UserMinimalService
) {}

createPermission(body: PermissionRequest): Observable<PermissionResponse> {
return this.restService.post(this.endpoint, body, {
observe: 'response',
});
}
createPermission(body: PermissionRequest): Observable<PermissionResponse> {
return this.restService.post(this.endpoint, body, {
observe: 'response',
});
}

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

updatePermission(
body: PermissionRequest,
id: number
): Observable<PermissionResponse> {
return this.restService.put(this.endpoint, body, id, {
observe: 'response',
});
}
updatePermission(
body: PermissionRequest,
id: number
): Observable<PermissionResponse> {
return this.restService.put(this.endpoint, body, id, {
observe: 'response',
});
}

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

getPermissions(
limit: number = 1000,
offset: number = 0,
orderByColumn?: string,
orderByDirection?: string,
userId?: number,
organisationId?: number
): Observable<PermissionGetManyResponse> {
if (userId) {
return this.restService.get(this.endpoint, {
limit: limit,
offset: offset,
orderOn: orderByColumn,
sort: orderByDirection,
userId: userId,
});
} else if (organisationId) {
return this.restService.get(this.endpoint, {
limit: limit,
offset: offset,
orderOn: orderByColumn,
sort: orderByDirection,
organisationId: organisationId,
});
} else {
return this.restService.get(this.endpoint, {
limit: limit,
offset: offset,
orderOn: orderByColumn,
sort: orderByDirection,
});
}
getPermissions(
limit: number = 1000,
offset: number = 0,
orderByColumn?: string,
orderByDirection?: string,
userId?: number,
organisationId?: number
): Observable<PermissionGetManyResponse> {
if (userId || organisationId) {
return this.restService.get(this.endpoint, {
limit: limit,
offset: offset,
orderOn: orderByColumn,
sort: orderByDirection,
userId: userId,
organisationId: organisationId,
});
} else {
return this.restService.get(this.endpoint, {
limit: limit,
offset: offset,
orderOn: orderByColumn,
sort: orderByDirection,
});
}
}

deletePermission(id: number) {
return this.restService.delete(this.endpoint, id);
}
deletePermission(id: number) {
return this.restService.delete(this.endpoint, id);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div *ngIf="application">
<app-top-bar [data]="application" [backButton]="backButton" [subPage]="true"
[addDetailDowndown]="true" [dropDownButton]="dropdownButton" (deleteSelectedInDropdown)="onDeleteApplication()"
[canEdit]="canEdit">
[addDetailDowndown]="true" [dropDownButton]="dropdownButton"
(deleteSelectedInDropdown)="onDeleteApplication()"
[canEdit]="canEdit">
</app-top-bar>
<div class="container-fluid">
<div class="row">
Expand All @@ -15,17 +16,20 @@ <h3>{{ 'APPLICATION.DETAILS' | translate }}</h3>
<p *ngIf="application.description">
<strong>{{ 'APPLICATION.DESCRIPTION' | translate }}</strong></p>
<pre><p>{{application.description}}</p></pre>
<app-metadata-details [status]="application.status" [startDate]="application.startDate"
[endDate]="application.endDate"
[category]="application.category"
[owner]="application.owner"
[contactPerson]="application.contactPerson"
[contactEmail]="application.contactEmail"
[contactPhone]="application.contactPhone"
[personalData]="application.personalData"
[hardware]="application.hardware"
[controlledProperties]="application.controlledProperties"
[deviceTypes]="application.deviceTypes"
<app-metadata-details
[permissions]="application.permissions"
[status]="application.status"
[startDate]="application.startDate"
[endDate]="application.endDate"
[category]="application.category"
[owner]="application.owner"
[contactPerson]="application.contactPerson"
[contactEmail]="application.contactEmail"
[contactPhone]="application.contactPhone"
[personalData]="application.personalData"
[hardware]="application.hardware"
[controlledProperties]="application.controlledProperties"
[deviceTypes]="application.deviceTypes"
></app-metadata-details>
</div>
</div>
Expand All @@ -36,7 +40,7 @@ <h3>{{ 'APPLICATION.DETAILS' | translate }}</h3>
[routerLink]="link.link"
routerLinkActive #rla="routerLinkActive"
[active]="rla.isActive"
>{{ link.label | translate }}</a>
>{{ link.label | translate }}</a>
</nav>
<router-outlet></router-outlet>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/app/applications/application.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Organisation } from '../admin/organisation/organisation.model';
import { ApplicationStatus } from './enums/status.enum';
import { IotDevice } from './iot-devices/iot-device.model';
import { ApplicationDeviceType } from './models/application-device-type.model';
import { PermissionResponse } from '@app/admin/permission/permission.model';

export class Application {
public id: number;
Expand All @@ -30,6 +31,8 @@ export class Application {
public hardware?: string;
public controlledProperties?: ControlledProperty[];
public deviceTypes?: ApplicationDeviceType[];
public permissions: PermissionResponse[];
public permissionIds: number[];
}

export class ApplicationRequest {
Expand All @@ -48,6 +51,7 @@ export class ApplicationRequest {
public hardware?: string;
public controlledProperties?: ControlledPropertyTypes[];
public deviceTypes?: ApplicationDeviceTypeUnion[];
public permissionIds: number[];
}

export interface ApplicationData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,27 @@
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('description'), 'is-valid' : formFailedSubmit && !errorFields.includes('description')}"></textarea>
</div>

<div class="form-group mt-3 col-12">
<label class="form-label" for="userGroup">{{'QUESTION.APPLICATION.ADD-PERMISSION' | translate}}</label>
<mat-select
id="userGroup"
class="form-control"
[formControl]="permissionMultiCtrl"
[multiple]="true"
panelClass="overflow-x-hidden"
[(value)]="application.permissionIds"
[compareWith]="compare">
<app-mat-select-search [formControl]="permissionMultiFilterCtrl"></app-mat-select-search>
<mat-option *ngFor="let permission of filteredPermissionsMulti | async" [value]="permission.id">
{{permission.name}}
</mat-option>
</mat-select>
<mat-hint>{{'QUESTION.APPLICATION.PERMISSION-HINT' | translate}}</mat-hint>
</div>

<div class="form-group mt-3">
<label class="form-label" for="application.status">{{'APPLICATION.METADATA-FIELD.STATUS' | translate}}</label>
<mat-select class="form-control" name="application.statusOptions" [(ngModel)]="application.status"
<label class="form-label" for="application.statusOptions">{{'APPLICATION.METADATA-FIELD.STATUS' | translate}}</label>
<mat-select class="form-control" id="application.statusOptions" name="application.statusOptions" [(ngModel)]="application.status"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('application.status'), 'is-valid' : formFailedSubmit && !errorFields.includes('application.status')}">
<mat-option *ngFor="let statusOption of statuses" [value]="statusOption.value">
{{statusOption.label}}
Expand All @@ -37,7 +55,7 @@
<div class="form-group mt-3">
<label class="form-label" for="application.startDate">{{'APPLICATION.METADATA-FIELD.START-DATE' |
translate}}</label>
<mat-form-field appearance="fill">
<mat-form-field appearance="fill" id="application.startDate">
<mat-label>{{'QUESTION.APPLICATION.START-DATE-PLACEHOLDER' | translate}}</mat-label>
<input matInput [max]="serializedEndDate.value" [matDatepicker]="startDatePicker"
[formControl]="serializedStartDate"
Expand All @@ -50,7 +68,7 @@

<div class="form-group mt-3">
<label class="form-label" for="application.endDate">{{'APPLICATION.METADATA-FIELD.END-DATE' | translate}}</label>
<mat-form-field appearance="fill">
<mat-form-field appearance="fill" id="application.endDate">
<mat-label>{{'QUESTION.APPLICATION.END-DATE-PLACEHOLDER' | translate}}</mat-label>
<input matInput [min]="serializedStartDate.value" [matDatepicker]="endDatePicker"
[formControl]="serializedEndDate"
Expand All @@ -62,23 +80,23 @@
</div>

<div class="form-group mt-3">
<label class="form-label" for="application.category">{{'APPLICATION.METADATA-FIELD.CATEGORY' | translate}}</label>
<label class="form-label" for="category">{{'APPLICATION.METADATA-FIELD.CATEGORY' | translate}}</label>
<input type="text" class="form-control" id="category" name="category"
[placeholder]="'QUESTION.APPLICATION.CATEGORY-PLACEHOLDER' | translate" maxlength="100"
[(ngModel)]="application.category"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('application.category'), 'is-valid' : formFailedSubmit && !errorFields.includes('application.category')}">
</div>

<div class="form-group mt-3">
<label class="form-label" for="application.owner">{{'APPLICATION.METADATA-FIELD.OWNER' | translate}}</label>
<label class="form-label" for="owner">{{'APPLICATION.METADATA-FIELD.OWNER' | translate}}</label>
<input type="text" class="form-control" id="owner" name="owner"
[placeholder]="'QUESTION.APPLICATION.OWNER-PLACEHOLDER' | translate" maxlength="100"
[(ngModel)]="application.owner"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('application.owner'), 'is-valid' : formFailedSubmit && !errorFields.includes('application.owner')}">
</div>

<div class="form-group mt-3">
<label class="form-label" for="application.contactPerson">{{'APPLICATION.METADATA-FIELD.CONTACT-PERSON' |
<label class="form-label" for="contactPerson">{{'APPLICATION.METADATA-FIELD.CONTACT-PERSON' |
translate}}</label>
<input type="text" class="form-control" id="contactPerson" name="contactPerson"
[placeholder]="'QUESTION.APPLICATION.CONTACT-PERSON-PLACEHOLDER' | translate" maxlength="100"
Expand All @@ -87,7 +105,7 @@
</div>

<div class="form-group mt-3">
<label class="form-label" for="application.contactEmail">{{'APPLICATION.METADATA-FIELD.CONTACT-EMAIL' |
<label class="form-label" for="contactEmail">{{'APPLICATION.METADATA-FIELD.CONTACT-EMAIL' |
translate}}</label>
<input type="email" class="form-control" id="contactEmail" name="contactEmail"
[placeholder]="'QUESTION.APPLICATION.CONTACT-EMAIL-PLACEHOLDER' | translate" maxlength="50" [email]="true"
Expand All @@ -96,7 +114,7 @@
</div>

<div class="form-group mt-3">
<label class="form-label" for="application.contactPhone">{{'APPLICATION.METADATA-FIELD.CONTACT-PHONE' |
<label class="form-label" for="contactPhone">{{'APPLICATION.METADATA-FIELD.CONTACT-PHONE' |
translate}}</label>
<input type="text" class="form-control" id="contactPhone" name="contactPhone" [formControl]="phoneCtrl"
[placeholder]="'QUESTION.APPLICATION.CONTACT-PHONE-PLACEHOLDER' | translate" maxlength="12"
Expand Down Expand Up @@ -126,7 +144,7 @@
<label class="form-label" for="application.controlledProperty">{{'APPLICATION.METADATA-FIELD.CONTROLLED-PROPERTY'
|
translate}}</label>
<mat-select class="form-control" name="application.controlledProperty" multiple="true"
<mat-select class="form-control" name="application.controlledProperty" id="application.controlledProperty" multiple="true"
[(ngModel)]="application.controlledProperties"
[placeholder]="'QUESTION.APPLICATION.CONTROLLED-PROPERTY-PLACEHOLDER' | translate"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('application.controlledProperty'), 'is-valid' : formFailedSubmit && !errorFields.includes('application.controlledProperty')}">
Expand All @@ -139,7 +157,7 @@
<div class="form-group mt-3">
<label class="form-label" for="application.deviceType">{{'APPLICATION.METADATA-FIELD.DEVICE-TYPE' |
translate}}</label>
<mat-select class="form-control" name="application.deviceType" multiple="true"
<mat-select class="form-control" name="application.deviceType" id="application.deviceType" multiple="true"
[(ngModel)]="application.deviceTypes" [placeholder]="'QUESTION.APPLICATION.DEVICE-TYPE-PLACEHOLDER' | translate"
[ngClass]="{'is-invalid' : formFailedSubmit && errorFields.includes('application.deviceType'), 'is-valid' : formFailedSubmit && !errorFields.includes('application.deviceType')}">
<mat-option *ngFor="let deviceType of deviceTypes" [value]="deviceType.value">
Expand Down
Loading

0 comments on commit 54244cc

Please sign in to comment.