Skip to content

Commit

Permalink
Merge pull request #86 from Mixeway/feature/ProjectOwner
Browse files Browse the repository at this point in the history
Feature/project owner
  • Loading branch information
siewer authored Feb 2, 2024
2 parents 6bd42cf + 809fc61 commit 71bcfc0
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 36 deletions.
3 changes: 3 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,8 @@
"@schematics/angular:directive": {
"prefix": "ngx"
}
},
"cli": {
"analytics": false
}
}
151 changes: 117 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/app/@core/Model/ProjectUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export class ProjectUser {
user: string;
}
5 changes: 5 additions & 0 deletions src/app/@core/constants/AdminConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export class AdminConstants {
'name': 'Viewer',
'id': 'ROLE_USER',
},
{
'name': 'Project Owner',
'id': 'ROLE_PROJECT_OWNER',
},
{
'name': 'Editor',
'id': 'ROLE_EDITOR_RUNNER',
Expand Down Expand Up @@ -152,6 +156,7 @@ export class AdminConstants {
ADMIN_FORM_PROJECTS = 'Permissions for projects';
ADMIN_FORM_PROJECTS2 = 'Select projects...';
ADMIN_ROLE_USER = 'ROLE_USER';
ADMIN_ROLE_PROJECT_OWNER = 'ROLE_PROJECT_OWNER';
ADMIN_ROLE_USER2 = 'ROLE_EDITOR_RUNNER';
ADMIN_FORM_EDIT = 'Edit';
ADMIN_EDIT_USER = 'Editing user';
Expand Down
9 changes: 9 additions & 0 deletions src/app/@core/service/ShowProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {IaasApiType} from '../Model/IaasApiType';
import {ProjectStats} from '../Model/ProjectStats';
import {ProjectAudit} from '../Model/ProjectAudit';
import {ProjectDetailsAudit} from '../Model/ProjectDetailsAudit';
import {ProjectUser} from '../Model/ProjectUser';
import {DetailStats} from '../Model/DetailStats';

@Injectable({
Expand Down Expand Up @@ -516,4 +517,12 @@ export class ShowProjectService {
catchError(this.errorHandl),
);
}

saveProjectUser(id, settings) {
return this.http.post<ProjectUser[]>(environment.backend + '/show/project/' + id + '/user/add', settings)
.pipe(
retry(1),
catchError(this.errorHandl),
);
}
}
2 changes: 1 addition & 1 deletion src/app/pages/admin/user/user.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<label for="userPassword" class="label">{{constants.ADMIN_FORM_USER_PASSWORD}} </label>
<input type="password" nbInput fullWidth id="userPassword" [placeholder]="constants.ADMIN_FORM_USER_PASSWORD" formControlName="userPassword">
</div>
<div class="form-group" *ngIf="( userForm.value.userRole==constants.ADMIN_ROLE_USER)">
<div class="form-group" *ngIf="( userForm.value.userRole==constants.ADMIN_ROLE_USER || userForm.value.userRole==constants.ADMIN_ROLE_PROJECT_OWNER)">
<label for="permissionsProject" class="label">{{constants.ADMIN_FORM_PROJECTS}}</label>
<ejs-multiselect formControlName="projects" id="permissionsProject" [dataSource]='projects' [fields]='fields' (filtering)='onFiltering($event)' [allowFiltering]='true'
[placeholder]='constants.ADMIN_FORM_PROJECTS2'></ejs-multiselect>
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/admin/user/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class UserComponent implements OnInit {
}

changedRole($event: any) {
if ($event === 'ROLE_USER' || $event === 'ROLE_ADMIN' || $event === 'ROLE_AUDITOR' || $event === 'ROLE_EDITOR_RUNNER') {
if ($event === 'ROLE_USER' || $event === 'ROLE_ADMIN' || $event === 'ROLE_AUDITOR' || $event === 'ROLE_EDITOR_RUNNER' || $event === 'ROLE_PROJECT_OWNER') {
this.showUsername = true;
this.showOptions = true;
} else if ($event === 'ROLE_API') {
Expand Down
11 changes: 11 additions & 0 deletions src/app/pages/show-project/show-project.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,19 @@ <h3> {{ risk?.projectName }} <button *ngIf="showVulnAuditor" (click)="displayPro
</div>
<button type="submit" nbButton status="danger">{{constants.PROJECT_SAVE}}</button>
</form>

<form [formGroup]="projectUserForm" (ngSubmit)="saveProjectUser(ref)">


<div class="form-group">
<label for="userProject" class="label">Who grant access to?</label>
<input type="text" nbInput fullWidth id="userProject" placeholder="username" formControlName="user">
</div>
<button type="submit" nbButton status="danger">{{constants.PROJECT_SAVE}}</button>
</form>
</nb-card-body>
</nb-card>

</ng-template>
<ng-template #showInstructions let-data let-ref="showInstructions">
<nb-card>
Expand Down
24 changes: 24 additions & 0 deletions src/app/pages/show-project/show-project.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {ProjectInfo} from '../../@core/Model/ProjectInfo';
import {VulnTrendChart} from '../../@core/Model/VulnTrendChart';
import {Severities} from '../../@core/Model/Severities';
import {ProjectStats} from '../../@core/Model/ProjectStats';
import {ProjectUser} from '../../@core/Model/ProjectUser';


@Component({
selector: 'ngx-show-project',
Expand Down Expand Up @@ -45,7 +47,10 @@ export class ShowProjectComponent implements OnInit {
severities: Severities;
severitiesChartData: any = [];
projectStats: ProjectStats;

private vulnAuditorForm: any;
private projectUserForm: any;
projectUser: ProjectUser = new ProjectUser;
constructor(private showProjectService: ShowProjectService, private _route: ActivatedRoute, private router: Router,
private cookieService: CookieService, private dialogService: NbDialogService,
private formBuilder: FormBuilder, private toast: Toast, private windowService: NbWindowService,
Expand All @@ -65,6 +70,9 @@ export class ShowProjectComponent implements OnInit {
dclocation: this.projectInfo.networkdc,
appClient: this.projectInfo.appClient,
});
this.projectUserForm = this.formBuilder.group({
user: this.projectUser.user,
});
this.updateShowDockerInfo();
}
loadTrendChartData() {
Expand Down Expand Up @@ -197,6 +205,22 @@ export class ShowProjectComponent implements OnInit {
});
}


saveProjectUser(ref) {
return this.showProjectService.saveProjectUser(this._entityId, this.projectUserForm.value).subscribe(() => {
this.toast.showToast('success', this.constants.PROJECT_OPERATION_SUCCESS,
'Project Settings saved successfully.');
this.loadProjectInfo();
ref.close();
},
() => {
this.toast.showToast('danger', this.constants.PROJECT_OPERATION_FAILURE,
this.constants.PROJECT_OPERATION_FAILURES);
});
}



flipped = false;

toggleView() {
Expand Down

0 comments on commit 71bcfc0

Please sign in to comment.