You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/11/22 10:23:22 UTC
[06/15] ignite git commit: IGNITE-6914. Web Console: Exporting large
CSV files via file-saver library.
IGNITE-6914. Web Console: Exporting large CSV files via file-saver library.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fe6bbab9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fe6bbab9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fe6bbab9
Branch: refs/heads/ignite-zk
Commit: fe6bbab9aae4efaae84ed9ea0dd908f36c74f9c5
Parents: 58b5041
Author: alexdel <ve...@yandex.ru>
Authored: Tue Nov 21 20:15:32 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Nov 21 20:15:32 2017 +0700
----------------------------------------------------------------------
modules/web-console/frontend/app/app.js | 18 +++++++++---------
.../frontend/app/modules/sql/sql.controller.js | 4 ++--
.../frontend/app/services/LegacyUtils.service.js | 18 +++++-------------
modules/web-console/frontend/package.json | 2 +-
.../web-console/frontend/views/sql/sql.tpl.pug | 4 ++--
5 files changed, 19 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fe6bbab9/modules/web-console/frontend/app/app.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js
index 44454f6..ca678fc 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -142,23 +142,23 @@ angular.module('ignite-console', [
'ngAnimate',
'ngSanitize',
// Third party libs.
- 'ngRetina',
'btford.socket-io',
- 'mgcrea.ngStrap',
- 'ui.router',
- 'ui.router.state.events',
- 'gridster',
'dndLists',
+ 'gridster',
+ 'mgcrea.ngStrap',
+ 'ngRetina',
'nvd3',
+ 'pascalprecht.translate',
'smart-table',
'treeControl',
- 'pascalprecht.translate',
'ui.grid',
- 'ui.grid.saveState',
- 'ui.grid.selection',
- 'ui.grid.resizeColumns',
'ui.grid.autoResize',
'ui.grid.exporter',
+ 'ui.grid.resizeColumns',
+ 'ui.grid.saveState',
+ 'ui.grid.selection',
+ 'ui.router',
+ 'ui.router.state.events',
// Base modules.
'ignite-console.core',
'ignite-console.ace',
http://git-wip-us.apache.org/repos/asf/ignite/blob/fe6bbab9/modules/web-console/frontend/app/modules/sql/sql.controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/sql/sql.controller.js b/modules/web-console/frontend/app/modules/sql/sql.controller.js
index e97825c..ea0a06d 100644
--- a/modules/web-console/frontend/app/modules/sql/sql.controller.js
+++ b/modules/web-console/frontend/app/modules/sql/sql.controller.js
@@ -1652,7 +1652,7 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
csvContent += cols.join(';') + '\n';
});
- LegacyUtils.download('application/octet-stream;charset=utf-8', fileName, escape(csvContent));
+ LegacyUtils.download('text/csv', fileName, csvContent);
};
/**
@@ -1767,7 +1767,7 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
};
$scope.scanAvailable = function(paragraph) {
- return $scope.caches.length && !paragraph.loading;
+ return $scope.caches.length && !(paragraph.loading || paragraph.csvIsPreparing);
};
$scope.scanTooltip = function(paragraph) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/fe6bbab9/modules/web-console/frontend/app/services/LegacyUtils.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/LegacyUtils.service.js b/modules/web-console/frontend/app/services/LegacyUtils.service.js
index be593b0..b19bde3 100644
--- a/modules/web-console/frontend/app/services/LegacyUtils.service.js
+++ b/modules/web-console/frontend/app/services/LegacyUtils.service.js
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+import saver from 'file-saver';
+
// TODO: Refactor this service for legacy tables with more than one input field.
export default ['IgniteLegacyUtils', ['IgniteErrorPopover', (ErrorPopover) => {
function isDefined(v) {
@@ -351,20 +353,10 @@ export default ['IgniteLegacyUtils', ['IgniteErrorPopover', (ErrorPopover) => {
return !isEmpty;
},
domainForStoreConfigured,
- download(type, name, data) {
- const file = document.createElement('a');
-
- file.setAttribute('href', 'data:' + type + ';charset=utf-8,' + data);
- file.setAttribute('download', name);
- file.setAttribute('target', '_self');
-
- file.style.display = 'none';
-
- document.body.appendChild(file);
-
- file.click();
+ download(type = 'application/octet-stream', name = 'file.txt', data = '') {
+ const file = new Blob([data], { type: `${type};charset=utf-8`});
- document.body.removeChild(file);
+ saver.saveAs(file, name, false);
},
getQueryVariable(name) {
const attrs = window.location.search.substring(1).split('&');
http://git-wip-us.apache.org/repos/asf/ignite/blob/fe6bbab9/modules/web-console/frontend/package.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/package.json b/modules/web-console/frontend/package.json
index 49e69b4..18635f7 100644
--- a/modules/web-console/frontend/package.json
+++ b/modules/web-console/frontend/package.json
@@ -76,8 +76,8 @@
"html-loader": "0.4.5",
"html-webpack-plugin": "2.29.0",
"jquery": "3.2.1",
- "json-loader": "0.5.7",
"json-bigint": "0.2.3",
+ "json-loader": "0.5.7",
"jszip": "3.1.4",
"lodash": "4.17.4",
"node-sass": "4.6.0",
http://git-wip-us.apache.org/repos/asf/ignite/blob/fe6bbab9/modules/web-console/frontend/views/sql/sql.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/sql/sql.tpl.pug b/modules/web-console/frontend/views/sql/sql.tpl.pug
index 44989e8..a53a082 100644
--- a/modules/web-console/frontend/views/sql/sql.tpl.pug
+++ b/modules/web-console/frontend/views/sql/sql.tpl.pug
@@ -204,7 +204,7 @@ mixin table-result-heading-scan
button.btn.btn-primary.btn--with-icon(
ng-click='exportCsv(paragraph)'
- ng-disabled='paragraph.loading'
+ ng-disabled='paragraph.loading || paragraph.csvIsPreparing'
bs-tooltip=''
ng-attr-title='{{ scanTooltip(paragraph) }}'
@@ -218,7 +218,7 @@ mixin table-result-heading-scan
-var options = [{ text: "Export", click: 'exportCsv(paragraph)' }, { text: 'Export all', click: 'exportCsvAll(paragraph)' }]
button.btn.dropdown-toggle.btn-primary(
- ng-disabled='paragraph.loading'
+ ng-disabled='paragraph.loading || paragraph.csvIsPreparing'
bs-dropdown=`${JSON.stringify(options)}`