Skip to content

Commit a00adc2

Browse files
committed
Merge pull request #1 from apache/master
Merging from Master
2 parents df324de + bd5be50 commit a00adc2

File tree

12 files changed

+205
-4
lines changed

12 files changed

+205
-4
lines changed

conf/zeppelin-env.sh.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
# export ZEPPELIN_LOG_DIR # Where log files are stored. PWD by default.
2727
# export ZEPPELIN_PID_DIR # The pid files are stored. /tmp by default.
2828
# export ZEPPELIN_NOTEBOOK_DIR # Where notebook saved
29+
# export ZEPPELIN_NOTEBOOK_HOMESCREEN # Id of notebook to be displayed in homescreen. ex) 2A94M5J1Z
30+
# export ZEPPELIN_NOTEBOOK_HOMESCREEN_HIDE # hide homescreen notebook from list when this value set to "true". default "false"
2931
# export ZEPPELIN_NOTEBOOK_S3_BUCKET # Bucket where notebook saved
3032
# export ZEPPELIN_NOTEBOOK_S3_USER # User in bucket where notebook saved. For example bucket/user/notebook/2A94M5J1Z/note.json
3133
# export ZEPPELIN_IDENT_STRING # A string representing this instance of zeppelin. $USER by default.

conf/zeppelin-site.xml.template

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@
3737
<description>path or URI for notebook persist</description>
3838
</property>
3939

40+
<property>
41+
<name>zeppelin.notebook.homescreen</name>
42+
<value></value>
43+
<description>id of notebook to be displayed in homescreen. ex) 2A94M5J1Z Empty value displays default home screen</description>
44+
</property>
45+
46+
<property>
47+
<name>zeppelin.notebook.homescreen.hide</name>
48+
<value>false</value>
49+
<description>hide homescreen notebook from list when this value set to true</description>
50+
</property>
51+
52+
4053
<!-- If used S3 to storage the notebooks, it is necessary the following folder structure bucketname/username/notebook/ -->
4154
<!--
4255
<property>

zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/RemoteScheduler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ public void run() {
289289
running.remove(job);
290290
queue.notify();
291291
}
292+
jobSubmittedRemotely = true;
292293

293294
return;
294295
}

