-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
507 additions
and
56 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
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.
44 changes: 44 additions & 0 deletions
44
...l-notification/add-new-external-notification/add-new-external-notification.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,44 @@ | ||
<ng-template #content let-modal> | ||
<div class="modal-header"> | ||
<h4 class="modal-title" id="modal-basic-title">MS Teams Webhook</h4> | ||
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<form [formGroup]="myform" (ngSubmit)="onSubmit()"> | ||
<div class="modal-body"> | ||
<div class="alert alert-primary" role="alert"> | ||
<i class="fas fa-info-circle"> </i> | ||
Follow the instructions on how to set up <a href="https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook#add-an-incoming-webhook-to-a-teams-channel">Incoming Webhook</a> for a channel. | ||
</div> | ||
<p class="text-secondary"></p> | ||
<div class="input-group mb-3"> | ||
<div class="input-group-prepend"> | ||
<span class="input-group-text" id="inputGroup-sizing-default">Webhook Url</span> | ||
</div> | ||
<input type="input" class="form-control" formControlName="url" aria-label="Default" aria-describedby="inputGroup-sizing-default"> | ||
</div> | ||
<div class="input-group mb-3"> | ||
<div class="input-group-prepend"> | ||
<span class="input-group-text" id="inputGroup-sizing-default">Name</span> | ||
</div> | ||
<input type="input" class="form-control" formControlName="name" aria-label="Default" aria-describedby="inputGroup-sizing-default"> | ||
</div> | ||
<div class="form-control-feedback" *ngIf="url.errors && (url.dirty || url.touched)"> | ||
<p class="alert alert-danger" *ngIf="url.errors.required">Webhook Url required</p> | ||
<p class="alert alert-danger" *ngIf="url.errors.maxlength">The url is too long.</p> | ||
</div> | ||
<div class="form-control-feedback" *ngIf="name.errors && (name.dirty || name.touched)"> | ||
<p class="alert alert-danger" *ngIf="name.errors.required">Name required</p> | ||
<p class="alert alert-danger" *ngIf="name.errors.maxlength">Name is too long.</p> | ||
</div> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</div> | ||
</form> | ||
|
||
</ng-template> | ||
|
||
<button class="notification btn btn-sm btn-primary" (click)="open(content)"><i class="fas fa-bell"></i> new MS Teams notification</button> |
29 changes: 29 additions & 0 deletions
29
...otification/add-new-external-notification/add-new-external-notification.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,29 @@ | ||
import { HttpClientModule } from '@angular/common/http'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
|
||
import { AddNewExternalNotificationComponent } from './add-new-external-notification.component'; | ||
|
||
describe('AddNewExternalNotificationComponent', () => { | ||
let component: AddNewExternalNotificationComponent; | ||
let fixture: ComponentFixture<AddNewExternalNotificationComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ AddNewExternalNotificationComponent ], | ||
imports: [RouterTestingModule, ReactiveFormsModule, HttpClientModule], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AddNewExternalNotificationComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
77 changes: 77 additions & 0 deletions
77
...nal-notification/add-new-external-notification/add-new-external-notification.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,77 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { FormControl, Validators, FormGroup } from '@angular/forms'; | ||
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { of } from 'rxjs'; | ||
import { catchError } from 'rxjs/operators'; | ||
import { NotificationMessage } from 'src/app/notification/notification-messages'; | ||
import { ScenarioApiService } from 'src/app/scenario-api.service'; | ||
import { ScenarioService } from 'src/app/scenario.service'; | ||
|
||
@Component({ | ||
selector: 'app-add-new-external-notification', | ||
templateUrl: './add-new-external-notification.component.html', | ||
styleUrls: ['./add-new-external-notification.component.css'] | ||
}) | ||
export class AddNewExternalNotificationComponent implements OnInit { | ||
|
||
myform: FormGroup; | ||
url; | ||
name; | ||
modal: NgbActiveModal; | ||
@Input() params; | ||
|
||
constructor( | ||
private modalService: NgbModal, | ||
private notification: NotificationMessage, | ||
private scenarioApiService: ScenarioApiService, | ||
private scenarioService: ScenarioService, | ||
) { } | ||
|
||
ngOnInit() { | ||
this.createFormControls(); | ||
this.createForm(); | ||
} | ||
|
||
open(content) { | ||
this.modal = this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }); | ||
} | ||
|
||
createFormControls() { | ||
this.url = new FormControl('', [ | ||
Validators.maxLength(400), | ||
Validators.required | ||
]); | ||
this.name = new FormControl('', [ | ||
Validators.maxLength(100), | ||
Validators.required | ||
]); | ||
} | ||
|
||
createForm() { | ||
this.myform = new FormGroup({ | ||
url: this.url, | ||
name: this.name | ||
}); | ||
} | ||
|
||
onSubmit() { | ||
if (this.myform.valid) { | ||
const { projectName, scenarioName } = this.params; | ||
const body = { | ||
...this.myform.value, | ||
type: 'ms-teams' | ||
}; | ||
|
||
this.scenarioApiService.createNewScenarioNotification(projectName, scenarioName, body) | ||
.pipe(catchError(r => of(r))) | ||
.subscribe(_ => { | ||
const message = this.notification.createScenarioNotification(_); | ||
this.scenarioApiService.setData(message); | ||
this.scenarioService.fetchScenarioNotifications(projectName, scenarioName); | ||
}); | ||
this.myform.reset(); | ||
this.modal.close(); | ||
} | ||
} | ||
|
||
} |
Empty file.
25 changes: 25 additions & 0 deletions
25
...nal-notification/delete-external-notification/delete-external-notification.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,25 @@ | ||
<ng-template #content let-modal> | ||
<div class="modal-header"> | ||
<h4 class="modal-title" id="modal-basic-title">Delete Notification</h4> | ||
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')"> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<form [formGroup]="myform" (ngSubmit)="onSubmit()"> | ||
<div class="modal-body"> | ||
|
||
<div class="alert alert-primary" role="alert"> | ||
Are you sure you want to delete <strong>{{notificationInput.name}} </strong> notification? | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button class="btn btn-secondary" (click)="modal.dismiss('Cross click')">Close</button> | ||
<button type="submit" class="btn btn-danger float-left">Delete</button> | ||
</div> | ||
</form> | ||
|
||
</ng-template> | ||
|
||
<button class="btn btn-link btn-sm text-danger float-right" (click)="open(content)"> | ||
<i class="fas fa-trash-alt"></i> | ||
</button> |
Oops, something went wrong.