Merge remote-tracking branch 'origin/master-3.0' into master-3.0

This commit is contained in:
grossmj 2023-11-09 15:44:47 +10:00
commit 81efa0c6d6
11 changed files with 1415 additions and 1894 deletions

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm test

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
v16.14.0

View File

@ -38,7 +38,7 @@
"postbuildforelectron": "node set-variables-in-env.js --unset src/environments/environment.electron.prod.ts",
"postinstall": "ngcc --properties es2020 browser module main --first-only --create-ivy-entry-points --tsconfig \"./src/tsconfig.app.json\" && ngcc --properties es2020 browser module main --first-only --create-ivy-entry-points --tsconfig \"./src/tsconfig.app.json\"",
"snyk-protect": "snyk-protect",
"prepare": "yarn run snyk-protect"
"prepare": "husky install"
},
"private": true,
"dependencies": {
@ -108,6 +108,7 @@
"electron": "13.6.6",
"electron-builder": "^23.0.3",
"file-loader": "^6.2.0",
"husky": "^8.0.3",
"jasmine-core": "^4.1.0",
"jasmine-spec-reporter": "^7.0.0",
"jquery": "^3.6.0",

View File

@ -14,10 +14,12 @@
<mat-tab label="Details" class="details">
<div>
<div>
<form [formGroup]="editGroupForm" class="input-field">
<mat-form-field>
<mat-label>Group name:</mat-label>
<input matInput type="text" [ngModel]="group.name">
<input matInput type="text" formControlName="groupname">
</mat-form-field>
</form>
</div>
<div>
@ -25,7 +27,7 @@
</div>
<div mat-dialog-actions class="button-div">
<button mat-button (click)="onUpdate()" tabindex="2" mat-raised-button color="primary"
[disabled]="!editGroupForm.valid">
[disabled]="!editGroupForm.valid || group.is_builtin">
Update Group
</button>
</div>

View File

@ -15,7 +15,7 @@ import {ActivatedRoute} from "@angular/router";
import {Controller} from "@models/controller";
import {Group} from "@models/groups/group";
import {User} from "@models/users/user";
import {UntypedFormControl, UntypedFormGroup} from "@angular/forms";
import {UntypedFormControl, UntypedFormGroup, Validators} from "@angular/forms";
import {MatDialog} from "@angular/material/dialog";
import {AddUserToGroupDialogComponent} from "@components/group-details/add-user-to-group-dialog/add-user-to-group-dialog.component";
import {RemoveToGroupDialogComponent} from "@components/group-details/remove-to-group-dialog/remove-to-group-dialog.component";
@ -54,9 +54,7 @@ export class GroupDetailsComponent implements OnInit {
private aclService: AclService,
private roleService: RoleService) {
this.editGroupForm = new UntypedFormGroup({
groupname: new UntypedFormControl(''),
});
this.route.data.subscribe((d: { controller: Controller; group: Group, members: User[], aces: ACE[] }) => {
@ -64,7 +62,9 @@ export class GroupDetailsComponent implements OnInit {
this.group = d.group;
this.aces = d.aces;
this.members = d.members.sort((a: User, b: User) => a.username.toLowerCase().localeCompare(b.username.toLowerCase()));
this.editGroupForm.setValue({groupname: this.group.name});
this.editGroupForm = new UntypedFormGroup({
groupname: new UntypedFormControl(this.group.name, [Validators.required]),
});
});
@ -84,6 +84,8 @@ export class GroupDetailsComponent implements OnInit {
}
onUpdate() {
this.group.name = this.editGroupForm.get('groupname').value
console.log(this.editGroupForm.get('groupname'))
this.groupService.update(this.controller, this.group)
.subscribe(() => {
this.toastService.success(`group updated`);

View File

@ -21,7 +21,6 @@ export const groupNameAsyncValidator = (controller: Controller, groupService: Gr
return timer(500).pipe(
switchMap(() => groupService.getGroups(controller)),
map((response) => {
console.log(response);
return (response.find((n) => n.name === control.value) ? { projectExist: true } : null);
})
);

View File

@ -12,18 +12,20 @@
</div>
<div class="main">
<div class="details">
<form [formGroup]="editRoleForm">
<div>
<mat-form-field>
<mat-label>Role name:</mat-label>
<input matInput type="text" [ngModel]="($role | async)?.name">
<input matInput type="text" formControlName="rolename">
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-label>Description:</mat-label>
<input matInput type="text" [ngModel]="($role | async)?.description">
<input matInput type="text" formControlName="description">
</mat-form-field>
</div>
</form>
<div>Creation date: {{($role | async)?.created_at}}</div>
<div>Last update Date: {{($role | async)?.updated_at}}</div>
<div>UUID: {{($role | async)?.role_id}}</div>
@ -32,7 +34,8 @@
</div>
<div mat-dialog-actions class="button-div">
<button mat-button (click)="onUpdate()" tabindex="2" mat-raised-button color="primary"
[disabled]="!editRoleForm.valid">
[disabled]="(!(editRoleForm.valueChanges | async) && editRoleForm.valid) || ($role | async)?.is_builtin">
Update Role
</button>
</div>

View File

@ -15,14 +15,15 @@ import {RoleService} from "@services/role.service";
import {ActivatedRoute} from "@angular/router";
import {Controller} from "@models/controller";
import {Role} from "@models/api/role";
import {UntypedFormControl, UntypedFormGroup} from "@angular/forms";
import {FormBuilder, FormGroup} from "@angular/forms";
import {ToasterService} from "@services/toaster.service";
import {HttpErrorResponse} from "@angular/common/http";
import {Privilege} from "@models/api/Privilege";
import {PrivilegeService} from "@services/privilege.service";
import {Observable, ReplaySubject} from "rxjs";
import {BehaviorSubject, Observable} from "rxjs";
import {IPrivilegesChange} from "@components/role-management/role-detail/privilege/IPrivilegesChange";
import {map} from "rxjs/operators";
import {string} from "yargs";
@Component({
selector: 'app-role-detail',
@ -31,8 +32,8 @@ import {map} from "rxjs/operators";
})
export class RoleDetailComponent implements OnInit {
controller: Controller;
$role: ReplaySubject<Role> = new ReplaySubject<Role>(1);
editRoleForm: UntypedFormGroup;
$role: BehaviorSubject<Role> = new BehaviorSubject<Role>({role_id: "", description: "", updated_at: "", is_builtin: false, privileges: [], name: "", created_at:""});
editRoleForm: FormGroup;
$ownedPrivilegesId: Observable<Privilege[]> = this.$role.pipe(map((role: Role) => {
return role.privileges
}));
@ -44,11 +45,16 @@ export class RoleDetailComponent implements OnInit {
private toastService: ToasterService,
private route: ActivatedRoute,
private privilegeService: PrivilegeService,
private fb : FormBuilder,
) {
this.editRoleForm = new UntypedFormGroup({
rolename: new UntypedFormControl(),
description: new UntypedFormControl(),
this.$role.subscribe((role) => {
this.editRoleForm = fb.group({
rolename: [role.name],
description: [role.description],
});
});
}
@ -61,7 +67,9 @@ export class RoleDetailComponent implements OnInit {
});
}
onUpdate() {
this.$role.subscribe((role) => {
const role = this.$role.value;
role.name = this.editRoleForm.get("rolename").value;
role.description = this.editRoleForm.get("description").value;
this.roleService.update(this.controller, role)
.subscribe(() => {
this.toastService.success(`role: ${role.name} was updated`);
@ -71,7 +79,6 @@ export class RoleDetailComponent implements OnInit {
this.toastService.error(`${error.message}
${error.error.message}`);
});
})
}

View File

@ -15,14 +15,14 @@
<h6>Template</h6>
</div>
<mat-form-field class="form-field" floatPlaceholder="never">
<input matInput placeholder="Search by name" [(ngModel)]="searchText" [ngModelOptions]="{ standalone: true }" />
<input matInput placeholder="Search by name" [(ngModel)]="searchText" [ngModelOptions]="{ standalone: true }" ngDefaultControl/>
</mat-form-field>
<mat-form-field class="form-field">
<mat-select
[ngModelOptions]="{ standalone: true }"
placeholder="Filter templates by type"
(selectionChange)="filterTemplates($event)"
[(ngModel)]="selectedType"
[(ngModel)]="selectedType" ngDefaultControl
>
<mat-option *ngFor="let type of templateTypes" [value]="type">
{{ type }}
@ -34,7 +34,7 @@
[ngModelOptions]="{ standalone: true }"
placeholder="Choose template"
(selectionChange)="chooseTemplate($event)"
[(ngModel)]="selectedTemplate"
[(ngModel)]="selectedTemplate" ngDefaultControl
>
<mat-option *ngFor="let template of filteredTemplates | templatefilter: searchText" [value]="template">
{{ template.name }}

View File

@ -11,6 +11,7 @@ import { ToasterService } from 'app/services/toaster.service';
import { MockedToasterService } from 'app/services/toaster.service.spec';
import { NonNegativeValidator } from 'app/validators/non-negative-validator';
import { TemplateListDialogComponent } from './template-list-dialog.component';
import {TemplateFilter} from "@filters/templateFilter.pipe";
@ -20,7 +21,7 @@ describe('TemplateListDialogComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [TemplateListDialogComponent],
declarations: [TemplateListDialogComponent, TemplateFilter],
imports: [ReactiveFormsModule, FormsModule,RouterTestingModule],
providers: [
{ provide: TemplateService, useClass: TemplateMocksService },

3207
yarn.lock

File diff suppressed because it is too large Load Diff