|
@@ -365,6 +365,10 @@ var Snippet = function (vm, notebook, snippet) {
|
|
|
else if (data.status == -3) { // Statement expired
|
|
else if (data.status == -3) { // Statement expired
|
|
|
self.status('expired');
|
|
self.status('expired');
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (data.status == 403) { // Auth required
|
|
|
|
|
+ self.status('expired');
|
|
|
|
|
+ $(document).trigger("showAuthModal", {'type': self.type(), 'snippet': self});
|
|
|
|
|
+ }
|
|
|
else if (data.status == 1 || data.status == -1) {
|
|
else if (data.status == 1 || data.status == -1) {
|
|
|
self.status('failed');
|
|
self.status('failed');
|
|
|
var match = ERROR_REGEX.exec(data.message);
|
|
var match = ERROR_REGEX.exec(data.message);
|
|
@@ -381,7 +385,7 @@ var Snippet = function (vm, notebook, snippet) {
|
|
|
self.lastExecuted = 0;
|
|
self.lastExecuted = 0;
|
|
|
|
|
|
|
|
self.execute = function () {
|
|
self.execute = function () {
|
|
|
- var now = (new Date()).getTime(); // we don't allow fast clicks
|
|
|
|
|
|
|
+ var now = (new Date()).getTime(); // We don't allow fast clicks
|
|
|
if (self.status() == 'running' || self.status() == 'loading' || now - self.lastExecuted < 1000) {
|
|
if (self.status() == 'running' || self.status() == 'loading' || now - self.lastExecuted < 1000) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -487,7 +491,7 @@ var Snippet = function (vm, notebook, snippet) {
|
|
|
notebook.newSnippet();
|
|
notebook.newSnippet();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
self.fetchResultMetadata = function () {
|
|
self.fetchResultMetadata = function () {
|
|
|
$.post("/notebook/api/fetch_result_metadata", {
|
|
$.post("/notebook/api/fetch_result_metadata", {
|
|
|
notebook: ko.mapping.toJSON(notebook.getContext()),
|
|
notebook: ko.mapping.toJSON(notebook.getContext()),
|
|
@@ -769,7 +773,7 @@ var Notebook = function (vm, notebook) {
|
|
|
|
|
|
|
|
$.post("/notebook/api/create_session", {
|
|
$.post("/notebook/api/create_session", {
|
|
|
notebook: ko.mapping.toJSON(self.getContext()),
|
|
notebook: ko.mapping.toJSON(self.getContext()),
|
|
|
- session: ko.mapping.toJSON(session) // e.g. {'type': 'hive', 'properties': [{'driverCores': '2'}]}
|
|
|
|
|
|
|
+ session: ko.mapping.toJSON(session) // e.g. {'type': 'hive', 'properties': [{'name': driverCores', 'value', '2'}]}
|
|
|
}, function (data) {
|
|
}, function (data) {
|
|
|
if (data.status == 0) {
|
|
if (data.status == 0) {
|
|
|
ko.mapping.fromJS(data.session, {}, session);
|
|
ko.mapping.fromJS(data.session, {}, session);
|
|
@@ -782,6 +786,8 @@ var Notebook = function (vm, notebook) {
|
|
|
if (callback) {
|
|
if (callback) {
|
|
|
setTimeout(callback, 500);
|
|
setTimeout(callback, 500);
|
|
|
}
|
|
}
|
|
|
|
|
+ } else if (data.status == 403) {
|
|
|
|
|
+ $(document).trigger("showAuthModal", {'type': session.type()});
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
fail(data.message);
|
|
fail(data.message);
|
|
@@ -793,6 +799,18 @@ var Notebook = function (vm, notebook) {
|
|
|
})
|
|
})
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ self.authSession = function () {
|
|
|
|
|
+ self.createSession(new Session(vm, {
|
|
|
|
|
+ 'type': vm.authSessionType(),
|
|
|
|
|
+ 'properties': [
|
|
|
|
|
+ {'name': 'user', 'value': vm.authSessionUsername()},
|
|
|
|
|
+ {'name': 'password', 'value': vm.authSessionPassword()}
|
|
|
|
|
+ ]
|
|
|
|
|
+ }),
|
|
|
|
|
+ vm.authSessionSnippet() ? vm.authSessionSnippet().execute : null // On new session we don't automatically execute the snippet after the aut. On session expiration we do.
|
|
|
|
|
+ );
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
self.newSnippet = function (type) {
|
|
self.newSnippet = function (type) {
|
|
|
if (type) {
|
|
if (type) {
|
|
|
self.selectedSnippet(type);
|
|
self.selectedSnippet(type);
|
|
@@ -921,6 +939,11 @@ function EditorViewModel(notebooks, options) {
|
|
|
self.isEditing(!self.isEditing());
|
|
self.isEditing(!self.isEditing());
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ self.authSessionUsername = ko.observable(); // UI popup
|
|
|
|
|
+ self.authSessionPassword = ko.observable();
|
|
|
|
|
+ self.authSessionType = ko.observable();
|
|
|
|
|
+ self.authSessionSnippet = ko.observable();
|
|
|
|
|
+
|
|
|
self.removeSnippetConfirmation = ko.observable();
|
|
self.removeSnippetConfirmation = ko.observable();
|
|
|
|
|
|
|
|
self.removeSnippet = function (notebook, snippet) {
|
|
self.removeSnippet = function (notebook, snippet) {
|