From f7dcf5438a885b4531ca9a85f52c014da42a4544 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 27 Jul 2017 14:14:56 +0200
Subject: [PATCH] common code extracted from panels

---
 .../src/main/js/gui/export/AbstractExportPanel.js    | 12 +++++++++---
 .../src/main/js/gui/export/ElementExportPanel.js     |  1 -
 .../src/main/js/gui/export/GraphicsExportPanel.js    |  3 +--
 .../src/main/js/gui/export/NetworkExportPanel.js     |  4 +---
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/frontend-js/src/main/js/gui/export/AbstractExportPanel.js b/frontend-js/src/main/js/gui/export/AbstractExportPanel.js
index 4eea71a0f3..2f16acc9ab 100644
--- a/frontend-js/src/main/js/gui/export/AbstractExportPanel.js
+++ b/frontend-js/src/main/js/gui/export/AbstractExportPanel.js
@@ -4,13 +4,13 @@
 
 var Panel = require('../Panel');
 
+var GuiConnector = require('../../GuiConnector');
 var logger = require('../../logger');
 var Functions = require('../../Functions');
 var DualListbox = require('dual-listbox').DualListbox;
 var Promise = require("bluebird");
 
 function AbstractExportPanel(params) {
-  params.panelName = "elementExport";
   params.scrollable = true;
   Panel.call(this, params);
 
@@ -276,13 +276,19 @@ AbstractExportPanel.prototype._createDownloadButton = function() {
     name : "downloadButton",
     content : " Download",
     onclick : function() {
+      GuiConnector.showProcessing();
       return self.createResponseString().then(function(result) {
         var blob = new Blob([ result ], {
           type : "text/plain;charset=utf-8"
         });
         var FileSaver = require("file-saver");
-        return FileSaver.saveAs(blob, self.getProject().getProjectId() + "-elements.txt");
-      }).then(null, GuiConnector.alert);
+        return FileSaver.saveAs(blob, self.getProject().getProjectId() + "-" + self.getPanelName() + ".txt");
+      }).then(function() {
+        GuiConnector.hideProcessing();
+      }, function(error) {
+        GuiConnector.hideProcessing();
+        GuiConnector.alert(error);
+      });
     },
   });
   downloadDiv.appendChild(button);
diff --git a/frontend-js/src/main/js/gui/export/ElementExportPanel.js b/frontend-js/src/main/js/gui/export/ElementExportPanel.js
index f56db727ae..59868a6b1b 100644
--- a/frontend-js/src/main/js/gui/export/ElementExportPanel.js
+++ b/frontend-js/src/main/js/gui/export/ElementExportPanel.js
@@ -11,7 +11,6 @@ var Promise = require("bluebird");
 
 function ElementExportPanel(params) {
   params.panelName = "elementExport";
-  params.scrollable = true;
   AbstractExportPanel.call(this, params);
 }
 
diff --git a/frontend-js/src/main/js/gui/export/GraphicsExportPanel.js b/frontend-js/src/main/js/gui/export/GraphicsExportPanel.js
index 6bf41a4246..0506c3af96 100644
--- a/frontend-js/src/main/js/gui/export/GraphicsExportPanel.js
+++ b/frontend-js/src/main/js/gui/export/GraphicsExportPanel.js
@@ -7,8 +7,7 @@ var Panel = require('../Panel');
 var logger = require('../../logger');
 
 function GraphicsExportPanel(params) {
-  params.panelName = "elementExport";
-  params.scrollable = true;
+  params.panelName = "graphicsExport";
   Panel.call(this, params);
 }
 
diff --git a/frontend-js/src/main/js/gui/export/NetworkExportPanel.js b/frontend-js/src/main/js/gui/export/NetworkExportPanel.js
index 097d0caf0a..d93fdebae2 100644
--- a/frontend-js/src/main/js/gui/export/NetworkExportPanel.js
+++ b/frontend-js/src/main/js/gui/export/NetworkExportPanel.js
@@ -10,10 +10,8 @@ var GuiMessageError = require('../GuiMessageError');
 
 
 function NetworkExportPanel(params) {
-  params.panelName = "elementExport";
-  params.scrollable = true;
+  params.panelName = "networkExport";
   AbstractExportPanel.call(this, params);
-
 }
 
 NetworkExportPanel.prototype = Object.create(AbstractExportPanel.prototype);
-- 
GitLab