ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [10/16] ignite git commit: IGNITE-7225 Web Console: Added detection of CSV separator based on browser locale.
Date Fri, 12 Jan 2018 07:54:18 GMT
IGNITE-7225 Web Console: Added detection of CSV separator based on browser locale.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d8ce43ac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d8ce43ac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d8ce43ac

Branch: refs/heads/ignite-zk-join
Commit: d8ce43ac062cc9ff5e600fe994dfcdfd4f50759a
Parents: f6e103d
Author: Ilya Borisov <Klaster1@gmail.com>
Authored: Fri Jan 12 10:11:50 2018 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Jan 12 10:11:50 2018 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/app/app.js         |  2 ++
 .../app/components/grid-export/component.js     | 11 +++++++---
 .../app/components/page-queries/controller.js   | 15 +++++++++----
 .../web-console/frontend/app/services/CSV.js    | 22 ++++++++++++++++++++
 4 files changed, 43 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d8ce43ac/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 332bc24..7380124 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -92,6 +92,7 @@ import ModelNormalizer from './services/ModelNormalizer.service.js';
 import UnsavedChangesGuard from './services/UnsavedChangesGuard.service';
 import Clusters from './services/Clusters';
 import Caches from './services/Caches';
+import {CSV} from './services/CSV';
 
 import AngularStrapTooltip from './services/AngularStrapTooltip.decorator';
 import AngularStrapSelect from './services/AngularStrapSelect.decorator';
