ZEPPELIN-1254 boradcast after updating the interpreter bindings

This commit is contained in:
Renjith Kamath 2016-08-02 16:05:08 +05:30
parent 299bb511bf
commit ab0bced9d6
3 changed files with 14 additions and 6 deletions

View file

@ -187,6 +187,7 @@ public class NotebookRestApi {
public Response bind(@PathParam("noteId") String noteId) {
List<InterpreterSettingsList> settingList =
InterpreterBindingUtils.getInterpreterBindings(notebook, noteId);
notebookServer.broadcastInterpreterBindings(noteId, settingList);
return new JsonResponse<>(Status.OK, "", settingList).build();
}

View file

@ -418,11 +418,14 @@ public class NotebookServer extends WebSocketServlet implements
}
public void saveInterpreterBindings(NotebookSocket conn, Message fromMessage) {
String noteId = (String) fromMessage.data.get("noteID");
try {
List<String> settingIdList = gson.fromJson(String.valueOf(
fromMessage.data.get("selectedSettingIds")), new TypeToken<ArrayList<String>>() {
}.getType());
notebook().bindInterpretersToNote((String) fromMessage.data.get("noteID"), settingIdList);
notebook().bindInterpretersToNote(noteId, settingIdList);
broadcastInterpreterBindings(noteId,
InterpreterBindingUtils.getInterpreterBindings(notebook(), noteId));
} catch (Exception e) {
LOG.error("Error while saving interpreter bindings", e);
}
@ -433,9 +436,7 @@ public class NotebookServer extends WebSocketServlet implements
String noteID = (String) fromMessage.data.get("noteID");
List<InterpreterSettingsList> settingList =
InterpreterBindingUtils.getInterpreterBindings(notebook(), noteID);
conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS)
.put("interpreterBindings", settingList)));
broadcastInterpreterBindings(noteID, settingList);
}
public List<Map<String, String>> generateNotebooksInfo(boolean needsReload,
@ -477,6 +478,12 @@ public class NotebookServer extends WebSocketServlet implements
broadcast(note.id(), new Message(OP.NOTE).put("note", note));
}
public void broadcastInterpreterBindings(String noteId,
List settingList) {
broadcast(noteId, new Message(OP.INTERPRETER_BINDINGS)
.put("interpreterBindings", settingList));
}
public void broadcastNoteList(AuthenticationInfo subject) {
List<Map<String, String>> notesInfo = generateNotebooksInfo(false, subject);
broadcastAll(new Message(OP.NOTES_INFO).put("notes", notesInfo));

View file

@ -449,7 +449,7 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
}
};
var getInterpreterBindings = function(callback) {
var getInterpreterBindings = function() {
websocketMsgSrv.getInterpreterBindings($scope.note.id);
};
@ -967,7 +967,7 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro
}
initializeLookAndFeel();
//open interpreter binding setting when there're none selected
getInterpreterBindings(); //getInterpreterBindings(getInterpreterBindingsCallBack);
getInterpreterBindings();
});
$scope.$on('$destroy', function() {