You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by mo...@apache.org on 2017/04/22 00:26:30 UTC

zeppelin git commit: [ZEPPELIN-2374] sorting notes tree

Repository: zeppelin
Updated Branches:
  refs/heads/master 09e8f7f0c -> 5124e62a1


[ZEPPELIN-2374] sorting notes tree

### What is this PR for?
Updated angular version to 1.5.7 (added comparator to orderBy). Sorting notes tree, order:
1. folders (alphabetically)
2. notes (alphabetically)
3. Trash

### What type of PR is it?
Improvement

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-2374

### How should this be tested?
see screenshots

### Screenshots (if appropriate)
home page
before   -   after
![tree_1](https://cloud.githubusercontent.com/assets/25951039/24800433/93a5f0f4-1bb9-11e7-9d96-8f1eab461bcc.png)

navbar
before   -   after
![1_2](https://cloud.githubusercontent.com/assets/25951039/24800610/30b5098e-1bba-11e7-8060-f7c68fff77c1.png)

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Tinkoff DWH <ti...@gmail.com>

Closes #2234 from tinkoff-dwh/ZEPPELIN-2374 and squashes the following commits:

6722904 [Tinkoff DWH] Merge remote-tracking branch 'upstream/master' into ZEPPELIN-2374
7b439e5 [Tinkoff DWH] ZEPPELIN-2374 eslint fix
634524e [Tinkoff DWH] Merge remote-tracking branch 'origin/master' into ZEPPELIN-2374
c6327ce [Tinkoff DWH] Merge remote-tracking branch 'upstream/master' into ZEPPELIN-2374
f511cee [Tinkoff DWH] [ZEPPELIN-2374] update angular to 1.5.7. sorting notes tree


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

Branch: refs/heads/master
Commit: 5124e62a176580b9b721ebeb25274f37a80e638c
Parents: 09e8f7f
Author: Tinkoff DWH <ti...@gmail.com>
Authored: Fri Apr 21 08:04:13 2017 +0500
Committer: Lee moon soo <mo...@apache.org>
Committed: Fri Apr 21 17:26:29 2017 -0700

----------------------------------------------------------------------
 zeppelin-web/bower.json                         | 16 ++++++------
 zeppelin-web/src/app/home/home.controller.js    |  4 +++
 zeppelin-web/src/app/home/home.html             |  6 ++---
 .../src/app/home/notebook-template.html         |  4 +--
 zeppelin-web/src/app/home/notebook.html         |  4 +--
 .../arrayOrderingSrv/arrayOrdering.service.js   | 26 ++++++++++++++++++++
 .../components/navbar/navbar-noteList-elem.html |  2 +-
 zeppelin-web/src/components/navbar/navbar.html  | 18 +++++++-------
 8 files changed, 55 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5124e62a/zeppelin-web/bower.json
----------------------------------------------------------------------
diff --git a/zeppelin-web/bower.json b/zeppelin-web/bower.json
index 6547e83..690cd15 100644
--- a/zeppelin-web/bower.json
+++ b/zeppelin-web/bower.json
@@ -2,16 +2,16 @@
   "name": "zeppelin-web",
   "version": "0.0.0",
   "dependencies": {
-    "angular": "1.5.0",
+    "angular": "1.5.7",
     "json3": "~3.3.1",
     "es5-shim": "~3.1.0",
     "bootstrap": "~3.2.0",
-    "angular-cookies": "1.5.0",
-    "angular-sanitize": "1.5.0",
-    "angular-animate": "1.5.0",
-    "angular-touch": "1.5.0",
-    "angular-route": "1.5.0",
-    "angular-resource": "1.5.0",
+    "angular-cookies": "1.5.7",
+    "angular-sanitize": "1.5.7",
+    "angular-animate": "1.5.7",
+    "angular-touch": "1.5.7",
+    "angular-route": "1.5.7",
+    "angular-resource": "1.5.7",
     "angular-bootstrap": "~2.5.0",
     "angular-websocket": "~1.0.13",
     "ace-builds": "1.2.6",
@@ -38,7 +38,7 @@
     "ngclipboard": "^1.1.1"
   },
   "devDependencies": {
-    "angular-mocks": "1.5.0"
+    "angular-mocks": "1.5.7"
   },
   "appPath": "src",
   "overrides": {

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5124e62a/zeppelin-web/src/app/home/home.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/home/home.controller.js b/zeppelin-web/src/app/home/home.controller.js
index e8fccb9..83f9681 100644
--- a/zeppelin-web/src/app/home/home.controller.js
+++ b/zeppelin-web/src/app/home/home.controller.js
@@ -143,4 +143,8 @@ function HomeCtrl ($scope, noteListDataFactory, websocketMsgSrv, $rootScope, arr
   $scope.getNoteName = function (note) {
     return arrayOrderingSrv.getNoteName(note)
   }
+
+  $scope.noteComparator = function (note1, note2) {
+    return arrayOrderingSrv.noteComparator(note1, note2)
+  }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5124e62a/zeppelin-web/src/app/home/home.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/home/home.html b/zeppelin-web/src/app/home/home.html
index adfa1a3..7c1154f 100644
--- a/zeppelin-web/src/app/home/home.html
+++ b/zeppelin-web/src/app/home/home.html
@@ -40,16 +40,16 @@ limitations under the License.
               <i style="font-size: 15px;" class="icon-notebook"></i> Create new note</a></h5>
             <ul id="notebook-names">
               <li class="filter-names" ng-include="'components/filterNoteNames/filter-note-names.html'"></li>
-              <li ng-repeat="note in home.notes.list | filter:query.q | orderBy:home.arrayOrderingSrv.noteListOrdering track by $index">
+              <li ng-repeat="note in home.notes.list | filter:query.q | orderBy:node:false:home.arrayOrderingSrv.noteComparator track by $index">
                 <i style="font-size: 10px;" class="icon-doc"></i>
                 <a style="text-decoration: none;" href="#/notebook/{{note.id}}">{{noteName(note)}}</a>
               </li>
               <div ng-if="!query.q || query.q === ''">
-                <li ng-repeat="node in home.notes.root.children | orderBy:home.arrayOrderingSrv.noteListOrdering track by $index"
+                <li ng-repeat="node in home.notes.root.children | orderBy:node:false:home.arrayOrderingSrv.noteComparator track by $index"
                     ng-include src="'app/home/notebook-template.html'" ng-class="note_folder_renderer"></li>
               </div>
               <div ng-if="query.q">
-                <li ng-repeat="node in home.notes.flatList| filter:query.q | orderBy:home.arrayOrderingSrv.noteListOrdering track by $index"
+                <li ng-repeat="node in home.notes.flatList| filter:query.q | orderBy:home.arrayOrderingSrv.noteFlatListOrdering track by $index"
                     ng-include src="'app/home/notebook-template.html'" ng-class="note_folder_renderer"></li>
              </div>
             </ul>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5124e62a/zeppelin-web/src/app/home/notebook-template.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/home/notebook-template.html b/zeppelin-web/src/app/home/notebook-template.html
index 98708f9..cf665bb 100644
--- a/zeppelin-web/src/app/home/notebook-template.html
+++ b/zeppelin-web/src/app/home/notebook-template.html
@@ -92,7 +92,7 @@ limitations under the License.
     </div>
     <div ng-if="!node.hidden">
       <ul style="list-style-type: none; padding-left:15px;">
-        <li ng-repeat="node in node.children" ng-include="'app/home/notebook-template.html'" ng-class="'note_folder_renderer'"></li>
+        <li ng-repeat="node in node.children | orderBy:node:false:noteComparator" ng-include="'app/home/notebook-template.html'" ng-class="'note_folder_renderer'"></li>
       </ul>
     </div>
   </div>
@@ -116,7 +116,7 @@ limitations under the License.
     </div>
     <div ng-if="!node.hidden">
       <ul style="list-style-type: none; padding-left:15px;">
-        <li ng-repeat="node in node.children" ng-include="'app/home/notebook-template.html'" ng-class="'note_folder_renderer'"></li>
+        <li ng-repeat="node in node.children | orderBy:node:false:noteComparator" ng-include="'app/home/notebook-template.html'" ng-class="'note_folder_renderer'"></li>
       </ul>
     </div>
   </div>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5124e62a/zeppelin-web/src/app/home/notebook.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/home/notebook.html b/zeppelin-web/src/app/home/notebook.html
index bd52bf4..76214e9 100644
--- a/zeppelin-web/src/app/home/notebook.html
+++ b/zeppelin-web/src/app/home/notebook.html
@@ -28,11 +28,11 @@ limitations under the License.
        <ul id="notebook-names">
          <li class="filter-names" ng-include="'components/filterNoteNames/filter-note-names.html'"></li>
          <div ng-if="!query.q || query.q === ''">
-           <li ng-repeat="node in home.notes.root.children | orderBy:home.arrayOrderingSrv.noteListOrdering track by $index"
+           <li ng-repeat="node in home.notes.root.children | orderBy:node:false:home.arrayOrderingSrv.noteComparator track by $index"
                ng-include src="'app/home/notebook-template.html'" ng-class="note_folder_renderer"></li>
          </div>
          <div ng-if="query.q">
-           <li ng-repeat="node in home.notes.flatList | filter:query.q | orderBy:home.arrayOrderingSrv.noteListOrdering track by $index"
+           <li ng-repeat="node in home.notes.flatList | filter:query.q | orderBy:home.arrayOrderingSrv.noteFlatListOrdering track by $index"
                ng-include src="'app/home/notebook-template.html'" ng-class="note_folder_renderer"></li>
          </div>
        </ul>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5124e62a/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js b/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js
index 6e2fe33..ead2824 100644
--- a/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js
+++ b/zeppelin-web/src/components/arrayOrderingSrv/arrayOrdering.service.js
@@ -33,4 +33,30 @@ function arrayOrderingSrv (TRASH_FOLDER_ID) {
       return note.name
     }
   }
+
+  this.noteComparator = function (v1, v2) {
+    let note1 = v1.value
+    let note2 = v2.value
+
+    if (note1.id === TRASH_FOLDER_ID) {
+      return 1
+    }
+
+    if (note2.id === TRASH_FOLDER_ID) {
+      return -1
+    }
+
+    if (note1.children === undefined && note2.children !== undefined) {
+      return 1
+    }
+
+    if (note1.children !== undefined && note2.children === undefined) {
+      return -1
+    }
+
+    let noteName1 = arrayOrderingSrv.getNoteName(note1)
+    let noteName2 = arrayOrderingSrv.getNoteName(note2)
+
+    return noteName1.localeCompare(noteName2)
+  }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5124e62a/zeppelin-web/src/components/navbar/navbar-noteList-elem.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/navbar/navbar-noteList-elem.html b/zeppelin-web/src/components/navbar/navbar-noteList-elem.html
index 18de94f..b63efd8 100644
--- a/zeppelin-web/src/components/navbar/navbar-noteList-elem.html
+++ b/zeppelin-web/src/components/navbar/navbar-noteList-elem.html
@@ -33,7 +33,7 @@ limitations under the License.
       </div>
       <div class="expandable" style="color: black;">
         <ul>
-          <li ng-repeat="note in note.children | orderBy:navbar.arrayOrderingSrv.noteListOrdering track by $index"
+          <li ng-repeat="note in note.children | orderBy:node:false:navbar.arrayOrderingSrv.noteComparator track by $index"
               ng-class="{'active' : navbar.isActive(note.id)}"
               ng-include="'components/navbar/navbar-noteList-elem.html'">
           </li>

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/5124e62a/zeppelin-web/src/components/navbar/navbar.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/navbar/navbar.html b/zeppelin-web/src/components/navbar/navbar.html
index 4a1115a..799206b 100644
--- a/zeppelin-web/src/components/navbar/navbar.html
+++ b/zeppelin-web/src/components/navbar/navbar.html
@@ -33,15 +33,15 @@ limitations under the License.
             <div id="notebook-list" class="scrollbar-container" ng-if="isDrawNavbarNoteList">
               <li class="filter-names" ng-include="'components/filterNoteNames/filter-note-names.html'"></li>
               <div ng-if="!query.q || query.q === ''">
-                <li ng-repeat="note in navbar.notes.root.children | orderBy:navbar.arrayOrderingSrv.noteListOrdering track by note.id"
-                    ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'components/navbar/navbar-noteList-elem.html'">
-                </li>
-              </div>
-              <div ng-if="query.q">
-                <li ng-repeat="note in navbar.notes.flatList | filter : query.q | orderBy:navbar.arrayOrderingSrv.noteListOrdering track by note.id"
-                    ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'components/navbar/navbar-noteList-elem.html'">
-                </li>
-              </div>
+              <li ng-repeat="note in navbar.notes.root.children | orderBy:node:false:navbar.arrayOrderingSrv.noteComparator track by note.id"
+                  ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'components/navbar/navbar-noteList-elem.html'">
+              </li>
+            </div>
+            <div ng-if="query.q">
+              <li ng-repeat="note in navbar.notes.flatList | filter : query.q | orderBy:navbar.arrayOrderingSrv.noteFlatListOrdering track by note.id"
+                  ng-class="{'active' : navbar.isActive(note.id)}" ng-include="'components/navbar/navbar-noteList-elem.html'">
+              </li>
+            </div>
             </div>
           </ul>
         </li>