@@ -263,6 +264,7 @@ angular.module('ignite-console', [
 .service('IgniteActivitiesUserDialog', IgniteActivitiesUserDialog)
 .service('Clusters', Clusters)
 .service('Caches', Caches)
+.service(CSV.name, CSV)
 // Controllers.
 .controller(...resetPassword)
 .controller(...profile)

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8ce43ac/modules/web-console/frontend/app/components/grid-export/component.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/grid-export/component.js b/modules/web-console/frontend/app/components/grid-export/component.js
index 9c239a6..18e41c7 100644
--- a/modules/web-console/frontend/app/components/grid-export/component.js
+++ b/modules/web-console/frontend/app/components/grid-export/component.js
@@ -16,13 +16,18 @@
  */
 
 import template from './template.pug';
+import {CSV} from 'app/services/CSV';
 
 export default {
     template,
     controller: class {
-        static $inject = ['$scope', 'uiGridGroupingConstants', 'uiGridExporterService', 'uiGridExporterConstants'];
+        static $inject = ['$scope', 'uiGridGroupingConstants', 'uiGridExporterService', 'uiGridExporterConstants',
CSV.name];
 
-        constructor($scope, uiGridGroupingConstants, uiGridExporterService, uiGridExporterConstants)
{
+        /**
+         * @param {CSV} CSV
+         */
+        constructor($scope, uiGridGroupingConstants, uiGridExporterService, uiGridExporterConstants,
CSV) {
+            this.CSV = CSV;
             Object.assign(this, { uiGridGroupingConstants, uiGridExporterService, uiGridExporterConstants
});
         }
 
@@ -42,7 +47,7 @@ export default {
                 data.push(values);
             });
 
-            const csvContent = this.uiGridExporterService.formatAsCsv(columnHeaders, data,
this.gridApi.grid.options.exporterCsvColumnSeparator);
+            const csvContent = this.uiGridExporterService.formatAsCsv(columnHeaders, data,
this.CSV.getSeparator());
             this.uiGridExporterService.downloadFile(this.gridApi.grid.options.exporterCsvFilename,
csvContent, this.gridApi.grid.options.exporterOlderExcelCompatibility);
         }
     },

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8ce43ac/modules/web-console/frontend/app/components/page-queries/controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/page-queries/controller.js b/modules/web-console/frontend/app/components/page-queries/controller.js
index bd03b22..a871a0d 100644
--- a/modules/web-console/frontend/app/components/page-queries/controller.js
+++ b/modules/web-console/frontend/app/components/page-queries/controller.js
@@ -25,6 +25,8 @@ import { fromPromise } from 'rxjs/observable/fromPromise';
 import { timer } from 'rxjs/observable/timer';
 import { defer } from 'rxjs/observable/defer';
 
+import {CSV} from 'app/services/CSV';
+
 import paragraphRateTemplateUrl from 'views/sql/paragraph-rate.tpl.pug';
 import cacheMetadataTemplateUrl from 'views/sql/cache-metadata.tpl.pug';
 import chartSettingsTemplateUrl from 'views/sql/chart-settings.tpl.pug';
@@ -246,11 +248,15 @@ class Paragraph {
 
 // Controller for SQL notebook screen.
 export default class {
-    static $inject = ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval', '$animate',
'$location', '$anchorScroll', '$state', '$filter', '$modal', '$popover', 'IgniteLoading',
'IgniteLegacyUtils', 'IgniteMessages', 'IgniteConfirm', 'AgentManager', 'IgniteChartColors',
'IgniteNotebook', 'IgniteNodes', 'uiGridExporterConstants', 'IgniteVersion', 'IgniteActivitiesData',
'JavaTypes', 'IgniteCopyToClipboard'];
+    static $inject = ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval', '$animate',
'$location', '$anchorScroll', '$state', '$filter', '$modal', '$popover', 'IgniteLoading',
'IgniteLegacyUtils', 'IgniteMessages', 'IgniteConfirm', 'AgentManager', 'IgniteChartColors',
'IgniteNotebook', 'IgniteNodes', 'uiGridExporterConstants', 'IgniteVersion', 'IgniteActivitiesData',
'JavaTypes', 'IgniteCopyToClipboard', CSV.name];
 
-    constructor($root, $scope, $http, $q, $timeout, $interval, $animate, $location, $anchorScroll,
$state, $filter, $modal, $popover, Loading, LegacyUtils, Messages, Confirm, agentMgr, IgniteChartColors,
Notebook, Nodes, uiGridExporterConstants, Version, ActivitiesData, JavaTypes, IgniteCopyToClipboard)
{
+    /**
+     * @param {CSV} CSV
+     */
+    constructor($root, $scope, $http, $q, $timeout, $interval, $animate, $location, $anchorScroll,
$state, $filter, $modal, $popover, Loading, LegacyUtils, Messages, Confirm, agentMgr, IgniteChartColors,
Notebook, Nodes, uiGridExporterConstants, Version, ActivitiesData, JavaTypes, IgniteCopyToClipboard,
CSV) {
         const $ctrl = this;
 
+        this.CSV = CSV;
         Object.assign(this, { $root, $scope, $http, $q, $timeout, $interval, $animate, $location,
$anchorScroll, $state, $filter, $modal, $popover, Loading, LegacyUtils, Messages, Confirm,
agentMgr, IgniteChartColors, Notebook, Nodes, uiGridExporterConstants, Version, ActivitiesData,
JavaTypes });
 
         // Define template urls.
@@ -1654,6 +1660,7 @@ export default class {
         };
 
         const _export = (fileName, columnDefs, meta, rows, toClipBoard = false) => {
+            const csvSeparator = this.CSV.getSeparator();
             let csvContent = '';
 
             const cols = [];
@@ -1666,7 +1673,7 @@ export default class {
                     excludedCols.push(idx);
             });
 
-            csvContent += cols.join(';') + '\n';
+            csvContent += cols.join(csvSeparator) + '\n';
 
             _.forEach(rows, (row) => {
                 cols.length = 0;
@@ -1689,7 +1696,7 @@ export default class {
                     });
                 }
 
-                csvContent += cols.join(';') + '\n';
+                csvContent += cols.join(csvSeparator) + '\n';
             });
 
             if (toClipBoard)

http://git-wip-us.apache.org/repos/asf/ignite/blob/d8ce43ac/modules/web-console/frontend/app/services/CSV.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/CSV.js b/modules/web-console/frontend/app/services/CSV.js
new file mode 100644
index 0000000..ac87bbf
--- /dev/null
+++ b/modules/web-console/frontend/app/services/CSV.js
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export class CSV {
+    getSeparator() {
+        return (0.5).toLocaleString().includes(',') ? ';' : ',';
+    }
+}


Mime
View raw message