Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-3.0' into master-3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Nov 9, 2023
2 parents 63b8582 + 49f8f61 commit 81efa0c
Show file tree
Hide file tree
Showing 11 changed files with 1,415 additions and 1,894 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.14.0
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 7 additions & 5 deletions src/app/components/group-details/group-details.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ <h1 class="col">Group {{group.name}}</h1>
<mat-tab label="Details" class="details">
<div>
<div>
<mat-form-field>
<mat-label>Group name:</mat-label>
<input matInput type="text" [ngModel]="group.name">
</mat-form-field>
<form [formGroup]="editGroupForm" class="input-field">
<mat-form-field>
<mat-label>Group name:</mat-label>
<input matInput type="text" formControlName="groupname">
</mat-form-field>
</form>
</div>

<div>
<mat-checkbox [checked]="group.is_builtin" disabled>Is built-in</mat-checkbox>
</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>
Expand Down
12 changes: 7 additions & 5 deletions src/app/components/group-details/group-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -54,17 +54,17 @@ 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[] }) => {

this.controller = d.controller;
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]),
});
});


Expand All @@ -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`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,30 @@ <h1 class="col">Role {{($role | async)?.name}}</h1>
</div>
<div class="main">
<div class="details">
<div>
<mat-form-field>
<mat-label>Role name:</mat-label>
<input matInput type="text" [ngModel]="($role | async)?.name">
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-label>Description:</mat-label>
<input matInput type="text" [ngModel]="($role | async)?.description">
</mat-form-field>
</div>
<form [formGroup]="editRoleForm">
<div>
<mat-form-field>
<mat-label>Role name:</mat-label>
<input matInput type="text" formControlName="rolename">
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-label>Description:</mat-label>
<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>Last update Date: {{($role | async)?.updated_at}}</div>
<div>UUID: {{($role | async)?.role_id}}</div>
<div>
<mat-checkbox [checked]="($role | async)?.is_builtin" disabled>Is built-in</mat-checkbox>
</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>
Expand All @@ -41,8 +44,8 @@ <h1 class="col">Role {{($role | async)?.name}}</h1>
<app-privilege
[disable]="($role | async)?.is_builtin"
[ownedPrivilege]="$ownedPrivilegesId | async"
[privileges]="privileges | async"
(update)="onPrivilegesUpdate($event)"></app-privilege>
[privileges]="privileges | async"
(update)="onPrivilegesUpdate($event)"></app-privilege>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
}));
Expand All @@ -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],
});
});
}

Expand All @@ -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`);
Expand All @@ -71,7 +79,6 @@ export class RoleDetailComponent implements OnInit {
this.toastService.error(`${error.message}
${error.error.message}`);
});
})

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ <h1 mat-dialog-title>Add a node</h1>
<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 }}
Expand All @@ -34,7 +34,7 @@ <h6>Template</h6>
[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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";



Expand All @@ -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 },
Expand Down
Loading

0 comments on commit 81efa0c

Please sign in to comment.