Skip to content

Commit

Permalink
New Features:
Browse files Browse the repository at this point in the history
1. Incident progess chat saves correctly
2. Incident manager shows assigned user incidents
3. Menu now Shows Team name and current logged User name
New Pages:
Bugs Corrected:
To Be Corrected:
0. On product delete, delete trace results
1. On product delete, delete flamegraph result
3. On add member do not delete github info
4. Sort System Test check if needed!!!
  • Loading branch information
juanfranciscocis committed Oct 4, 2024
1 parent 3a4fa90 commit 1810b9f
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 5 deletions.
24 changes: 20 additions & 4 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,26 @@
<ion-label color="primary">{{item.title}}</ion-label>
</ion-item>
}@else{
<ion-item [routerLink]="item.url">
<ion-icon [name]="item.icon" slot="start"></ion-icon>
<ion-label color="primary">{{item.title}}</ion-label>
</ion-item>
@if (item.title === 'Settings') {
<ion-item [routerLink]="item.url">
<ion-icon [name]="item.icon" slot="start"></ion-icon>
<ion-label color="primary">{{item.title}}</ion-label>
<ion-chip>{{ user.name }}</ion-chip>
</ion-item>
}
@else if (item.title === 'My Team') {
<ion-item [routerLink]="item.url">
<ion-icon [name]="item.icon" slot="start"></ion-icon>
<ion-label color="primary">{{item.title}}</ion-label>
<ion-chip>{{ user.orgName }}</ion-chip>
</ion-item>
}
@else {
<ion-item [routerLink]="item.url">
<ion-icon [name]="item.icon" slot="start"></ion-icon>
<ion-label color="primary">{{item.title}}</ion-label>
</ion-item>
}
}
</ion-menu-toggle>
</ion-list>
Expand Down
11 changes: 11 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { MenuController } from '@ionic/angular';
import {User} from "./interfaces/user";

/**
* AppComponent is the root component of the application.
Expand All @@ -15,6 +16,11 @@ import { MenuController } from '@ionic/angular';
})
export class AppComponent implements OnInit {

/**
* The user object.
*/
user: User = {} as User;

/**
* An array of menu items. Each item is an object with 'title', 'url', and 'icon' properties.
*/
Expand Down Expand Up @@ -101,6 +107,7 @@ export class AppComponent implements OnInit {
}
}
});
this.getUser();
}

navigate(item: any) {
Expand All @@ -109,4 +116,8 @@ export class AppComponent implements OnInit {
});
}

getUser() {
const user = JSON.parse(localStorage.getItem('user')!);
this.user = user;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {LoadingController} from "@ionic/angular";
import {IncidentService} from "../../../services/incident.service";
import {Incident} from "../../../interfaces/incident";
import {User} from "../../../interfaces/user";
import {NotificationService} from "../../../services/notification.service";

@Component({
selector: 'app-incident-details',
Expand All @@ -26,6 +27,7 @@ export class IncidentDetailsPage implements OnInit {
private activatedRoute: ActivatedRoute,
private loadingCtrl: LoadingController,
private incidentService: IncidentService,
private notificationService: NotificationService,
) { }

ngOnInit() {
Expand All @@ -36,6 +38,8 @@ export class IncidentDetailsPage implements OnInit {
}

getParams() {


this.activatedRoute.params.subscribe(params => {
this.productObjective = params['productObjective']; //this is the product objective
this.productStep = params['step']; //this is the step of the product
Expand All @@ -51,7 +55,9 @@ export class IncidentDetailsPage implements OnInit {
console.log(this.incident.title);
}

addComment() {
async addComment() {

await this.showLoading();
console.log('add comment');
console.log(this.currentUser);
console.log(this.newComment);
Expand All @@ -76,14 +82,50 @@ export class IncidentDetailsPage implements OnInit {
}

//save the incident to the db
await this.incidentService.updateIncident(this.orgName, this.productObjective, this.productStep, this.incident);


interface Role {
role: string;
member: string;
}

let consolidateMember: Role[] = [];
consolidateMember.push({role: 'Incident Commander', member: this.incident.incidentCommander});
consolidateMember.push({role: 'Communications Lead', member: this.incident.communications_lead});
consolidateMember.push({role: 'Operations Lead', member: this.incident.operations_lead});
for (let i = 0; i < this.incident.operation_team.length; i++) {
consolidateMember.push({role: 'Operations Team Member', member: this.incident.operation_team[i]});
}
console.log(consolidateMember);
await this.notificationService.notifyIncidentUpdateToTeam(consolidateMember, this.orgName);


this.newComment = '';

this.hideLoading();


}

closeIncident() {

}


/**
* Show a loading spinner.
*/
async showLoading() {
const loading = await this.loadingCtrl.create({
});
await loading.present();
}

/**
* Hide the loading spinner.
*/
async hideLoading() {
await this.loadingCtrl.dismiss();
}
}
24 changes: 24 additions & 0 deletions src/app/services/incident.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,28 @@ export class IncidentService {
return [];
}


async updateIncident(orgName: string, productObjective: string, productStep: string, incident: Incident) {
const docRef = doc(this.firestore, 'teams', orgName, 'products', productObjective, 'incident', productStep);
const docSnap = await getDoc(docRef);
if (docSnap.exists()) {
const data = docSnap.data();
//get the incidents array
// @ts-ignore
let dataIncident = data.incidents;
console.log(dataIncident);
for (let i = 0; i <= dataIncident.length; i++) {
console.log(dataIncident[i].title);
console.log(incident.title);
if (dataIncident[i].title === incident.title) {
console.log('found');
dataIncident[i] = incident;
await setDoc(docRef, data);
return true;
}
}
}
return false;
}

}
36 changes: 36 additions & 0 deletions src/app/services/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,41 @@ export class NotificationService {
console.log(error);
}
}


async notifyIncidentUpdateToTeam(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
// @ts-ignore
const filteredTeam = team.filter(user => users.includes(user.name));
console.log('team',filteredTeam);

const url = `https://devprobeapi.onrender.com/sendNotification`;
for (let user of filteredTeam) {
let sid = await this.getNotificationUser(user);
console.log('sid',sid);
if (sid !== '') {
let target_url = `https://devprobe-89481.web.app/incident-manager-chooser`;
const body = {
sid: sid,
title: 'Incident Update',
type: 'update_incident',
// @ts-ignore
message: `Hey ${user.name}, there are updates to your incident`,
target: target_url
};
await this.http.post(url, body).toPromise();
console.log('Notification sent successfully');
}else{
console.log('no sid');}}
}catch (error) {
console.log(error);
}

}

}

0 comments on commit 1810b9f

Please sign in to comment.