This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch rel/0.67.0
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/rel/0.67.0 by this push:
     new d52642b  [STREAMPIPES-217] Improve file upload behaviour
d52642b is described below

commit d52642b111264a9b11f80a04d08b4208a37357b9
Author: Dominik Riemer <[email protected]>
AuthorDate: Thu Sep 17 23:53:58 2020 +0200

    [STREAMPIPES-217] Improve file upload behaviour
---
 .../org/apache/streampipes/manager/file/FileManager.java  |  3 ++-
 .../apache/streampipes/rest/impl/PipelineElementFile.java |  4 ++--
 .../static-file-input/static-file-input.component.html    |  2 +-
 .../static-file-input/static-file-input.component.ts      | 15 ++++++++++-----
 4 files changed, 15 insertions(+), 9 deletions(-)

diff --git 
a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java
 
b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java
index 2c21424..af1e7a6 100644
--- 
a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java
+++ 
b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/file/FileManager.java
@@ -28,7 +28,7 @@ import java.util.UUID;
 
 public class FileManager {
 
-  public static void storeFile(String user,
+  public static FileMetadata storeFile(String user,
                                String filename,
                                InputStream fileInputStream) throws IOException 
{
 
@@ -37,6 +37,7 @@ public class FileManager {
     FileMetadata fileMetadata = makeFileMetadata(user, filename, 
internalFilename, filetype);
     new FileHandler().storeFile(internalFilename, fileInputStream);
     storeFileMetadata(fileMetadata);
+    return fileMetadata;
   }
 
   public static void deleteFile(String id) {
diff --git 
a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java
 
b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java
index 8d4e670..c9e4ad3 100644
--- 
a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java
+++ 
b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/PipelineElementFile.java
@@ -40,8 +40,8 @@ public class PipelineElementFile extends 
AbstractRestInterface implements IPipel
                             @FormDataParam("file_upload") InputStream 
uploadedInputStream,
                             @FormDataParam("file_upload") 
FormDataContentDisposition fileDetail) {
     try {
-      FileManager.storeFile(username, fileDetail.getFileName(), 
uploadedInputStream);
-      return ok();
+      FileMetadata metadata = FileManager.storeFile(username, 
fileDetail.getFileName(), uploadedInputStream);
+      return ok(metadata);
     } catch (Exception e) {
       return fail();
     }
diff --git 
a/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.html
 
b/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.html
index 5176f4d..7134363 100644
--- 
a/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.html
+++ 
b/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.html
@@ -66,7 +66,7 @@
             </mat-form-field>
             <!--<div fxLayoutAlign="center none">-->
             <div>
-                <button color="primary" mat-raised-button (click)="upload()">
+                <button color="primary" mat-raised-button (click)="upload()" 
[disabled]="!fileName">
                     Upload
                 </button>
             </div>
diff --git 
a/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
 
b/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
index cdf372f..279d253 100644
--- 
a/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
+++ 
b/ui/src/app/core-ui/static-properties/static-file-input/static-file-input.component.ts
@@ -62,10 +62,16 @@ export class StaticFileInputComponent extends 
AbstractStaticPropertyRenderer<Fil
         this.fetchFileMetadata();
     }
 
-    fetchFileMetadata() {
+    fetchFileMetadata(internalFilenameToSelect?: any) {
         
this.filesService.getFileMetadata(this.staticProperty.requiredFiletypes).subscribe(fm
 => {
             this.fileMetadata = fm;
-            if (this.staticProperty.locationPath) {
+            if (internalFilenameToSelect) {
+                this.chooseExistingFile = true;
+                this.selectedFile =
+                    this.fileMetadata.find(fm => fm.internalFilename === 
internalFilenameToSelect);
+                this.selectOption(this.selectedFile);
+                this.emitUpdate(true);
+            } else if (this.staticProperty.locationPath) {
                 this.selectedFile =
                     this.fileMetadata.find(fm => fm.internalFilename === 
this.staticProperty.locationPath);
             } else {
@@ -95,9 +101,8 @@ export class StaticFileInputComponent extends 
AbstractStaticPropertyRenderer<Fil
                     if (event.type == HttpEventType.UploadProgress) {
                         this.uploadStatus = Math.round(100 * event.loaded / 
event.total);
                     } else if (event instanceof HttpResponse) {
-                        this.fetchFileMetadata();
-                        (<FileStaticProperty> 
(this.staticProperty)).locationPath = event.body.notifications[0].title;
-                               this.emitUpdate(true);
+                        let internalFilename = event.body.internalFilename;
+                        this.fetchFileMetadata(internalFilename);
                     }
                 },
                 error => {

Reply via email to