Skip to content

Commit

Permalink
Merge pull request #91 from juanfranciscocis/WindowsEnviroment
Browse files Browse the repository at this point in the history
New Features:
  • Loading branch information
juanfranciscocis authored Oct 2, 2024
2 parents 273e0f4 + ef1f417 commit d1a77ac
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 19 deletions.
19 changes: 11 additions & 8 deletions src/app/pages/incident_manager/new-incident/new-incident.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,21 @@ export class NewIncidentPage implements OnInit {

}).then(async (data) => {
if (data) {
await this.hideLoading();
interface Role {
role: string;
member: string;
}

let consolidateMember: String[] = [];
consolidateMember.push(this.incidentCommander);
consolidateMember.push(this.communicationsLead);
consolidateMember.push(this.operationsLead);
let consolidateMember: Role[] = [];
consolidateMember.push({role: 'Incident Commander', member: this.incidentCommander});
consolidateMember.push({role: 'Communications Lead', member: this.communicationsLead});
consolidateMember.push({role: 'Operations Lead', member: this.operationsLead});
for (let i = 0; i < this.operationTeam[1].items.length; i++) {
consolidateMember.push(this.operationTeam[1].items[i]);
console.log('consolidateMember',consolidateMember);
consolidateMember.push({role: 'Operations Team Member', member: this.operationTeam[1].items[i]});
}
console.log('consolidateMember',consolidateMember);
await this.notificationService.notifyIncidentToUser(consolidateMember, this.orgName);

await this.hideLoading();
await this.showAlert('Incident saved successfully', 'Success');
window.history.back();
} else {
Expand Down
16 changes: 10 additions & 6 deletions src/app/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import {User} from "../interfaces/user";
import {Firestore, doc, getDoc, setDoc } from '@angular/fire/firestore';
import {HttpClient} from "@angular/common/http";
import {TeamsService} from "./teams.service";

interface Role {
role: string;
member: string;
}
@Injectable({
providedIn: 'root'
})
Expand Down Expand Up @@ -51,15 +54,15 @@ export class NotificationService {
}
}

async notifyIncidentToUser(users: String[], orgName: string) {
async notifyIncidentToUser(roles: Role[],orgName: string) {

try {


//get team by orgName
const team = await this.teamService.getTeamByOrganization(orgName);
const users = roles.map(role => role.member);
// from the team arr delete the users that are not in the users array
const filteredTeam = team.filter(user => users.includes(<String>user.name));
// @ts-ignore
const filteredTeam = team.filter(user => users.includes(user.name));
console.log('team',filteredTeam);

const url = `https://devprobeapi.onrender.com/sendNotification`;
Expand All @@ -72,7 +75,8 @@ export class NotificationService {
sid: sid,
title: 'New Incident',
type: 'new_incident',
message: `Hey ${user.name}, you have been assigned a new incident`,
// @ts-ignore
message: `Hey ${user.name}, you have been assigned a new incident your incident role is ${roles.find(role => role.member === user.name).role}`,
target: target_url
};
await this.http.post(url, body).toPromise();
Expand Down
1 change: 1 addition & 0 deletions www/5371.8b79a9bec1875d4c.js

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

Loading

0 comments on commit d1a77ac

Please sign in to comment.