Repository: incubator-ignite Updated Branches: refs/heads/ignite-1121 1203354c6 -> af712e577
#ignite-1121 Sql fix Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7977aa5c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7977aa5c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7977aa5c Branch: refs/heads/ignite-1121 Commit: 7977aa5c2956660fdd031d5125eb6535fba94ad7 Parents: a45a700 Author: Andrey <anovi...@gridgain.com> Authored: Thu Jul 23 16:11:20 2015 +0700 Committer: Andrey <anovi...@gridgain.com> Committed: Thu Jul 23 17:55:31 2015 +0700 ---------------------------------------------------------------------- .../src/main/js/controllers/models/sql.json | 2 +- .../src/main/js/controllers/sql-controller.js | 32 +++++++- .../src/main/js/public/stylesheets/style.less | 21 +++++ .../src/main/js/routes/public.js | 4 +- .../src/main/js/views/sql/sql.jade | 84 ++++++++++++++++++++ .../src/main/js/views/templates/tab.jade | 27 ++++++- 6 files changed, 161 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7977aa5c/modules/web-control-center/src/main/js/controllers/models/sql.json ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/controllers/models/sql.json b/modules/web-control-center/src/main/js/controllers/models/sql.json index b00e5dd..bcb03e0 100644 --- a/modules/web-control-center/src/main/js/controllers/models/sql.json +++ b/modules/web-control-center/src/main/js/controllers/models/sql.json @@ -1,5 +1,5 @@ { "screenTip": [ - "Execute SQL queries." + "Select cache and execute SQL queries." ] } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7977aa5c/modules/web-control-center/src/main/js/controllers/sql-controller.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/controllers/sql-controller.js b/modules/web-control-center/src/main/js/controllers/sql-controller.js index 2562117..12772c6 100644 --- a/modules/web-control-center/src/main/js/controllers/sql-controller.js +++ b/modules/web-control-center/src/main/js/controllers/sql-controller.js @@ -35,9 +35,37 @@ var demoResults = [ var demoCaches = [{_id: '1', name: 'Users', mode: 'LOCAL'}, {_id: '2', name: 'Organizations', mode: 'REPLICATED'}, {_id: '3', name: 'Cities', mode: 'PARTITIONED'}]; + + controlCenterModule.controller('sqlController', ['$scope', '$http', '$common', function ($scope, $http, $common) { $scope.joinTip = $common.joinTip; + $scope.pageSizes = [50, 100, 200, 400, 800, 1000]; + + $scope.tabs = [ + { + query: "SELECT u.id, u.firstName, u.lastName FROM User u WHERE u.name LIKE 'aaaa'", + cols: Object.keys(demoResults[0]), + page: 1, + hasMore: true, + total: 0, + rows: demoResults + }, + {query: "SELECT * FROM Organization"} + ]; + + $scope.addTab = function() { + console.log('addTab'); + + $scope.tabs.push({query: "SELECT "}); + }; + + $scope.removeTab = function(idx) { + console.log('removeTab'); + + $scope.tabs.splice(idx, 1); + }; + $scope.modes = [ {value: 'PARTITIONED', label: 'PARTITIONED'}, {value: 'REPLICATED', label: 'REPLICATED'}, @@ -52,9 +80,5 @@ controlCenterModule.controller('sqlController', ['$scope', '$http', '$common', f $common.showError(errMsg); }); - $scope.query = "select u.id, u.firstName, u.lastName from User u where u.name like 'aaaa';"; - - $scope.results = demoResults; - $scope.caches = demoCaches; }]); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7977aa5c/modules/web-control-center/src/main/js/public/stylesheets/style.less ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/public/stylesheets/style.less b/modules/web-control-center/src/main/js/public/stylesheets/style.less index 3d0ede7..c3d58c2 100644 --- a/modules/web-control-center/src/main/js/public/stylesheets/style.less +++ b/modules/web-control-center/src/main/js/public/stylesheets/style.less @@ -814,6 +814,27 @@ button .caret, .btn .caret { } } +.theme-line table.sql-results { + [class*="col-"] { + padding-left: 0 !important; + padding-right: 0 !important; + } + + td { + padding: 3px 6px; + } + + > thead > tr > td { + padding: 3px 0; + } + + thead > tr > th { + padding: 3px 6px; + + line-height: @input-height; + } +} + .panel-title a { font-size: 14px; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7977aa5c/modules/web-control-center/src/main/js/routes/public.js ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/routes/public.js b/modules/web-control-center/src/main/js/routes/public.js index 290ba90..b3cb983 100644 --- a/modules/web-control-center/src/main/js/routes/public.js +++ b/modules/web-control-center/src/main/js/routes/public.js @@ -24,7 +24,7 @@ router.get('/select', function (req, res) { res.render('templates/select', {}); }); -// GET tabs template. +// GET dynamic tabs template. router.get('/tab', function (req, res) { res.render('templates/tab', {}); }); @@ -34,7 +34,7 @@ router.get('/confirm', function (req, res) { res.render('templates/confirm', {}); }); -// GET save as dialog. +// GET copy dialog. router.get('/copy', function (req, res) { res.render('templates/copy', {}); }); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7977aa5c/modules/web-control-center/src/main/js/views/sql/sql.jade ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/views/sql/sql.jade b/modules/web-control-center/src/main/js/views/sql/sql.jade new file mode 100644 index 0000000..6957be1 --- /dev/null +++ b/modules/web-control-center/src/main/js/views/sql/sql.jade @@ -0,0 +1,84 @@ +//- + 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. +extends ../templates/layout + +append scripts + script(src='/sql-controller.js') + + script(src='//cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/theme-chrome.js') + script(src='//cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/mode-sql.js') + script(src='//cdnjs.cloudflare.com/ajax/libs/ace/1.2.0/ext-language_tools.js') + +block container + .row + .col-sm-12 + .docs-content + .docs-header + h1 Connect to Ignite and Execute SQL Queries + hr + .docs-body(ng-controller='sqlController') + - var tab = 'tabs[tabs.activeIdx]' + + .block-callout-parent.block-callout-border.margin-bottom-dflt + .block-callout + p(ng-bind-html='joinTip(screenTip)') + .tabs-below(bs-tabs bs-active-pane='tabs.activeIdx' data-template='/tab') + div(ng-repeat='tab in tabs' title='Query' bs-pane) + .row + .col-sm-9(style='border-right: 1px solid #eee') + div(style='height: 200px' ui-ace='{ theme: "chrome", mode: "sql",' + + 'require: ["ace/ext/language_tools"],' + + 'rendererOptions: {showPrintMargin: false, highlightGutterLine: false, fontSize: 14},' + + 'advanced: {enableSnippets: false, enableBasicAutocompletion: true, enableLiveAutocompletion: true}}' ng-model='#{tab}.query') + .col-sm-3 + .links(ng-hide='caches.length == 0' style='margin-top: 0.65em') + lable.labelHeader Caches: + table(st-table='caches') + tbody + tr(ng-repeat='row in caches track by row._id') + td.col-sm-6(ng-class='{active: row._id == #{tab}.selectedItem._id}') + a(ng-click='#{tab}.selectedItem = row') {{$index + 1}}) {{row.name}}, {{row.mode | displayValue:modes:'Cache mode not set'}} + hr(style='margin: 0') + .settings-row + label Page Size: + button.btn.btn-default.base-control(ng-init='pageSize = pageSizes[0]' ng-model='pageSize' bs-options='item for item in pageSizes' bs-select) + .settings-row + button.btn.btn-primary(ng-click='') Explain + button.btn.btn-primary(ng-click='') Execute + button.btn.btn-primary(ng-click='' disabled) Scan + + div(ng-show='#{tab}.rows.length > 0' style='margin-top: 0.65em') + hr + div + table.table.table-striped.col-sm-12.sql-results(st-table='rows' st-safe-src='#{tab}.rows') + thead + tr(style='border-size: 0') + td(colspan='{{#{tab}.cols.length}}') + .col-sm-8 + lable Page results: + b {{#{tab}.rows.length}} + | Page #: + b {{#{tab}.page}} + | Total results: + b {{#{tab}.rows.length + #{tab}.total}} + .col-sm-4 + button.btn.btn-primary.fieldButton(ng-click='') Next page + .input-tip + input.form-control(type='text' st-search='' placeholder='Filter...') + + tr + th(ng-repeat='column in #{tab}.cols' st-sort='{{column}}') {{column}} + tbody + tr(ng-repeat='row in rows') + td(ng-repeat="column in #{tab}.cols") {{row[column]}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7977aa5c/modules/web-control-center/src/main/js/views/templates/tab.jade ---------------------------------------------------------------------- diff --git a/modules/web-control-center/src/main/js/views/templates/tab.jade b/modules/web-control-center/src/main/js/views/templates/tab.jade index ce62bd6..518c870 100644 --- a/modules/web-control-center/src/main/js/views/templates/tab.jade +++ b/modules/web-control-center/src/main/js/views/templates/tab.jade @@ -1,3 +1,26 @@ -// - Created by nva on 23/07/15. +//- + 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. + +ul.nav(ng-class='$navClass', role='tablist') + li(role='presentation', ng-repeat='$pane in $panes track by $index', ng-class="[ $isActive($pane, $index) ? $activeClass : '', $pane.disabled ? 'disabled' : '' ]") + a(ng-if='$index == 0' role='tab', data-toggle='tab', ng-click='!$pane.disabled && $setActive($pane.name || $index)', data-index='{{ $index }}', aria-controls='$pane.title') {{$pane.title}} + i.fa.fa-remove(ng-click='removeTab($index)' ng-if='$index > 0' style='margin-left: 5px') + a(ng-if='$index > 0' role='tab', data-toggle='tab', ng-click='!$pane.disabled && $setActive($pane.name || $index)', data-index='{{ $index }}', aria-controls='$pane.title') {{$pane.title}}: {{$index}} + i.fa.fa-remove(ng-click='removeTab($index)' style='margin-left: 5px') + li.pull-right(bs-tooltip data-title='Add new query') + a(role='tab', data-toggle='tab' ng-click='addTab()') + i.fa.fa-plus +.tab-content(ng-transclude)