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 2015/07/02 08:55:22 UTC

[05/14] incubator-zeppelin git commit: Zeppelin-web Spring Cleaning

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/navbar/navbar.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/navbar/navbar.controller.js b/zeppelin-web/src/components/navbar/navbar.controller.js
new file mode 100644
index 0000000..0aa24ef
--- /dev/null
+++ b/zeppelin-web/src/components/navbar/navbar.controller.js
@@ -0,0 +1,49 @@
+/* global $:false */
+/*
+ * Licensed 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.
+ */
+
+'use strict';
+
+angular.module('zeppelinWebApp').controller('NavCtrl', function($scope, $rootScope, $routeParams, notebookListDataFactory, websocketMsgSrv) {
+  /** Current list of notes (ids) */
+  
+  var vm = this;
+  vm.notes = notebookListDataFactory;
+  vm.connected = false;
+  vm.websocketMsgSrv = websocketMsgSrv;
+  
+  $('#notebook-list').perfectScrollbar({suppressScrollX: true});
+  
+  $scope.$on('setNoteMenu', function(event, notes) {
+      notebookListDataFactory.setNotes(notes);
+  });
+  
+  $scope.$on('setConnectedStatus', function(event, param) {
+      vm.connected = param;
+  });
+
+  function loadNotes() {
+    websocketMsgSrv.getNotebookList();
+  }
+
+  function isActive(noteId) {
+    return ($routeParams.noteId === noteId);
+  }
+  
+  vm.loadNotes = loadNotes;
+  vm.isActive = isActive;
+  
+  vm.loadNotes();
+  
+});

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/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
new file mode 100644
index 0000000..ebdd1fb
--- /dev/null
+++ b/zeppelin-web/src/components/navbar/navbar.html
@@ -0,0 +1,54 @@
+<!--
+Licensed 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.
+-->
+<div class="navbar navbar-inverse navbar-fixed-top" style="display: none;" role="navigation" ng-class="{'displayNavBar': !asIframe}">
+  <div class="container">
+    <div class="navbar-header">
+      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
+        <span class="icon-bar"></span>
+        <span class="icon-bar"></span>
+        <span class="icon-bar"></span>
+      </button>
+      <a class="navbar-brand" href="#/">
+        <img style="margin-top: -7px;s" src="assets/images/zepLogoW.png" width="50" alt="I'm zeppelin"> Zeppelin
+      </a>
+    </div>
+
+    <div class="collapse navbar-collapse" ng-controller="NavCtrl as navbar">
+      <ul class="nav navbar-nav">
+        <li class="dropdown">
+          <a href="#" class="dropdown-toggle">Notebook <span class="caret"></span></a>
+          <ul class="dropdown-menu" role="menu">
+            <li><a href="javascript:void(0);" ng-click="navbar.websocketMsgSrv.createNotebook()"><i class="fa fa-plus"></i> Create new note</a></li>
+            <li class="divider"></li>
+            <div id="notebook-list" class="scrollbar-container">
+              <li ng-repeat="note in navbar.notes.list track by $index" ng-class="{'active' : navbar.isActive(note.id)}">
+                <a href="#/notebook/{{note.id}}">{{note.name || 'Note ' + note.id}} </a>
+              </li>
+            </div>
+          </ul>
+        </li>
+        <li>
+          <a href="#/interpreter">Interpreter</a>
+        </li>
+      </ul>
+      <ul class="nav navbar-nav navbar-right" style="margin-top:10px; margin-right:5px;">
+        <li class="server-status">
+          <i class="fa fa-circle" ng-class="{'server-connected':navbar.connected, 'server-disconnected':!navbar.connected}"></i>
+          <span ng-show="navbar.connected">Connected</span>
+          <span ng-show="!navbar.connected">Disconnected</span>
+        </li>
+      </ul>
+    </div>
+  </div>
+</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/ngdelete/ngdelete.directive.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/ngdelete/ngdelete.directive.js b/zeppelin-web/src/components/ngdelete/ngdelete.directive.js
new file mode 100644
index 0000000..1ddf1eb
--- /dev/null
+++ b/zeppelin-web/src/components/ngdelete/ngdelete.directive.js
@@ -0,0 +1,28 @@
+/*
+ * Licensed 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.
+ */
+
+'use strict';
+
+angular.module('zeppelinWebApp').directive('ngDelete', function() {
+  return function(scope, element, attrs) {
+    element.bind('keydown keyup', function(event) {
+      if (event.which === 27 || event.which === 46) {
+        scope.$apply(function() {
+          scope.$eval(attrs.ngEnter);
+        });
+        event.preventDefault();
+      }
+    });
+  };
+});

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/ngenter/ngenter.directive.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/ngenter/ngenter.directive.js b/zeppelin-web/src/components/ngenter/ngenter.directive.js
new file mode 100644
index 0000000..f284c69
--- /dev/null
+++ b/zeppelin-web/src/components/ngenter/ngenter.directive.js
@@ -0,0 +1,27 @@
+/*
+ * Licensed 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.
+ */
+'use strict';
+
+angular.module('zeppelinWebApp').directive('ngEnter', function() {
+  return function(scope, element, attrs) {
+    element.bind('keydown keypress', function(event) {
+      if (event.which === 13) {
+        scope.$apply(function() {
+          scope.$eval(attrs.ngEnter);
+        });
+        event.preventDefault();
+      }
+    });
+  };
+});

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js b/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js
new file mode 100644
index 0000000..ae48999
--- /dev/null
+++ b/zeppelin-web/src/components/notebookListDataFactory/notebookList.datafactory.js
@@ -0,0 +1,26 @@
+/*
+ * Licensed 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.
+ */
+'use strict';
+
+angular.module('zeppelinWebApp').factory('notebookListDataFactory', function() {
+  var notes = {};
+
+  notes.list = [];
+
+  notes.setNotes = function(notesList) {
+    notes.list = angular.copy(notesList);
+  };
+
+  return notes;
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe-popup.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe-popup.html b/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe-popup.html
new file mode 100644
index 0000000..f537aee
--- /dev/null
+++ b/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe-popup.html
@@ -0,0 +1,21 @@
+<div class="popover {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
+<!--
+Licensed 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.
+-->
+  <div class="arrow"></div>
+
+  <div class="popover-inner">
+    <h3 class="popover-title" ng-bind="title" ng-show="title"></h3>
+    <div class="popover-content" bind-html-unsafe="content"></div>
+  </div>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js b/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js
new file mode 100644
index 0000000..3e405dc
--- /dev/null
+++ b/zeppelin-web/src/components/popover-html-unsafe/popover-html-unsafe.directive.js
@@ -0,0 +1,28 @@
+/*
+ * Licensed 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.
+ */
+'use strict';
+
+angular.module('zeppelinWebApp')
+  .directive('popoverHtmlUnsafePopup', function() {
+    return {
+      restrict: 'EA',
+      replace: true,
+      scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
+      templateUrl: 'components/popover-html-unsafe/popover-html-unsafe-popup.html'
+    };
+  })
+
+  .directive('popoverHtmlUnsafe', ['$tooltip', function($tooltip) {
+    return $tooltip('popoverHtmlUnsafe', 'popover', 'click');
+  }]);

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/resizable/resizable.directive.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/resizable/resizable.directive.js b/zeppelin-web/src/components/resizable/resizable.directive.js
new file mode 100644
index 0000000..fe46a24
--- /dev/null
+++ b/zeppelin-web/src/components/resizable/resizable.directive.js
@@ -0,0 +1,41 @@
+/*
+ * Licensed 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.
+ */
+'use strict';
+
+angular.module('zeppelinWebApp').directive('resizable', function () {
+    var resizableConfig = {
+        autoHide: true,
+        handles: 'se',
+        helper: 'resizable-helper',
+        minHeight:100,
+        grid: [10000, 10]  // allow only vertical
+    };
+
+    return {
+        restrict: 'A',
+        scope: {
+            callback: '&onResize'
+        },
+        link: function postLink(scope, elem, attrs) {
+            attrs.$observe('allowresize', function(isAllowed) {
+                if (isAllowed === 'true') {
+                    elem.resizable(resizableConfig);
+                    elem.on('resizestop', function () {
+                        if (scope.callback) { scope.callback(); }
+                    });
+                }
+            });
+        }
+    };
+});

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
new file mode 100644
index 0000000..2c01210
--- /dev/null
+++ b/zeppelin-web/src/components/websocketEvents/websocketEvents.factory.js
@@ -0,0 +1,66 @@
+/*
+ * Licensed 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.
+ */
+'use strict';
+
+angular.module('zeppelinWebApp').factory('websocketEvents', function($rootScope, $websocket, baseUrlSrv) {
+  var websocketCalls = {};
+  
+  websocketCalls.ws = $websocket(baseUrlSrv.getWebsocketProtocol() + '://' + location.hostname + ':' + baseUrlSrv.getPort());
+  
+  websocketCalls.ws.onOpen(function() {
+    console.log('Websocket created');
+    $rootScope.$broadcast('setConnectedStatus', true);
+  });
+  
+  
+  websocketCalls.sendNewEvent = function(data) {
+    console.log('Send >> %o, %o', data.op, data);
+    websocketCalls.ws.send(JSON.stringify(data));
+  };
+
+  websocketCalls.ws.onMessage(function(event) {
+    var payload;
+    if (event.data) {
+      payload = angular.fromJson(event.data);
+    }
+    console.log('Receive << %o, %o', payload.op, payload);
+    var op = payload.op;
+    var data = payload.data;
+    if (op === 'NOTE') {
+      $rootScope.$broadcast('setNoteContent', data.note);
+    } else if (op === 'NOTES_INFO') {
+      $rootScope.$broadcast('setNoteMenu', data.notes);
+    } else if (op === 'PARAGRAPH') {
+      $rootScope.$broadcast('updateParagraph', data);
+    } else if (op === 'PROGRESS') {
+      $rootScope.$broadcast('updateProgress', data);
+    } else if (op === 'COMPLETION_LIST') {
+      $rootScope.$broadcast('completionList', data);
+    } else if (op === 'ANGULAR_OBJECT_UPDATE') {
+      $rootScope.$broadcast('angularObjectUpdate', data);
+    }
+  });
+
+  websocketCalls.ws.onError(function(event) {
+    console.log('error message: ', event);
+    $rootScope.$broadcast('setConnectedStatus', false);
+  });
+
+  websocketCalls.ws.onClose(function(event) {
+    console.log('close message: ', event);
+    $rootScope.$broadcast('setConnectedStatus', false);
+  });
+
+  return websocketCalls;
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
new file mode 100644
index 0000000..2c4f132
--- /dev/null
+++ b/zeppelin-web/src/components/websocketEvents/websocketMsg.service.js
@@ -0,0 +1,107 @@
+/*
+ * Licensed 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.
+ */
+'use strict';
+
+angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope, websocketEvents) {
+
+  return {
+
+    createNotebook: function() {
+      websocketEvents.sendNewEvent({op: 'NEW_NOTE'});
+    },
+
+    deleteNotebook: function(noteId) {
+      websocketEvents.sendNewEvent({op: 'DEL_NOTE', data: {id: noteId}});
+    },
+
+    getNotebookList: function() {
+      websocketEvents.sendNewEvent({op: 'LIST_NOTES'});
+    },
+
+    getNotebook: function(noteId) {
+      websocketEvents.sendNewEvent({op: 'GET_NOTE', data: {id: noteId}});
+    },
+
+    updateNotebook: function(noteId, noteName, noteConfig) {
+      websocketEvents.sendNewEvent({op: 'NOTE_UPDATE', data: {id: noteId, name: noteName, config : noteConfig}});
+    },
+
+    moveParagraph: function(paragraphId, newIndex) {
+      websocketEvents.sendNewEvent({ op: 'MOVE_PARAGRAPH', data : {id: paragraphId, index: newIndex}});
+    },
+
+    insertParagraph: function(newIndex) {
+      websocketEvents.sendNewEvent({ op: 'INSERT_PARAGRAPH', data : {index: newIndex}});
+    },
+
+    updateAngularObject: function(noteId, name, value, interpreterGroupId) {
+      websocketEvents.sendNewEvent({
+        op: 'ANGULAR_OBJECT_UPDATED',
+        data: {
+          noteId: noteId,
+          name: name,
+          value: value,
+          interpreterGroupId: interpreterGroupId
+        }
+      });
+    },
+
+    cancelParagraphRun: function(paragraphId) {
+      websocketEvents.sendNewEvent({op: 'CANCEL_PARAGRAPH', data: {id: paragraphId}});
+    },
+
+    runParagraph: function(paragraphId, paragraphTitle, paragraphData, paragraphConfig, paragraphParams) {
+      websocketEvents.sendNewEvent({
+        op: 'RUN_PARAGRAPH',
+        data: {
+          id: paragraphId,
+          title: paragraphTitle,
+          paragraph: paragraphData,
+          config: paragraphConfig,
+          params: paragraphParams
+        }
+      });
+    },
+
+    removeParagraph: function(paragraphId) {
+      websocketEvents.sendNewEvent({op: 'PARAGRAPH_REMOVE', data: {id: paragraphId}});
+    },
+
+    completion: function(paragraphId, buf, cursor) {
+      websocketEvents.sendNewEvent({
+        op : 'COMPLETION',
+        data : {
+          id : paragraphId,
+          buf : buf,
+          cursor : cursor
+        }
+      });
+    },
+
+    commitParagraph: function(paragraphId, paragraphTitle, paragraphData, paragraphConfig, paragraphParams) {
+      websocketEvents.sendNewEvent({
+        op: 'COMMIT_PARAGRAPH',
+        data: {
+          id: paragraphId,
+          title : paragraphTitle,
+          paragraph: paragraphData,
+          config: paragraphConfig,
+          params: paragraphParams
+        }
+      });
+    }
+
+  };
+
+});

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/favicon.ico
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/favicon.ico b/zeppelin-web/src/favicon.ico
new file mode 100644
index 0000000..7e5049a
Binary files /dev/null and b/zeppelin-web/src/favicon.ico differ

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/fonts/FontAwesome.otf
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/fonts/FontAwesome.otf b/zeppelin-web/src/fonts/FontAwesome.otf
new file mode 100644
index 0000000..81c9ad9
Binary files /dev/null and b/zeppelin-web/src/fonts/FontAwesome.otf differ

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/8c7424a1/zeppelin-web/src/fonts/Simple-Line-Icons.eot
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/fonts/Simple-Line-Icons.eot b/zeppelin-web/src/fonts/Simple-Line-Icons.eot
new file mode 100644
index 0000000..d258f62
Binary files /dev/null and b/zeppelin-web/src/fonts/Simple-Line-Icons.eot differ