From dcea0602a35029a105354579f800de881ec0c3b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Thu, 21 Jun 2018 10:17:54 +0200 Subject: [PATCH] Fix uploading for avatar plugin --- frontend/legacy/webpack.config.js | 6 +++--- frontend/src/app/angular4-modules.ts | 13 +++++++++++-- .../api/op-file-upload/op-file-upload.service.ts | 1 + .../notifications/notification.component.html | 2 +- .../hal/http/openproject-header-interceptor.ts | 3 ++- .../plugins/frontend_linking/generator.rb | 2 -- 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/frontend/legacy/webpack.config.js b/frontend/legacy/webpack.config.js index b92f8b9d98..aac469a9c0 100644 --- a/frontend/legacy/webpack.config.js +++ b/frontend/legacy/webpack.config.js @@ -132,11 +132,11 @@ function getLegacyWebpackConfig() { }, resolve: { - // Resolve symlinks from dynamically linked plugins - symlinks: true, + // Don't map symlinks from dynamically linked plugins to their real paths + symlinks: false, modules: [ - 'node_modules', + path.resolve(__dirname, '..', 'node_modules') ], extensions: ['.ts', '.tsx', '.js'], diff --git a/frontend/src/app/angular4-modules.ts b/frontend/src/app/angular4-modules.ts index f3bb1947bf..585e5a4013 100644 --- a/frontend/src/app/angular4-modules.ts +++ b/frontend/src/app/angular4-modules.ts @@ -208,11 +208,11 @@ import {AttributeHelpTextModal} from "./modules/common/help-texts/attribute-help import {CopyToClipboardDirective} from 'core-app/modules/common/copy-to-clipboard/copy-to-clipboard.directive'; import {WorkPackageEmbeddedTableEntryComponent} from "core-components/wp-table/embedded/wp-embedded-table-entry.component"; import {LinkedPluginsModule} from "core-app/modules/plugins/linked-plugins.module"; +import {HookService} from "core-app/modules/plugins/hook-service"; @NgModule({ imports: [ BrowserModule, - UpgradeModule, FormsModule, // UI router routes configuration UIRouterModule.forRoot(), @@ -539,7 +539,7 @@ import {LinkedPluginsModule} from "core-app/modules/plugins/linked-plugins.modul }) export class OpenProjectModule { // noinspection JSUnusedGlobalSymbols - ngDoBootstrap(appRef:ApplicationRef) { + ngDoBootstrap(appRef:ApplicationRef, injector:Injector) { // Already done in openproject-app.ts // this.upgrade.bootstrap(document.body, ['openproject'], {strictDi: false}); @@ -554,6 +554,15 @@ export class OpenProjectModule { { tagName: 'op-ckeditor-form', cls: OpCkeditorFormComponent }, { tagName: 'copy-to-clipboard', cls: CopyToClipboardDirective }, ); + + // Call hook service to allow modules to bootstrap additional elements. + // We can't use ngDoBootstrap in nested modules since they are not called. + const hookService = (appRef as any)._injector.get(HookService); + hookService + .call('openProjectAngularBootstrap') + .forEach((results:{tagName:string, cls:any}[]) => { + bootstrapOptional(appRef, ...results); + }); } } diff --git a/frontend/src/app/components/api/op-file-upload/op-file-upload.service.ts b/frontend/src/app/components/api/op-file-upload/op-file-upload.service.ts index f07ddf077d..bd2a7e09b8 100644 --- a/frontend/src/app/components/api/op-file-upload/op-file-upload.service.ts +++ b/frontend/src/app/components/api/op-file-upload/op-file-upload.service.ts @@ -95,6 +95,7 @@ export class OpenProjectFileUploadService { body: formData, // Observe the response, not the body observe: 'response', + withCredentials: true, // Subscribe to progress events. subscribe() will fire multiple times! reportProgress: true } diff --git a/frontend/src/app/modules/common/notifications/notification.component.html b/frontend/src/app/modules/common/notifications/notification.component.html index b0fcb3cda7..c8e63a8d06 100644 --- a/frontend/src/app/modules/common/notifications/notification.component.html +++ b/frontend/src/app/modules/common/notifications/notification.component.html @@ -26,7 +26,7 @@ *ngFor="let upload of data" [upload]="upload" (onSuccess)="onUploadSuccess()" - (onError)="onUploadError()"> + (onError)="onUploadError($event)"> diff --git a/frontend/src/app/modules/hal/http/openproject-header-interceptor.ts b/frontend/src/app/modules/hal/http/openproject-header-interceptor.ts index b6b2f6c2eb..1d5bd1cfd0 100644 --- a/frontend/src/app/modules/hal/http/openproject-header-interceptor.ts +++ b/frontend/src/app/modules/hal/http/openproject-header-interceptor.ts @@ -15,11 +15,12 @@ export class OpenProjectHeaderInterceptor implements HttpInterceptor { .set('X-Requested-With', 'XMLHttpRequest'); if (csrf_token) { - newHeaders.set('X-CSRF-TOKEN', csrf_token); + newHeaders = newHeaders.set('X-CSRF-TOKEN', csrf_token); } // Clone the request to add the new header const clonedRequest = req.clone({ + withCredentials: true, headers: newHeaders }); diff --git a/lib/open_project/plugins/frontend_linking/generator.rb b/lib/open_project/plugins/frontend_linking/generator.rb index f5e385a426..5f5958fa65 100644 --- a/lib/open_project/plugins/frontend_linking/generator.rb +++ b/lib/open_project/plugins/frontend_linking/generator.rb @@ -100,8 +100,6 @@ module ::OpenProject::Plugins puts "Linking legacy frontend of OpenProject plugin #{name} to #{target}." FileUtils.ln_sf(source, target) end - - generate_plugin_module(plugins) end end