OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix add button by adding directly to parent component
Oliver Günther445277d24280
diff --git a/frontend/src/app/modules/bim/bcf/bcf-gallery/bcf-add-viewpoint-button.component.ts b/frontend/src/app/modules/bim/bcf/bcf-gallery/bcf-add-viewpoint-button.component.tsdeleted file mode 100644index 49c104480e3..00000000000--- a/frontend/src/app/modules/bim/bcf/bcf-gallery/bcf-add-viewpoint-button.component.ts+++ /dev/null@@ -1,103 +0,0 @@-// -- copyright-// OpenProject is a project management system.-// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)-//-// 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 doc/COPYRIGHT.rdoc for more details.-// ++--import {Component, Input, OnDestroy, OnInit} from '@angular/core';-import {I18nService} from 'core-app/modules/common/i18n/i18n.service';-import {CurrentProjectService} from "core-components/projects/current-project.service";-import {HttpClient, HttpHeaders} from "@angular/common/http";-import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";-import {ViewerBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge.service";--@Component({- template: `- <a [title]="text.add_viewpoint" class="button" (click)="handleClick()">- <op-icon icon-classes="button--icon icon-add"></op-icon>- <span class="button--text"> {{text.viewpoint}} </span>- </a>- `,- selector: 'bcf-add-viewpoint-button',-})-export class BcfAddViewpointButtonComponent implements OnInit, OnDestroy {- @Input() public workPackage:WorkPackageResource;-- public text = {- viewpoint: this.I18n.t('js.bcf.viewpoint'),- add_viewpoint: this.I18n.t('js.bcf.add_viewpoint'),- };-- constructor(readonly I18n:I18nService,- readonly currentProject:CurrentProjectService,- readonly viewerBridge:ViewerBridgeService,- readonly httpClient:HttpClient) {- }-- public handleClick() {- this.viewerBridge.getViewpoint().then((message) => this.saveViewpoint(message));- }-- private saveViewpoint(message:any):void {- let viewpointJson = message["messagePayload"];-- viewpointJson.snapshot = {- snapshot_type: 'png',- snapshot_data: viewpointJson.snapshot- };-- const headers = new HttpHeaders()- .set("Content-Type", "application/json");- this.httpClient- .post(- `/api/bcf/2.1/projects/${this.projectIdentifier()}/topics/${this.topicUuid()}/viewpoints`,- viewpointJson,- {- headers: headers,- withCredentials: true,- responseType: 'json'- }- ).subscribe((data) => {- console.log("Response of posting viewpoint", data);- });- }--- public ngOnInit():void {- console.log("init add viewpoint button component");- }-- public ngOnDestroy():void {- // nop- }-- private projectIdentifier():string|null {- return this.currentProject.identifier;- }-- private topicUuid():string {- return this.workPackage.bcf.uuid;- }-}diff --git a/frontend/src/app/modules/bim/bcf/bcf-viewer-bridge/revit-bridge.service.ts b/frontend/src/app/modules/bim/bcf/bcf-viewer-bridge/revit-bridge.service.tsindex 894b67dd0bb..2ea35accc9b 100644--- a/frontend/src/app/modules/bim/bcf/bcf-viewer-bridge/revit-bridge.service.ts+++ b/frontend/src/app/modules/bim/bcf/bcf-viewer-bridge/revit-bridge.service.ts@@ -24,7 +24,7 @@ export class RevitBridgeService extends ViewerBridgeService {constructor() {super();-+if (window.RevitBridge) {console.log("window.RevitBridge is already there, so let's hook up the Revit Listener");this.hookUpRevitListener();@@ -48,7 +48,17 @@ export class RevitBridgeService extends ViewerBridgeService {filter(message => message.messageType === 'ViewpointData' && message.trackingId === trackingId),first())- .toPromise();+ .toPromise()+ .then((message) => {+ let viewpointJson = JSON.parse(message.messagePayload);++ viewpointJson.snapshot = {+ snapshot_type: 'png',+ snapshot_data: viewpointJson.snapshot+ };++ return viewpointJson;+ });}showViewpoint(data:BcfViewpointInterface) {diff --git a/frontend/src/app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge-service.factory.ts b/frontend/src/app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge-service.factory.tsdeleted file mode 100644index 23d758e0109..00000000000--- a/frontend/src/app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge-service.factory.ts+++ /dev/null@@ -1,18 +0,0 @@-import {RevitBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/revit-bridge.service";-import {XeokitBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/xeokit-bridge.service";-import {Injector} from "@angular/core";-import {IFCViewerService} from "core-app/modules/bim/ifc_models/ifc-viewer/ifc-viewer.service";--/**- * Determines based on the current user agent whether- * we're running in Revit or not.- *- * Depending on that, we use the IFC viewer service for showing/saving viewpoints.- */-export function viewerBridgeServiceFactory(injector:Injector) {- if (window.navigator.userAgent.search('Revit') > -1) {- return new RevitBridgeService();- } else {- return new XeokitBridgeService(injector.get(IFCViewerService));- }-}\ No newline at end of filediff --git a/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html b/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.htmlindex a6db365c819..f7ba4c0cc3a 100644--- a/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html+++ b/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.html@@ -14,5 +14,8 @@</ngx-gallery></div>- <bcf-add-viewpoint-button [workPackage]="workPackage"></bcf-add-viewpoint-button>+ <a [title]="text.add_viewpoint" class="button" (click)="saveCurrentAsViewpoint()">+ <op-icon icon-classes="button--icon icon-add"></op-icon>+ <span class="button--text"> {{text.viewpoint}} </span>+ </a></div>\ No newline at end of filediff --git a/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts b/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.tsindex fcd099a94dd..fa02899a90e 100644--- a/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts+++ b/frontend/src/app/modules/bim/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts@@ -87,7 +87,9 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {topicUUID:string;text = {- bcf: this.I18n.t('js.bcf.label_bcf')+ bcf: this.I18n.t('js.bcf.label_bcf'),+ viewpoint: this.I18n.t('js.bcf.viewpoint'),+ add_viewpoint: this.I18n.t('js.bcf.add_viewpoint'),};constructor(readonly state:StateService,@@ -137,7 +139,6 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {.viewpoints.id(viewpointUuid).get().subscribe(data => {- // TODO abstract from revitthis.viewerBridge.showViewpoint(data);});}@@ -150,7 +151,6 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {.topics.id(this.topicUUID).viewpoints.post(viewpoint);-}galleryPreviewOpen():void {diff --git a/frontend/src/app/modules/bim/bcf/openproject-bcf.module.ts b/frontend/src/app/modules/bim/bcf/openproject-bcf.module.tsindex 76927dd5279..1354fbdf91b 100644--- a/frontend/src/app/modules/bim/bcf/openproject-bcf.module.ts+++ b/frontend/src/app/modules/bim/bcf/openproject-bcf.module.ts@@ -38,10 +38,25 @@ import {OpenProjectHeaderInterceptor} from "core-app/modules/hal/http/openprojecimport {BcfDetectorService} from "core-app/modules/bim/bcf/helper/bcf-detector.service";import {BcfPathHelperService} from "core-app/modules/bim/bcf/helper/bcf-path-helper.service";import {ViewerBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge.service";-import {viewerBridgeServiceFactory} from "core-app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge-service.factory";import {BcfImportButtonComponent} from "core-app/modules/bim/ifc_models/toolbar/import-export-bcf/bcf-import-button.component";import {BcfExportButtonComponent} from "core-app/modules/bim/ifc_models/toolbar/import-export-bcf/bcf-export-button.component";-import {BcfAddViewpointButtonComponent} from "core-app/modules/bim/bcf/bcf-gallery/bcf-add-viewpoint-button.component";+import {RevitBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/revit-bridge.service";+import {XeokitBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/xeokit-bridge.service";+import {IFCViewerService} from "core-app/modules/bim/ifc_models/ifc-viewer/ifc-viewer.service";++/**+ * Determines based on the current user agent whether+ * we're running in Revit or not.+ *+ * Depending on that, we use the IFC viewer service for showing/saving viewpoints.+ */+export const viewerBridgeServiceFactory = (injector:Injector) => {+ if (window.navigator.userAgent.search('Revit') > -1) {+ return new RevitBridgeService();+ } else {+ return new XeokitBridgeService(injector.get(IFCViewerService));+ }+};@NgModule({imports: [@@ -53,19 +68,21 @@ import {BcfAddViewpointButtonComponent} from "core-app/modules/bim/bcf/bcf-galle{ provide: HTTP_INTERCEPTORS, useClass: OpenProjectHeaderInterceptor, multi: true },BcfDetectorService,BcfPathHelperService,- { provide: ViewerBridgeService, useFactory: viewerBridgeServiceFactory }+ {+ provide: ViewerBridgeService,+ useFactory: viewerBridgeServiceFactory,+ deps: [Injector]+ }],declarations: [BcfWpSingleViewComponent,BcfImportButtonComponent,BcfExportButtonComponent,- BcfAddViewpointButtonComponent],exports: [BcfWpSingleViewComponent,BcfImportButtonComponent,BcfExportButtonComponent,- BcfAddViewpointButtonComponent]})export class OpenprojectBcfModule {