Skip to content

Commit

Permalink
Raise Teams message when clashes are added from Navisworks
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgDangl committed Jul 16, 2024
1 parent cf9aa67 commit 2535b2c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
IFilters,
IssueFiltersComponent,
} from '../issue-filters/issue-filters.component';
import {
MessageType,
TeamsMessengerService,
} from '../../services/teams-messenger.service';

import { AppConfigService } from '../../services/AppConfigService';
import { BcfFileAutomaticallySaveService } from '../../services/bcf-file-automaticaly-save.service';
Expand All @@ -30,7 +34,6 @@ import { NotificationsService } from '../../services/notifications.service';
import { ProjectUsersService } from '../../services/project-users.service';
import { SafeUrlPipe } from '../../pipes/safe-url.pipe';
import { SettingsMessengerService } from '../../services/settings-messenger.service';
import { TeamsMessengerService } from '../../services/teams-messenger.service';
import { TopicDetailComponent } from '../topic-detail/topic-detail.component';
import { TopicFilterPipe } from '../../pipes/topic-filter.pipe';
import { TopicMessengerService } from '../../services/topic-messenger.service';
Expand Down Expand Up @@ -256,6 +259,10 @@ export class BcfFileComponent {
this.bcfFile.topics.push(...createdTopics);
this.filteredTopics = [...this.bcfFile.topics];
this.bcfFileAutomaticallySaveService.saveCurrentActiveBcfFileAutomatically();

this.teamsMessengerService.sendMessageToTeams(
MessageType.AddNavisworksClashes
);
});
},
error: (error) => {
Expand Down
35 changes: 32 additions & 3 deletions src/ipa-bcfier-ui/src/app/services/teams-messenger.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Injectable, OnDestroy, inject } from '@angular/core';
import {
EMPTY,
Subject,
Expand All @@ -7,18 +6,21 @@ import {
take,
takeUntil,
} from 'rxjs';
import { TopicMessengerService } from './topic-messenger.service';
import { SettingsMessengerService } from './settings-messenger.service';
import { Injectable, OnDestroy, inject } from '@angular/core';
import {
TeamsMessagePost,
TeamsMessagesClient,
} from '../generated-client/generated-client';

import { SelectedProjectMessengerService } from './selected-project-messenger.service';
import { SettingsMessengerService } from './settings-messenger.service';
import { TopicMessengerService } from './topic-messenger.service';

export enum MessageType {
AddComment = 'AddNomment',
AddViewpoint = 'AddViewpoint',
ChangeTitle = 'ChangeTitle',
AddNavisworksClashes = 'AddNavisworksClashes',
}
@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -53,6 +55,9 @@ export class TeamsMessengerService implements OnDestroy {
case MessageType.AddViewpoint:
this.sendInfoAboutAddViewpoint();
break;
case MessageType.AddNavisworksClashes:
this.sendInfoAboutAddNavisworksClashes();
break;
case MessageType.ChangeTitle:
this.sendInfoAboutChangeTitle();
break;
Expand Down Expand Up @@ -109,6 +114,30 @@ export class TeamsMessengerService implements OnDestroy {
.subscribe(() => {});
}

private sendInfoAboutAddNavisworksClashes(): void {
this.topicMessengerService.selectedTopic
.pipe(
take(1),
combineLatestWith(this.settingsMessengerService.settings),
switchMap(([t, s]) => {
if (this.projectId && t?.id) {
const lastAddedViewpoint = t?.viewpoints[t?.viewpoints.length - 1];
const model: TeamsMessagePost = {
comment: 'Clash Results from Navisworks added',
username: s.username,
};
return this.teamsMessagesClient.announceNewCommentInProjectTopic(
this.projectId,
t?.id,
model
);
}
return EMPTY;
})
)
.subscribe(() => {});
}

private sendInfoAboutChangeTitle(): void {
this.topicMessengerService.selectedTopic
.pipe(
Expand Down

0 comments on commit 2535b2c

Please sign in to comment.