Skip to content

Commit

Permalink
Add option to filter clashes to import by status
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgDangl committed Jul 23, 2024
1 parent 1a957f7 commit eba9ca8
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,18 @@ public List<BcfTopic> CreateClashIssues(NavisworksClashCreationData clashCreatio
{
if (t.SavedItem is ClashResult result)
{
return clashCreationData.ExcludedClashIds == null
|| !clashCreationData.ExcludedClashIds.Contains(result.Guid);
return (clashCreationData.ExcludedClashIds == null
|| !clashCreationData.ExcludedClashIds.Contains(result.Guid))
&& (clashCreationData.Status == null
|| clashCreationData.Status == result.Status.ToString());
}

if (t.SavedItem is ClashResultGroup resultGroup)
{
return clashCreationData.ExcludedClashIds == null
|| !clashCreationData.ExcludedClashIds.Contains(resultGroup.Guid);
return (clashCreationData.ExcludedClashIds == null
|| !clashCreationData.ExcludedClashIds.Contains(resultGroup.Guid))
&& (clashCreationData.Status == null
|| clashCreationData.Status == resultGroup.Status.ToString());
}

return false;
Expand Down
5 changes: 5 additions & 0 deletions src/IPA.Bcfier/Models/Clashes/NavisworksClashCreationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ public class NavisworksClashCreationData
{
public Guid ClashId { get; set; }

/// <summary>
/// This is used to filter for only a specific status of clashes
/// </summary>
public string? Status { get; set; }

public List<Guid> ExcludedClashIds { get; set; } = new List<Guid>();
}
}
155 changes: 81 additions & 74 deletions src/ipa-bcfier-ui/src/app/components/bcf-file/bcf-file.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,86 +211,93 @@ export class BcfFileComponent {
this.dialog
.open(NavisworksClashSelectionComponent)
.afterClosed()
.subscribe((selection?: { clashId: string; onlyImportNew: boolean }) => {
if (!selection) {
return;
}
this.notificationsService.info(
'If there are many clashes, generation of the data could take a few minutes.'
);
this.navisworksClashesLoadingService.showLoadingScreen();

const existingIds = selection.onlyImportNew
? this.bcfFile.topics
.filter(
(topic) =>
!!topic.serverAssignedId &&
// We only want to take Guids, as other server assigned ids might not originate from Navisworks
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
topic.serverAssignedId
)
)
.map((topic) => topic.serverAssignedId!)
: [];

const cancellationSubscription =
this.navisworksClashProgressMessengerService.cancelGeneration.subscribe(
() => {
this.viewpointsClient
.cancelNavisworksClashDetection(selection.clashId)
.subscribe(() => {
/* Not doing anything with the response, that's handled later */
});
}
.subscribe(
(selection?: {
clashId: string;
onlyImportNew: boolean;
statusType: string | null;
}) => {
if (!selection) {
return;
}
this.notificationsService.info(
'If there are many clashes, generation of the data could take a few minutes.'
);
this.navisworksClashesLoadingService.showLoadingScreen();

this.viewpointsClient
.createNavisworksClashDetectionResultIssues({
clashId: selection.clashId,
excludedClashIds: existingIds,
})
.subscribe({
next: (createdTopics) => {
this.navisworksClashesLoadingService.hideLoadingScreen();
cancellationSubscription.unsubscribe();
this.settingsMessengerService.settings
.pipe(take(1))
.subscribe((s) => {
createdTopics.forEach((topic) => {
topic.creationAuthor = s.username;
const existingIds = selection.onlyImportNew
? this.bcfFile.topics
.filter(
(topic) =>
!!topic.serverAssignedId &&
// We only want to take Guids, as other server assigned ids might not originate from Navisworks
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
topic.serverAssignedId
)
)
.map((topic) => topic.serverAssignedId!)
: [];

const cancellationSubscription =
this.navisworksClashProgressMessengerService.cancelGeneration.subscribe(
() => {
this.viewpointsClient
.cancelNavisworksClashDetection(selection.clashId)
.subscribe(() => {
/* Not doing anything with the response, that's handled later */
});
}
);

if (selection.onlyImportNew) {
// In that case, we're filtering out those topics that already exist in the
createdTopics = createdTopics.filter(
(topic) =>
!this.bcfFile.topics.some(
(existingTopic) =>
existingTopic.serverAssignedId ===
topic.serverAssignedId
)
);
}
this.viewpointsClient
.createNavisworksClashDetectionResultIssues({
clashId: selection.clashId,
excludedClashIds: existingIds,
status: selection.statusType,
})
.subscribe({
next: (createdTopics) => {
this.navisworksClashesLoadingService.hideLoadingScreen();
cancellationSubscription.unsubscribe();
this.settingsMessengerService.settings
.pipe(take(1))
.subscribe((s) => {
createdTopics.forEach((topic) => {
topic.creationAuthor = s.username;
});

this.bcfFile.topics.push(...createdTopics);
this.filteredTopics = [...this.bcfFile.topics];
this.bcfFileAutomaticallySaveService.saveCurrentActiveBcfFileAutomatically();
if (selection.onlyImportNew) {
// In that case, we're filtering out those topics that already exist in the
createdTopics = createdTopics.filter(
(topic) =>
!this.bcfFile.topics.some(
(existingTopic) =>
existingTopic.serverAssignedId ===
topic.serverAssignedId
)
);
}

this.teamsMessengerService.sendMessageToTeams(
MessageType.AddNavisworksClashes
);
});
},
error: (error) => {
this.navisworksClashesLoadingService.hideLoadingScreen();
cancellationSubscription.unsubscribe();
console.error(error);
this.notificationsService.error(
'Failed to generate the clash data from Navisworks, this is probably a timeout issue'
);
},
});
});
this.bcfFile.topics.push(...createdTopics);
this.filteredTopics = [...this.bcfFile.topics];
this.bcfFileAutomaticallySaveService.saveCurrentActiveBcfFileAutomatically();

this.teamsMessengerService.sendMessageToTeams(
MessageType.AddNavisworksClashes
);
});
},
error: (error) => {
this.navisworksClashesLoadingService.hideLoadingScreen();
cancellationSubscription.unsubscribe();
console.error(error);
this.notificationsService.error(
'Failed to generate the clash data from Navisworks, this is probably a timeout issue'
);
},
});
}
);
}

setResponsibleForAll(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,22 @@ <h2 mat-dialog-title>Select Clash Test</h2>
}
</mat-select>
</mat-form-field>
<mat-checkbox [(ngModel)]="onlyImportNew">Only Import New</mat-checkbox>
<mat-form-field class="dark-theme">
<mat-label>Status</mat-label>
<mat-select [(value)]="selectedStatusType">
<mat-option [value]="null">All / No Filter</mat-option>
<mat-option [value]="'New'">New</mat-option>
<mat-option [value]="'Active'">Active</mat-option>
<mat-option [value]="'Reviewed'">Reviewed</mat-option>
<mat-option [value]="'Approved'">Approved</mat-option>
<mat-option [value]="'Resolved'">Resolved</mat-option>
</mat-select>
</mat-form-field>
<mat-checkbox
[(ngModel)]="onlyImportNew"
matTooltip="This option imports only clashes that were not previously imported, it does not restrict to only clashes with the status 'New'"
>Only Import New Clashes</mat-checkbox
>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-raised-button (click)="save()" [disabled]="!selectedClashId">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mat-dialog-content {
display: flex;
flex-direction: column;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
import { MatTooltipModule } from '@angular/material/tooltip';

@Component({
selector: 'bcfier-navisworks-clash-selection',
Expand All @@ -22,6 +23,7 @@ import { MatSelectModule } from '@angular/material/select';
MatSelectModule,
MatCheckboxModule,
FormsModule,
MatTooltipModule,
],
templateUrl: './navisworks-clash-selection.component.html',
styleUrl: './navisworks-clash-selection.component.scss',
Expand All @@ -47,11 +49,13 @@ export class NavisworksClashSelectionComponent {

clashes: NavisworksClashSelection[] = [];
selectedClashId: string | null = null;
selectedStatusType: string | null = null;

save(): void {
this.dialogRef.close({
clashId: this.selectedClashId,
onlyImportNew: this.onlyImportNew,
statusType: this.selectedStatusType,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,7 @@ export interface NavisworksClashSelection {

export interface NavisworksClashCreationData {
clashId?: string;
status?: string | null;
excludedClashIds?: string[];
}

Expand Down

0 comments on commit eba9ca8

Please sign in to comment.