Merge pull request #1479 from Orange-OpenSource/master-3.0

somes fixes :
This commit is contained in:
Jeremy Grossmann 2023-11-07 23:00:51 +10:00 committed by GitHub
commit 49f8f61962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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", "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\"", "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", "snyk-protect": "snyk-protect",
"prepare": "yarn run snyk-protect" "prepare": "husky install"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
@ -108,6 +108,7 @@
"electron": "13.6.6", "electron": "13.6.6",
"electron-builder": "^23.0.3", "electron-builder": "^23.0.3",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"husky": "^8.0.3",
"jasmine-core": "^4.1.0", "jasmine-core": "^4.1.0",
"jasmine-spec-reporter": "^7.0.0", "jasmine-spec-reporter": "^7.0.0",
"jquery": "^3.6.0", "jquery": "^3.6.0",

View File

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

View File

@ -15,7 +15,7 @@ import {ActivatedRoute} from "@angular/router";
import {Controller} from "@models/controller"; import {Controller} from "@models/controller";
import {Group} from "@models/groups/group"; import {Group} from "@models/groups/group";
import {User} from "@models/users/user"; 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 {MatDialog} from "@angular/material/dialog";
import {AddUserToGroupDialogComponent} from "@components/group-details/add-user-to-group-dialog/add-user-to-group-dialog.component"; 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"; 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 aclService: AclService,
private roleService: RoleService) { private roleService: RoleService) {
this.editGroupForm = new UntypedFormGroup({
groupname: new UntypedFormControl(''),
});
this.route.data.subscribe((d: { controller: Controller; group: Group, members: User[], aces: ACE[] }) => { 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.group = d.group;
this.aces = d.aces; this.aces = d.aces;
this.members = d.members.sort((a: User, b: User) => a.username.toLowerCase().localeCompare(b.username.toLowerCase())); 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() { onUpdate() {
this.group.name = this.editGroupForm.get('groupname').value
console.log(this.editGroupForm.get('groupname'))
this.groupService.update(this.controller, this.group) this.groupService.update(this.controller, this.group)
.subscribe(() => { .subscribe(() => {
this.toastService.success(`group updated`); this.toastService.success(`group updated`);

View File

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

View File

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

View File

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

View File

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

View File

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

3207
yarn.lock

File diff suppressed because it is too large Load Diff