Skip to content

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

Add BCF topic UUID and viewpoint UUIDs to WorkPackageRepresenter

Wieland Lindenthal802231d83bca
diff --git a/frontend/src/app/modules/bcf/bcf-buttons/bcf-show-viewpoint-button.component.ts b/frontend/src/app/modules/bcf/bcf-buttons/bcf-show-viewpoint-button.component.ts
new file mode 100644
index 00000000000..539a4fed641
--- /dev/null
+++ b/frontend/src/app/modules/bcf/bcf-buttons/bcf-show-viewpoint-button.component.ts
@@ -0,0 +1,84 @@
+// -- 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, 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 {BcfPathHelperService} from "core-app/modules/bcf/helper/bcf-path-helper.service";
+import {RevitBridgeService} from "core-app/modules/bcf/services/revit-bridge.service";
+import {distinctUntilChanged, filter} from "rxjs/operators";
+import {untilComponentDestroyed} from "ng2-rx-componentdestroyed";
+
+@Component({
+ template: `
+ <a [title]="text.add_viewpoint" class="button import-bcf-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 {
+ 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 bcfPathHelper:BcfPathHelperService,
+ readonly revitBridgeService:RevitBridgeService) {
+ }
+
+ public handleClick() {
+ console.log("handleClick");
+ const trackingId = this.revitBridgeService.newTrackingId();
+
+ this.revitBridgeService.sendMessageToRevit('ViewpointGenerationRequested', trackingId, '');
+
+ this.revitBridgeService.revitMessageReceived$
+ .pipe(
+ distinctUntilChanged(),
+ filter(message => message.messageType === 'ViewpointGenerated' && message.trackingId === trackingId),
+ untilComponentDestroyed(this)
+ )
+ .subscribe(message => this.saveViewpoint(message));
+ }
+
+ private saveViewpoint(message:any):void {
+ console.log('save viewpoint with', message);
+ }
+
+ public ngOnInit():void {
+ console.log("init add viewpoint button component");
+ }
+
+ public ngOnDestroy():void {
+ // nop
+ }
+}
diff --git a/frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts b/frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts
index 3833d2821d4..6e648508ae8 100644
--- a/frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts
+++ b/frontend/src/app/modules/bcf/bcf-wp-single-view/bcf-wp-single-view.component.ts
@@ -6,8 +6,8 @@ import {PathHelperService} from "core-app/modules/common/path-helper/path-helper
import { NgxGalleryOptions, NgxGalleryImage, NgxGalleryAnimation } from 'ngx-gallery';
-export type ViewPointOriginal = { id:string, file_name:string };
-export type ViewPoint = { id:string, fileName:string, fullPath:string };
+export type ViewPointOriginal = { uuid:string, snapshot_id:string, snapshot_file_name:string };
+export type ViewPoint = { snapshotId:string, snapshotFileName:string, snapshotFullPath:string };
@Component({
selector: 'bcf-wp-single-view',
@@ -43,9 +43,9 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
ngOnInit():void {
this.viewpoints = this.workPackage.bcf.viewpoints.map((vp:ViewPointOriginal):ViewPoint => {
return {
- id: vp.id,
- fileName: vp.file_name,
- fullPath: this.pathHelper.attachmentDownloadPath(vp.id, vp.file_name)
+ snapshotId: vp.snapshot_id,
+ snapshotFileName: vp.snapshot_file_name,
+ snapshotFullPath: this.pathHelper.attachmentDownloadPath(vp.snapshot_id, vp.snapshot_file_name)
};
});
@@ -91,9 +91,9 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
this.galleryImages = this.viewpoints.map((vp:ViewPoint) => {
return {
- small: vp.fullPath,
- medium: vp.fullPath,
- big: vp.fullPath,
+ small: vp.snapshotFullPath,
+ medium: vp.snapshotFullPath,
+ big: vp.snapshotFullPath,
};
});
}
diff --git a/modules/bim/lib/open_project/bim/engine.rb b/modules/bim/lib/open_project/bim/engine.rb
index edd4b0b530b..d11eeebe783 100644
--- a/modules/bim/lib/open_project/bim/engine.rb
+++ b/modules/bim/lib/open_project/bim/engine.rb
@@ -105,10 +105,12 @@ module OpenProject::Bim
getter: ->(*) {
issue = represented.bcf_issue
bcf = {}
+ bcf[:uuid] = issue.uuid
bcf[:viewpoints] = issue.viewpoints.map do |viewpoint|
{
- id: viewpoint.snapshot.id,
- file_name: viewpoint.snapshot.filename
+ uuid: viewpoint.uuid,
+ snapshot_id: viewpoint.snapshot.id,
+ snapshot_file_name: viewpoint.snapshot.filename
}
end
bcf
diff --git a/modules/bim/spec/api/v3/work_packages/work_package_representer_spec.rb b/modules/bim/spec/api/v3/work_packages/work_package_representer_spec.rb
index 864907208a3..3247636bea1 100644
--- a/modules/bim/spec/api/v3/work_packages/work_package_representer_spec.rb
+++ b/modules/bim/spec/api/v3/work_packages/work_package_representer_spec.rb
@@ -61,14 +61,18 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
describe 'with BCF issues' do
it "contains viewpoints" do
- is_expected.to be_json_eql([
+ is_expected.to be_json_eql(
{
- file_name: bcf_issue.viewpoints.first.attachments.first.filename,
- id: bcf_issue.viewpoints.first.attachments.first.id
- }
- ].to_json)
- .including('id')
- .at_path('bcf/viewpoints/')
+ uuid: bcf_issue.uuid,
+ viewpoints: [
+ {
+ uuid: bcf_issue.viewpoints.first.uuid,
+ snapshot_file_name: bcf_issue.viewpoints.first.attachments.first.filename,
+ snapshot_id: bcf_issue.viewpoints.first.attachments.first.id
+ }
+ ]
+ }.to_json
+ ).including('snapshot_id').at_path('bcf')
end
end
end