You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/07/24 15:46:21 UTC

[10/16] incubator-ignite git commit: #ignite-843 Backport sql from ignite-1121

#ignite-843 Backport sql from ignite-1121


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

Branch: refs/heads/ignite-1121
Commit: 07d9499941d78856397c75ebce28fbb7a48935f4
Parents: 698d779
Author: Andrey <an...@gridgain.com>
Authored: Thu Jul 23 18:14:56 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Thu Jul 23 18:14:56 2015 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/models/sql.json     |  5 ++
 .../src/main/js/controllers/sql-controller.js   | 84 ++++++++++++++++++++
 .../src/main/js/views/sql/sql.jade              | 84 ++++++++++++++++++++
 .../src/main/js/views/templates/tab.jade        | 26 ++++++
 4 files changed, 199 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/07d94999/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
new file mode 100644
index 0000000..bcb03e0
--- /dev/null
+++ b/modules/web-control-center/src/main/js/controllers/models/sql.json
@@ -0,0 +1,5 @@
+{
+  "screenTip": [
+    "Select cache and execute SQL queries."
+  ]
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/07d94999/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
new file mode 100644
index 0000000..12772c6
--- /dev/null
+++ b/modules/web-control-center/src/main/js/controllers/sql-controller.js
@@ -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.
+ */
+
+var demoResults = [
+    {
+        id: 256,
+        firstName: 'Ivan',
+        lastName: 'Ivanov'
+    },
+    {
+        id: 384,
+        firstName: 'Sergey',
+        lastName: 'Petrov'
+    },
+    {
+        id: 923,
+        firstName: 'Andrey',
+        lastName: 'Sidorov'
+    }
+];
+
+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'},
+        {value: 'LOCAL', label: 'LOCAL'}
+    ];
+
+    $http.get('/models/sql.json')
+        .success(function (data) {
+            $scope.screenTip = data.screenTip;
+        })
+        .error(function (errMsg) {
+            $common.showError(errMsg);
+        });
+
+    $scope.caches = demoCaches;
+}]);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/07d94999/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:&nbsp;
+                        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:&nbsp;
+                                                b {{#{tab}.rows.length}}&nbsp;&nbsp;&nbsp;
+                                                | Page #:&nbsp;
+                                                b {{#{tab}.page}}&nbsp;&nbsp;&nbsp;
+                                                | Total results:&nbsp;
+                                                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/07d94999/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
new file mode 100644
index 0000000..518c870
--- /dev/null
+++ b/modules/web-control-center/src/main/js/views/templates/tab.jade
@@ -0,0 +1,26 @@
+//-
+    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)