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

Show notifications and move to last shown index

Oliver Güntherbef21b1ae933
diff --git a/frontend/npm-shrinkwrap.json b/frontend/npm-shrinkwrap.json
index 2c667e4caaa..6ece343cebd 100644
--- a/frontend/npm-shrinkwrap.json
+++ b/frontend/npm-shrinkwrap.json
@@ -4138,13 +4138,20 @@
}
},
"browserslist": {
- "version": "4.6.6",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.6.6.tgz",
- "integrity": "sha512-D2Nk3W9JL9Fp/gIcWei8LrERCS+eXu9AM5cfXA8WEZ84lFks+ARnZ0q/R69m2SV3Wjma83QDDPxsNKXUwdIsyA==",
+ "version": "4.9.1",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.9.1.tgz",
+ "integrity": "sha512-Q0DnKq20End3raFulq6Vfp1ecB9fh8yUNV55s8sekaDDeqBaCtWlRHCUdaWyUeSSBJM7IbM6HcsyaeYqgeDhnw==",
"requires": {
- "caniuse-lite": "^1.0.30000984",
- "electron-to-chromium": "^1.3.191",
- "node-releases": "^1.1.25"
+ "caniuse-lite": "^1.0.30001030",
+ "electron-to-chromium": "^1.3.363",
+ "node-releases": "^1.1.50"
+ },
+ "dependencies": {
+ "caniuse-lite": {
+ "version": "1.0.30001033",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001033.tgz",
+ "integrity": "sha512-8Ibzxee6ibc5q88cM1usPsMpJOG5CTq0s/dKOmlekPbDGKt+UrnOOTPSjQz3kVo6yL7N4SB5xd+FGLHQmbzh6A=="
+ }
}
},
"buffer": {
@@ -5869,9 +5876,9 @@
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"electron-to-chromium": {
- "version": "1.3.235",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.235.tgz",
- "integrity": "sha512-xNabEDbMIKPLQd6xgv4nyyeMaWXIKSJr6G51ZhUemHhbz6kjZAYcygA8CvfEcMF+Mt5eLmDWaLmfSOWdQxzBVQ=="
+ "version": "1.3.375",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.375.tgz",
+ "integrity": "sha512-zmaFnYVBtfpF8bGRYxgPeVAlXB7N3On8rjBE2ROc6wOpTPpzRWaiHo6KkbJMvlH07CH33uks/TEb6kuMMn8q6A=="
},
"elliptic": {
"version": "6.5.2",
@@ -9600,11 +9607,18 @@
}
},
"node-releases": {
- "version": "1.1.27",
- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.27.tgz",
- "integrity": "sha512-9iXUqHKSGo6ph/tdXVbHFbhRVQln4ZDTIBJCzsa90HimnBYc5jw8RWYt4wBYFHehGyC3koIz5O4mb2fHrbPOuA==",
+ "version": "1.1.51",
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.51.tgz",
+ "integrity": "sha512-1eQEs6HFYY1kMXQPOLzCf7HdjReErmvn85tZESMczdCNVWP3Y7URYLBAyYynuI7yef1zj4HN5q+oB2x67QU0lw==",
"requires": {
- "semver": "^5.3.0"
+ "semver": "^6.3.0"
+ },
+ "dependencies": {
+ "semver": {
+ "version": "6.3.0",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
+ "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
+ }
}
},
"node-sass": {
diff --git a/frontend/package.json b/frontend/package.json
index a4e431501d1..60faba7bab2 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -47,7 +47,7 @@
"@fullcalendar/daygrid": "4.4.0",
"@fullcalendar/interaction": "4.4.0",
"@fullcalendar/timegrid": "4.4.0",
- "@kolkov/ngx-gallery": "^1.0.10",
+ "@kolkov/ngx-gallery": "^1.0.11",
"@ng-select/ng-option-highlight": "0.0.4",
"@ng-select/ng-select": "^3.7.2",
"@sentry/browser": "^5.13.0",
diff --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.html
index 02926a9b3c7..55ba9890912 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
@@ -9,6 +9,8 @@
<div class="bcf--viewpoints" *ngIf="galleryImages.length > 0">
<ngx-gallery [options]="galleryOptions"
[images]="galleryImages"
+ (change)="onGalleryChanged($event)"
+ (imagesReady)="onGalleryLoaded()"
(previewOpen)="galleryPreviewOpen()"
(previewClose)="galleryPreviewClose()">
</ngx-gallery>
diff --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.ts
index 5719225de38..b141e30e599 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
@@ -1,7 +1,15 @@
-import {ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit} from "@angular/core";
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy,
+ ChangeDetectorRef,
+ Component,
+ Input,
+ OnDestroy,
+ ViewChild
+} from "@angular/core";
import {StateService} from "@uirouter/core";
import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";
-import {NgxGalleryImage, NgxGalleryOptions} from '@kolkov/ngx-gallery';
+import {NgxGalleryComponent, NgxGalleryImage, NgxGalleryOptions} from '@kolkov/ngx-gallery';
import {PathHelperService} from "core-app/modules/common/path-helper/path-helper.service";
import {HalLink} from "core-app/modules/hal/hal-link/hal-link";
import {BcfApiService} from "core-app/modules/bim/bcf/api/bcf-api.service";
@@ -11,6 +19,7 @@ import {I18nService} from "core-app/modules/common/i18n/i18n.service";
import {ViewerBridgeService} from "core-app/modules/bim/bcf/bcf-viewer-bridge/viewer-bridge.service";
import {WorkPackageCacheService} from "core-components/work-packages/work-package-cache.service";
import {untilComponentDestroyed} from "ng2-rx-componentdestroyed";
+import {NotificationsService} from "core-app/modules/common/notifications/notifications.service";
export type ViewPoint = { snapshotId:string, snapshotFullPath:string };
@@ -20,16 +29,20 @@ export type ViewPoint = { snapshotId:string, snapshotFullPath:string };
styleUrls: ['./bcf-wp-single-view.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush
})
-export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
+export class BcfWpSingleViewComponent implements AfterViewInit, OnDestroy {
@Input() workPackage:WorkPackageResource;
+ @ViewChild(NgxGalleryComponent) gallery:NgxGalleryComponent;
+
text = {
bcf: this.I18n.t('js.bcf.label_bcf'),
viewpoint: this.I18n.t('js.bcf.viewpoint'),
add_viewpoint: this.I18n.t('js.bcf.add_viewpoint'),
show_viewpoint: this.I18n.t('js.bcf.show_viewpoint'),
delete_viewpoint: this.I18n.t('js.bcf.delete_viewpoint'),
- text_are_you_sure: this.I18n.t('js.text_are_you_sure')
+ text_are_you_sure: this.I18n.t('js.text_are_you_sure'),
+ notice_successful_create: this.I18n.t('js.notice_successful_create'),
+ notice_successful_delete: this.I18n.t('js.notice_successful_delete'),
};
actions = [
@@ -50,6 +63,9 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
width: '100%',
height: '400px',
+ // Show first thumbnail by default
+ startIndex: 0,
+
// Show only one image ("thumbnail")
// and disable the large image slideshow
image: false,
@@ -102,10 +118,12 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
readonly bcfApi:BcfApiService,
readonly viewerBridge:ViewerBridgeService,
readonly wpCache:WorkPackageCacheService,
+ readonly notifications:NotificationsService,
+ readonly cdRef:ChangeDetectorRef,
readonly I18n:I18nService) {
}
- ngOnInit():void {
+ ngAfterViewInit():void {
this.wpCache
.observe(this.workPackage.id!)
.pipe(
@@ -116,6 +134,7 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
if (wp.bcfViewpoints) {
this.setViewpoints();
+ this.cdRef.detectChanges();
}
});
}
@@ -143,6 +162,7 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
.delete()
.subscribe(data => {
// Update the work package to reload the viewpoint
+ this.notifications.addSuccess(this.text.notice_successful_delete);
this.wpCache.require(this.workPackage.id!, true);
});
}
@@ -158,6 +178,8 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
.post(viewpoint)
.subscribe((result) => {
// Update the work package to reload the viewpoint
+ this.notifications.addSuccess(this.text.notice_successful_create);
+ this.showIndex = this.viewpoints.length;
this.wpCache.require(this.workPackage.id!, true);
});
}
@@ -170,6 +192,24 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
jQuery('#top-menu').removeClass('-no-z-index');
}
+ onGalleryLoaded() {
+ setTimeout(() => this.gallery.show(this.showIndex), 250);
+ }
+
+ onGalleryChanged(event:{ index:number }) {
+ this.showIndex = event.index;
+ }
+
+ private set showIndex(value:number) {
+ const options = [...this.galleryOptions];
+ options[0].startIndex = value;
+ this.galleryOptions = options;
+ }
+
+ private get showIndex():number {
+ return this.galleryOptions[0].startIndex!;
+ }
+
private get topicUUID():string|null {
const topicHref:string|undefined = this.workPackage.bcfTopic?.href;
@@ -190,6 +230,14 @@ export class BcfWpSingleViewComponent implements OnInit, OnDestroy {
}
private setViewpoints() {
+ const length = this.workPackage.bcfViewpoints.length;
+
+ if (this.showIndex < 0 || length < 1) {
+ this.showIndex = 0;
+ } else if (this.showIndex >= length) {
+ this.showIndex = length - 1;
+ }
+
this.viewpoints = this.workPackage.bcfViewpoints.map((vp:HalLink) => {
const viewpointResource = this.bcfApi.parse<BcfViewpointPaths>(vp.href!);