ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject [36/50] [abbrv] ignite git commit: Fixed notebook save.
Date Thu, 08 Sep 2016 04:46:53 GMT
Fixed notebook save.


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

Branch: refs/heads/ignite-3629
Commit: 957d47236e51d3a6e2e81018bc54a2aaa4706ceb
Parents: 31f8d1c
Author: Andrey Novikov <anovikov@apache.org>
Authored: Fri Sep 2 17:11:24 2016 +0700
Committer: Andrey Novikov <anovikov@apache.org>
Committed: Fri Sep 2 17:11:24 2016 +0700

----------------------------------------------------------------------
 .../web-console/backend/services/notebooks.js   |  4 +--
 .../frontend/app/modules/sql/sql.controller.js  | 33 ++++++++++++++------
 modules/web-console/frontend/views/sql/sql.jade | 16 +++++-----
 3 files changed, 34 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/957d4723/modules/web-console/backend/services/notebooks.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/services/notebooks.js b/modules/web-console/backend/services/notebooks.js
index 915279c..609d732 100644
--- a/modules/web-console/backend/services/notebooks.js
+++ b/modules/web-console/backend/services/notebooks.js
@@ -44,8 +44,8 @@ module.exports.factory = (_, mongo, spacesService, errors) => {
      * @returns {Promise.<mongo.ObjectId>} that resolves cache id
      */
     const update = (notebook) => {
-        return mongo.Notebook.update({_id: notebook._id}, notebook, {upsert: true}).exec()
-            .then(() => notebook)
+        return mongo.Notebook.findOneAndUpdate({_id: notebook._id}, notebook, {upsert: true}).exec()
+            .then((doc) => doc)
             .catch((err) => {
                 if (err.code === mongo.errCodes.DUPLICATE_KEY_UPDATE_ERROR || err.code ===
mongo.errCodes.DUPLICATE_KEY_ERROR)
                     throw new errors.DuplicateKeyException('Notebook with name: "' + notebook.name
+ '" already exist.');

http://git-wip-us.apache.org/repos/asf/ignite/blob/957d4723/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 235592b..8b5a1dd 100644
--- a/modules/web-console/frontend/app/modules/sql/sql.controller.js
+++ b/modules/web-console/frontend/app/modules/sql/sql.controller.js
@@ -133,7 +133,11 @@ class Paragraph {
     }
 
     queryExecuted() {
-        return this.queryArgs && this.queryArgs.query && !this.queryArgs.query.startsWith('EXPLAIN
');
+        return !_.isEmpty(this.meta);
+    }
+
+    scanExplain() {
+        return this.queryExecuted() && this.queryArgs.type !== 'QUERY';
     }
 
     timeLineSupported() {
@@ -1191,7 +1195,7 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
 
             _showLoading(paragraph, false);
 
-            if (paragraph.result === 'none' || !paragraph.queryExecuted())
+            if (_.isNil(paragraph.result) || paragraph.scanExplain())
                 paragraph.result = 'table';
             else if (paragraph.chart()) {
                 let resetCharts = queryChanged;
@@ -1246,6 +1250,9 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
         };
 
         $scope.execute = (paragraph) => {
+            if (!$scope.actionAvailable(paragraph, true))
+                return;
+
             Notebook.save($scope.notebook)
                 .catch(Messages.showError);
 
@@ -1258,7 +1265,8 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
                     const args = paragraph.queryArgs = {
                         cacheName: paragraph.cacheName,
                         pageSize: paragraph.pageSize,
-                        query: paragraph.query
+                        query: paragraph.query,
+                        type: 'QUERY'
                     };
 
                     return agentMonitor.query(cacheNode(paragraph.cacheName), args.cacheName,
args.query, false, args.pageSize);
@@ -1278,10 +1286,6 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout',
'$interval',
                 .then(() => paragraph.ace.focus());
         };
 
-        $scope.queryExecuted = function(paragraph) {
-            return LegacyUtils.isDefined(paragraph.queryArgs);
-        };
-
         const _cancelRefresh = (paragraph) => {
             if (paragraph.rate && paragraph.rate.stopTime) {
                 delete paragraph.queryArgs;
@@ -1295,6 +1299,9 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
         };
 
         $scope.explain = (paragraph) => {
+            if (!$scope.actionAvailable(paragraph, true))
+                return;
+
             Notebook.save($scope.notebook)
                 .catch(Messages.showError);
 
@@ -1307,7 +1314,8 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
                     const args = paragraph.queryArgs = {
                         cacheName: paragraph.cacheName,
                         pageSize: paragraph.pageSize,
-                        query: 'EXPLAIN ' + paragraph.query
+                        query: 'EXPLAIN ' + paragraph.query,
+                        type: 'EXPLAIN'
                     };
 
                     return agentMonitor.query(cacheNode(paragraph.cacheName), args.cacheName,
args.query, false, args.pageSize);
@@ -1322,6 +1330,9 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
         };
 
         $scope.scan = (paragraph, query = null) => {
+            if (!$scope.actionAvailable(paragraph, false))
+                return;
+
             Notebook.save($scope.notebook)
                 .catch(Messages.showError);
 
@@ -1334,7 +1345,8 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
                     const args = paragraph.queryArgs = {
                         cacheName: paragraph.cacheName,
                         pageSize: paragraph.pageSize,
-                        query
+                        query,
+                        type: 'SCAN'
                     };
 
                     return agentMonitor.query(cacheNode(paragraph.cacheName), args.cacheName,
query, false, args.pageSize);
@@ -1349,6 +1361,9 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
         };
 
         $scope.scanWithFilter = (paragraph) => {
+            if (!$scope.actionAvailable(paragraph, false))
+                return;
+
             ScanFilterInput.open()
                 .then(({filter, caseSensitive}) => {
                     const prefix = caseSensitive ? SCAN_CACHE_WITH_FILTER_CASE_SENSITIVE
: SCAN_CACHE_WITH_FILTER;

http://git-wip-us.apache.org/repos/asf/ignite/blob/957d4723/modules/web-console/frontend/views/sql/sql.jade
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/sql/sql.jade b/modules/web-console/frontend/views/sql/sql.jade
index 570517d..81acdfd 100644
--- a/modules/web-console/frontend/views/sql/sql.jade
+++ b/modules/web-console/frontend/views/sql/sql.jade
@@ -84,11 +84,11 @@ mixin paragraph-rename
 
 mixin query-controls
     .sql-controls
-        a.btn.btn-primary(ng-disabled='!actionAvailable(paragraph, true)' ng-click='actionAvailable(paragraph,
true) && execute(paragraph)' data-placement='bottom' bs-tooltip data-title='{{actionTooltip(paragraph,
"execute", true)}}') Execute
-        a.btn.btn-primary(ng-disabled='!actionAvailable(paragraph, true)' ng-click='actionAvailable(paragraph,
true) && explain(paragraph)' data-placement='bottom' bs-tooltip data-title='{{actionTooltip(paragraph,
"explain", true)}}') Explain
-        .btn-group(ng-disabled='!actionAvailable(paragraph, false)')
-            a.btn.btn-primary.fieldButton(ng-click='actionAvailable(paragraph, false) &&
scan(paragraph)' data-placement='bottom' bs-tooltip data-title='{{actionTooltip(paragraph,
"execute scan", false)}}') Scan
-            a.btn.btn-primary(data-toggle='dropdown' data-container='body' bs-dropdown='[{
text: "Scan with filter", click: "actionAvailable(paragraph, false) && scanWithFilter(paragraph)"
}]' data-placement='bottom-right')
+        a.btn.btn-primary(ng-disabled='!actionAvailable(paragraph, true)' ng-click='execute(paragraph)'
data-placement='bottom' bs-tooltip='' data-title='{{actionTooltip(paragraph, "execute", true)}}')
Execute
+        a.btn.btn-primary(ng-disabled='!actionAvailable(paragraph, true)' ng-click='explain(paragraph)'
data-placement='bottom' bs-tooltip='' data-title='{{actionTooltip(paragraph, "explain", true)}}')
Explain
+        .btn-group(bs-tooltip='' data-title='{{actionTooltip(paragraph, "execute scan", false)}}'
data-placement='bottom')
+            a.btn.btn-primary.fieldButton(ng-disabled='!actionAvailable(paragraph, false)'
ng-click='scan(paragraph)') Scan
+            a.btn.btn-primary(ng-disabled='!actionAvailable(paragraph, false)' data-toggle='dropdown'
data-container='body' bs-dropdown='[{ text: "Scan with filter", click: "actionAvailable(paragraph,
false) && scanWithFilter(paragraph)" }]')
                 span.caret
 
         .pull-right
@@ -115,7 +115,7 @@ mixin table-result
     .grid(ui-grid='paragraph.gridOptions' ui-grid-resize-columns ui-grid-exporter)
 
 mixin chart-result
-    div(ng-show='paragraph.queryExecuted()')
+    div(ng-hide='paragraph.scanExplain()')
         +chart-settings
         .empty(ng-show='paragraph.chartColumns.length > 0 && !paragraph.chartColumnsConfigured()')
Cannot display chart. Please configure axis using #[b Chart settings]
         .empty(ng-show='paragraph.chartColumns.length == 0') Cannot display chart. Result
set must contain Java build-in type columns. Please change query and execute it again.
@@ -124,7 +124,7 @@ mixin chart-result
                 div(ng-repeat='chart in paragraph.charts')
                     nvd3(options='chart.options' data='chart.data' api='chart.api')
             .empty(ng-show='!paragraph.timeLineSupported() && paragraph.chartTimeLineEnabled()')
Pie chart does not support 'TIME_LINE' column for X-axis. Please use another column for X-axis
or switch to another chart.
-    .empty(ng-hide='paragraph.queryExecuted()')
+    .empty(ng-show='paragraph.scanExplain()')
         .row
             .col-xs-4.col-xs-offset-4
                 +result-toolbar
@@ -176,7 +176,7 @@ mixin chart-result
                                         label No caches
                             .col-sm-12
                                 +query-controls
-                            .col-sm-12.sql-result(ng-switch='paragraph.resultType()')
+                            .col-sm-12.sql-result(ng-if='paragraph.queryExecuted()' ng-switch='paragraph.resultType()')
                                 .error(ng-switch-when='error') Error: {{paragraph.errMsg}}
                                 .empty(ng-switch-when='empty') Result set is empty
                                 .table(ng-switch-when='table')


Mime
View raw message