zeppelin-server/src/main/java/org/apache/zeppelin/socket/Message.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class Message {
3434
*
3535
*/
3636
public static enum OP {
37+
GET_HOME_NOTE, // [c-s] load note for home screen
38+
3739
GET_NOTE, // [c-s] client load note
3840
// @param id note id
3941

zeppelin-server/src/main/java/org/apache/zeppelin/socket/NotebookServer.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import java.util.Map;
2626
import java.util.Set;
2727
import javax.servlet.http.HttpServletRequest;
28+
29+
import org.apache.zeppelin.conf.ZeppelinConfiguration;
30+
import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
2831
import org.apache.zeppelin.display.AngularObject;
2932
import org.apache.zeppelin.display.AngularObjectRegistry;
3033
import org.apache.zeppelin.display.AngularObjectRegistryListener;
@@ -110,6 +113,9 @@ public void onMessage(NotebookSocket conn, String msg) {
110113
case LIST_NOTES:
111114
broadcastNoteList();
112115
break;
116+
case GET_HOME_NOTE:
117+
sendHomeNote(conn, notebook);
118+
break;
113119
case GET_NOTE:
114120
sendNote(conn, notebook, messagereceived);
115121
break;
@@ -279,10 +285,20 @@ private void broadcastNote(Note note) {
279285

280286
private void broadcastNoteList() {
281287
Notebook notebook = notebook();
288+
289+
ZeppelinConfiguration conf = notebook.getConf();
290+
String homescreenNotebookId = conf.getString(ConfVars.ZEPPELIN_NOTEBOOK_HOMESCREEN);
291+
boolean hideHomeScreenNotebookFromList = conf
292+
.getBoolean(ConfVars.ZEPPELIN_NOTEBOOK_HOMESCREEN_HIDE);
293+
282294
List<Note> notes = notebook.getAllNotes();
283295
List<Map<String, String>> notesInfo = new LinkedList<>();
284296
for (Note note : notes) {
285297
Map<String, String> info = new HashMap<>();
298+
if (hideHomeScreenNotebookFromList && note.id().equals(homescreenNotebookId)) {
299+
continue;
300+
}
301+
286302
info.put("id", note.id());
287303
info.put("name", note.getName());
288304
notesInfo.add(info);
@@ -306,6 +322,23 @@ private void sendNote(NotebookSocket conn, Notebook notebook,
306322
}
307323
}
308324

325+
private void sendHomeNote(NotebookSocket conn, Notebook notebook) throws IOException {
326+
String noteId = notebook.getConf().getString(ConfVars.ZEPPELIN_NOTEBOOK_HOMESCREEN);
327+
328+
Note note = null;
329+
if (noteId != null) {
330+
note = notebook.getNote(noteId);
331+
}
332+
333+
if (note != null) {
334+
addConnectionToNote(note.id(), conn);
335+
conn.send(serializeMessage(new Message(OP.NOTE).put("note", note)));
336+
sendAllAngularObjects(note, conn);
337+
} else {
338+
conn.send(serializeMessage(new Message(OP.NOTE).put("note", null)));
339+
}
340+
}
341+
309342
private void updateNote(WebSocket conn, Notebook notebook, Message fromMessage)
310343
throws SchedulerException, IOException {
311344
String noteId = (String) fromMessage.get("id");

zeppelin-web/src/app/home/home.controller.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,34 @@
1313
*/
1414
'use strict';
1515

16-
angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, notebookListDataFactory, websocketMsgSrv) {
16+
angular.module('zeppelinWebApp').controller('HomeCtrl', function($scope, notebookListDataFactory, websocketMsgSrv, $rootScope) {
1717

1818
var vm = this;
1919
vm.notes = notebookListDataFactory;
2020
vm.websocketMsgSrv = websocketMsgSrv;
21+
22+
$scope.notebookHome = false;
23+
$scope.staticHome = false;
2124

25+
var initHome = function() {
26+
websocketMsgSrv.getHomeNotebook();
27+
};
28+
29+
initHome();
30+
31+
$scope.$on('setNoteContent', function(event, note) {
32+
if (note) {
33+
$scope.note = note;
34+
35+
// initialize look And Feel
36+
$rootScope.$broadcast('setLookAndFeel', 'home');
37+
38+
// make it read only
39+
$scope.viewOnly = true;
40+
41+
$scope.notebookHome = true;
42+
} else {
43+
$scope.staticHome = true;
44+
}
45+
});
2246
});

zeppelin-web/src/app/home/home.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,5 +293,4 @@ This part should be removed when new version of bootstrap handles this issue.
293293
.btn-group > .tooltip + .btn,
294294
.btn-group > .popover + .btn {
295295
margin-left:-1px;
296-
}
297-
296+
}

zeppelin-web/src/app/home/home.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
limitations under the License.
1313
-->
1414

15-
<div class="box width-full home" ng-controller="HomeCtrl as home">
15+
<div ng-show="staticHome" class="box width-full home" ng-controller="HomeCtrl as home">
1616
<div class="zeppelin">
1717
<div class="zeppelin2"></div>
1818
</div>
@@ -51,3 +51,22 @@ <h4>Community</h4>
5151
</div>
5252
<br/><br/><br/>
5353
</div>
54+
55+
56+
<!-- Load notebook -->
57+
<div id="{{currentParagraph.id}}_paragraphColumn_main"
58+
ng-show="notebookHome"
59+
ng-repeat="currentParagraph in note.paragraphs"
60+
ng-controller="ParagraphCtrl"
61+
ng-Init="init(currentParagraph)"
62+
ng-class="columnWidthClass(currentParagraph.config.colWidth)"
63+
class="paragraph-col">
64+
<div id="{{currentParagraph.id}}_paragraphColumn"
65+
ng-if="currentParagraph.result"
66+
ng-include src="'app/notebook/paragraph/paragraph.html'"
67+
ng-class="{'paragraph-space box paragraph-margin': !asIframe, 'focused': paragraphFocused}"
68+
ng-hide="currentParagraph.config.tableHide && viewOnly">
69+
</div>
70+
</div>
71+
72+
<div style="clear:both;height:10px"></div>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
16+
/**
17+
* Theme for homescreen
18+
*/
19+
20+
21+
body {
22+
background: #ecf0f1;
23+
}
24+
25+
/**
26+
* Box and well
27+
*/
28+
.box{
29+
border-style: solid;
30+
min-height: 20px;
31+
padding: 19px;
32+
margin-bottom: 20px;
33+
}
34+
35+
.box,
36+
.well {
37+
background-color: #ffffff;
38+
border-color: #e5e5e5;
39+
border-width: 1px 1px 2px;
40+
border-radius: 3px;
41+
-webkit-box-shadow: none;
42+
box-shadow: none;
43+
}
44+
45+
.paragraph {
46+
min-height: 32px;
47+
}
48+
49+
.noteAction {
50+
background-color: white;
51+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
52+
color: #2c3e50;
53+
border-bottom: 1px solid #E5E5E5;
54+
}
55+
56+
.control span {
57+
margin-left: 4px;
58+
}
59+
60+
.control {
61+
padding: 4px;
62+
}
63+
64+
.paragraph-space {
65+
margin-bottom: 5px;
66+
padding: 10px !important;
67+
}
68+
69+
.editor,
70+
.executionTime,
71+
.nv-controlsWrap {
72+
display:block;
73+
}
74+
75+
76+
.paragraph .control {
77+
visibility : hidden;
78+
right:15px;
79+
top: 6px;
80+
}
81+
82+
.paragraph:hover .control {
83+
visibility : hidden;
84+
}
85+
86+
.noteAction span, .noteAction button, .noteAction form {
87+
visibility : hidden;
88+
}
89+
90+
.noteAction:hover span, .noteAction:hover button, .noteAction:hover form {
91+
visibility : visible;
92+
}
93+
94+
.executionTime,
95+
.nv-controlsWrap {
96+
display:none;
97+
}

zeppelin-web/src/components/websocketEvents/websocketMsg.service.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ angular.module('zeppelinWebApp').service('websocketMsgSrv', function($rootScope,
1717

1818
return {
1919

20+
getHomeNotebook: function() {
21+
websocketEvents.sendNewEvent({op: 'GET_HOME_NOTE'});
22+
},
23+
2024
createNotebook: function(noteName) {
2125
websocketEvents.sendNewEvent({op: 'NEW_NOTE',data: {name: noteName}});
2226
},

0 commit comments

Comments
 (0)