Fix eslint issues and merge conflicts in bim module

This commit is contained in:
Eric Schubert
2021-10-20 17:06:54 +02:00
parent 7fd3fda7d9
commit 3cb0690563
4 changed files with 99 additions and 34 deletions
+1 -1
View File
@@ -384,7 +384,7 @@ ij_typescript_align_multiline_binary_operation = false
ij_typescript_align_multiline_chained_methods = false
ij_typescript_align_multiline_extends_list = false
ij_typescript_align_multiline_for = true
ij_typescript_align_multiline_parameters = true
ij_typescript_align_multiline_parameters = false
ij_typescript_align_multiline_parameters_in_calls = false
ij_typescript_align_multiline_ternary_operation = false
ij_typescript_align_object_properties = 0
@@ -42,7 +42,7 @@ import { I18nService } from 'core-app/core/i18n/i18n.service';
import { CurrentUserService } from 'core-app/core/current-user/current-user.service';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { BehaviorSubject, combineLatest, Subject } from 'rxjs';
import { take } from "rxjs/operators";
import { take } from 'rxjs/operators';
@Component({
selector: 'op-ifc-viewer',
@@ -80,11 +80,11 @@ export class IFCViewerComponent implements OnInit, OnDestroy, AfterViewInit {
@ViewChild('inspectorPane') inspectorElement:ElementRef;
constructor(private I18n:I18nService,
private elementRef:ElementRef,
public ifcData:IfcModelsDataService,
private ifcViewerService:IFCViewerService,
private currentUserService:CurrentUserService,
private currentProjectService:CurrentProjectService) {
private elementRef:ElementRef,
public ifcData:IfcModelsDataService,
private ifcViewerService:IFCViewerService,
private currentUserService:CurrentUserService,
private currentProjectService:CurrentProjectService) {
}
ngOnInit():void {
@@ -132,7 +132,7 @@ export class IFCViewerComponent implements OnInit, OnDestroy, AfterViewInit {
this.ifcViewerService.destroy();
}
toggleInspector() {
toggleInspector():void {
this.ifcViewerService.inspectorVisible$.next(!this.inspectorVisible$.getValue());
}
@@ -141,6 +141,7 @@ export class IFCViewerComponent implements OnInit, OnDestroy, AfterViewInit {
@HostListener('keydown', ['$event'])
@HostListener('keyup', ['$event'])
@HostListener('keypress', ['$event'])
// eslint-disable-next-line class-methods-use-this
cancelAllKeyEvents($event:KeyboardEvent):void {
$event.stopPropagation();
}
@@ -155,7 +156,7 @@ export class IFCViewerComponent implements OnInit, OnDestroy, AfterViewInit {
@HostListener('window:mousedown', ['$event.target'])
disableKeyboard(target:Element):void {
if (this.modelCount && !this.outerContainer.nativeElement?.contains(target)) {
if (this.modelCount && !(this.outerContainer.nativeElement as HTMLElement).contains(target)) {
this.keyboardEnabled = false;
this.ifcViewerService.setKeyboardEnabled(false);
}
@@ -165,7 +166,7 @@ export class IFCViewerComponent implements OnInit, OnDestroy, AfterViewInit {
this.enableKeyBoard();
// Focus on the canvas
this.modelCanvas.nativeElement.focus();
(this.modelCanvas.nativeElement as HTMLElement).focus();
// Ensure we don't bubble this event to the window:mousedown handler
// as the target will already be removed from the DOM by angular
@@ -1,3 +1,31 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++
import { Injectable, Injector } from '@angular/core';
import { XeokitServer } from 'core-app/features/bim/ifc_models/xeokit/xeokit-server';
import { BcfViewpointInterface } from 'core-app/features/bim/bcf/api/viewpoints/bcf-viewpoint.interface';
@@ -10,6 +38,7 @@ import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decora
import { ViewpointsService } from 'core-app/features/bim/bcf/helper/viewpoints.service';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
import { HttpClient } from '@angular/common/http';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
export interface XeokitElements {
canvasElement:HTMLElement;
@@ -71,7 +100,7 @@ export class IFCViewerService extends ViewerBridgeService {
}
public newViewer(elements:XeokitElements, projects:any[]):void {
import('@xeokit/xeokit-bim-viewer/dist/xeokit-bim-viewer.es').then((XeokitViewerModule:any) => {
void import('@xeokit/xeokit-bim-viewer/dist/xeokit-bim-viewer.es').then((XeokitViewerModule:any) => {
const server = new XeokitServer(this.pathHelper);
const viewerUI = new XeokitViewerModule.BIMViewer(server, elements);
@@ -174,7 +203,7 @@ export class IFCViewerService extends ViewerBridgeService {
// and redirect to a route with a place to show viewer
// ('bim.partitioned.split')
window.location.href = this.pathHelper.bimDetailsPath(
workPackage.project.idFromLink,
idFromLink(workPackage.project.href),
workPackage.id!,
index,
);
@@ -1,6 +1,36 @@
// -- copyright
// OpenProject is an open source project management software.
// Copyright (C) 2012-2021 the OpenProject GmbH
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See COPYRIGHT and LICENSE files for more details.
//++
import { Injectable, Injector } from '@angular/core';
import { Observable, Subject, BehaviorSubject } from "rxjs";
import { distinctUntilChanged, filter, first, map } from 'rxjs/operators';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import {
distinctUntilChanged, filter, first, map,
} from 'rxjs/operators';
import { BcfViewpointInterface } from 'core-app/features/bim/bcf/api/viewpoints/bcf-viewpoint.interface';
import { ViewerBridgeService } from 'core-app/features/bim/bcf/bcf-viewer-bridge/viewer-bridge.service';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
@@ -16,12 +46,20 @@ declare global {
}
}
type RevitBridgeMessage = {
messageType:string,
trackingId:string,
messagePayload:BcfViewpointInterface
};
@Injectable()
export class RevitBridgeService extends ViewerBridgeService {
public shouldShowViewer = false;
public viewerVisible$ = new BehaviorSubject<boolean>(false);
private revitMessageReceivedSource =
new Subject<{ messageType:string, trackingId:string, messagePayload:BcfViewpointInterface }>();
private revitMessageReceivedSource = new Subject<RevitBridgeMessage>();
private trackingIdNumber = 0;
@InjectField() viewpointsService:ViewpointsService;
@@ -52,7 +90,7 @@ export class RevitBridgeService extends ViewerBridgeService {
return this.revitMessageReceived$
.pipe(
distinctUntilChanged(),
filter(message => message.messageType === 'ViewpointData' && message.trackingId === trackingId),
filter((message) => message.messageType === 'ViewpointData' && message.trackingId === trackingId),
first(),
map((message) => {
// FIXME: Deprecated code
@@ -60,8 +98,8 @@ export class RevitBridgeService extends ViewerBridgeService {
// newer versions the message payload is sent correctly and needs no special treatment
const viewpointJson = message.messagePayload;
if (viewpointJson.snapshot.hasOwnProperty('snapshot_type') &&
viewpointJson.snapshot.hasOwnProperty('snapshot_data')) {
if (viewpointJson.snapshot.hasOwnProperty('snapshot_type') // eslint-disable-line no-prototype-builtins
&& viewpointJson.snapshot.hasOwnProperty('snapshot_data')) { // eslint-disable-line no-prototype-builtins
// already correctly formatted payload
return viewpointJson;
}
@@ -80,13 +118,9 @@ export class RevitBridgeService extends ViewerBridgeService {
public showViewpoint(workPackage:WorkPackageResource, index:number):void {
this.viewpointsService
.getViewPoint$(workPackage, index)
.subscribe((viewpoint:BcfViewpointInterface) =>
this.sendMessageToRevit(
'ShowViewpoint',
this.newTrackingId(),
JSON.stringify(viewpoint),
),
);
.subscribe((viewpoint:BcfViewpointInterface) => this.sendMessageToRevit(
'ShowViewpoint', this.newTrackingId(), JSON.stringify(viewpoint),
));
}
sendMessageToRevit(messageType:string, trackingId:string, messagePayload:string):void {
@@ -99,22 +133,23 @@ export class RevitBridgeService extends ViewerBridgeService {
private hookUpRevitListener() {
window.RevitBridge.sendMessageToOpenProject = (messageString:string) => {
const message = JSON.parse(messageString);
const messageType = message.messageType;
const trackingId = message.trackingId;
const messagePayload = JSON.parse(message.messagePayload);
const { messageType, trackingId, messagePayload } = JSON.parse(messageString) as {
messageType:string,
trackingId:string,
messagePayload:string
};
this.revitMessageReceivedSource.next({
messageType: messageType,
trackingId: trackingId,
messagePayload: messagePayload,
messageType,
trackingId,
messagePayload: JSON.parse(messagePayload) as BcfViewpointInterface,
});
};
this.viewerVisible$.next(true);
}
newTrackingId():string {
this.trackingIdNumber = this.trackingIdNumber + 1;
this.trackingIdNumber += 1;
return String(this.trackingIdNumber);
}
}