-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #489 from broadinstitute/sdarq-remove-seccon-endpoint
[DSEC-743][sdarq][backend][frontend] Add remove endpoint and service for SecCon
- Loading branch information
Showing
16 changed files
with
231 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
14 changes: 14 additions & 0 deletions
14
.../src/app/delete-service-security-controls/delete-service-security-controls.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div class="jumbotron min-vh-100"> | ||
<div class="container"> | ||
<div class="alert alert-danger animated fadeInRight" role="alert" *ngIf="showModalErr"> | ||
<h4 class="alert-heading">Oops!</h4> | ||
<p> {{error_message}} </p> | ||
<p class="mb-0">Please contact AppSec team for more information!</p> | ||
</div> | ||
<br> | ||
<br> | ||
<app-survey *ngIf="showForm" [json]="json" (submitSurvey)="sendData($event)"></app-survey> | ||
<br> | ||
<br> | ||
</div> | ||
</div> |
23 changes: 23 additions & 0 deletions
23
...c/app/delete-service-security-controls/delete-service-security-controls.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DeleteServiceSecurityControlsComponent } from './delete-service-security-controls.component'; | ||
|
||
describe('DeleteServiceSecurityControlsComponent', () => { | ||
let component: DeleteServiceSecurityControlsComponent; | ||
let fixture: ComponentFixture<DeleteServiceSecurityControlsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ DeleteServiceSecurityControlsComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DeleteServiceSecurityControlsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
...nd/src/app/delete-service-security-controls/delete-service-security-controls.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ChangeDetectorRef, Component, NgZone, OnInit } from '@angular/core'; | ||
import { DeleteServiceSecurityControlsService } from '../services/delete-service-security-controls/delete-service-security-controls.service'; | ||
import formJson from './form.json'; | ||
|
||
@Component({ | ||
selector: 'app-delete-service-security-controls', | ||
templateUrl: './delete-service-security-controls.component.html', | ||
styleUrls: ['./delete-service-security-controls.component.css'] | ||
}) | ||
export class DeleteServiceSecurityControlsComponent implements OnInit { | ||
|
||
showModalErr: boolean; | ||
showForm: boolean; | ||
json = formJson; | ||
error_message: string; | ||
|
||
constructor(private DeleteServiceSecurityControls: DeleteServiceSecurityControlsService, | ||
private ref: ChangeDetectorRef, | ||
private ngZone: NgZone) { | ||
// This is intentional | ||
} | ||
|
||
ngOnInit(): void { | ||
this.showForm = true; | ||
} | ||
|
||
sendData(result) { | ||
this.DeleteServiceSecurityControls.removeSecurityControls(result).subscribe(() => { | ||
this.ref.detectChanges(); | ||
}, | ||
(data) => { | ||
this.ngZone.run(() => { | ||
this.showModalErr = true; | ||
this.showForm = false; | ||
this.error_message = data; | ||
}); | ||
}); | ||
|
||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
sdarq/frontend/src/app/delete-service-security-controls/form.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"pages": [{ | ||
"name": "Delete security controls for service", | ||
"elements": [{ | ||
"type": "text", | ||
"name": "service", | ||
"title": "Enter service name", | ||
"isRequired": true, | ||
"requiredErrorText": "Service name is required.", | ||
"validators": [{ | ||
"type": "regex", | ||
"text": "Please enter a valid service name", | ||
"regex": "^[a-zA-Z0-9][a-zA-Z0-9-_ ]{1,40}[a-zA-Z0-9]$" | ||
}] | ||
}], | ||
"title": "Delete security controls for service" | ||
}], | ||
"showCompletedPage": false, | ||
"showQuestionNumbers": "off" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...ervices/delete-service-security-controls/delete-service-security-controls.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { DeleteServiceSecurityControlsService } from './delete-service-security-controls.service'; | ||
|
||
describe('DeleteServiceSecurityControlsService', () => { | ||
let service: DeleteServiceSecurityControlsService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(DeleteServiceSecurityControlsService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
...app/services/delete-service-security-controls/delete-service-security-controls.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, throwError } from 'rxjs'; | ||
import { HttpHeaders, HttpClient } from '@angular/common/http'; | ||
import { catchError } from 'rxjs/operators'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DeleteServiceSecurityControlsService { | ||
|
||
private Url = location.origin + '/delete_service_sec_controls/'; | ||
|
||
constructor(private http: HttpClient) { } | ||
|
||
removeSecurityControls(data): Observable<any> { | ||
const options = { | ||
headers: new HttpHeaders({ 'Content-Type': 'application/json'}), | ||
}; | ||
return this.http.post(this.Url, data, options).pipe( | ||
catchError(this.handleError) | ||
) | ||
} | ||
|
||
handleError(error) { | ||
|
||
let errorMessage = ''; | ||
|
||
if (error.error instanceof ErrorEvent) { | ||
// client-side error | ||
errorMessage = `${error.error.message}`; | ||
} else { | ||
// server-side error | ||
if (error.error.statusText) { | ||
errorMessage = `${error.error.statusText}`; | ||
} else { | ||
errorMessage = `${error.message}`; | ||
} | ||
} | ||
return throwError(errorMessage); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters