mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
[ZEPPELIN-1363] button to remove form
This commit is contained in:
parent
c566462a5f
commit
9b2f3e9bae
8 changed files with 59 additions and 13 deletions
|
|
@ -350,9 +350,12 @@ public class NotebookServer extends WebSocketServlet
|
|||
case WATCHER:
|
||||
switchConnectionToWatcher(conn, messagereceived);
|
||||
break;
|
||||
case NOTE_FORMS:
|
||||
case SAVE_NOTE_FORMS:
|
||||
saveNoteForms(conn, userAndRoles, notebook, messagereceived);
|
||||
break;
|
||||
case REMOVE_NOTE_FORMS:
|
||||
removeNoteForms(conn, userAndRoles, notebook, messagereceived);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -2507,7 +2510,7 @@ public class NotebookServer extends WebSocketServlet
|
|||
formsSettings.setForms(note.getNoteForms());
|
||||
formsSettings.setParams(note.getNoteParams());
|
||||
|
||||
broadcast(note.getId(), new Message(OP.NOTE_FORMS).put("formsData", formsSettings));
|
||||
broadcast(note.getId(), new Message(OP.SAVE_NOTE_FORMS).put("formsData", formsSettings));
|
||||
}
|
||||
|
||||
private void saveNoteForms(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook,
|
||||
|
|
@ -2529,4 +2532,25 @@ public class NotebookServer extends WebSocketServlet
|
|||
broadcastNoteForms(note);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeNoteForms(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook,
|
||||
Message fromMessage) throws IOException {
|
||||
String noteId = (String) fromMessage.get("noteId");
|
||||
String formName = (String) fromMessage.get("formName");
|
||||
|
||||
if (!hasParagraphWriterPermission(conn, notebook, noteId,
|
||||
userAndRoles, fromMessage.principal, "update")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Note note = notebook.getNote(noteId);
|
||||
if (note != null) {
|
||||
note.getNoteForms().remove(formName);
|
||||
note.getNoteParams().remove(formName);
|
||||
|
||||
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
|
||||
note.persist(subject);
|
||||
broadcastNoteForms(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ limitations under the License.
|
|||
ng-repeat="formulaire in forms | toArray"
|
||||
ng-init="loadForm(formulaire, params)">
|
||||
<label class="control-label input-sm" ng-class="{'disable': disable}">{{formulaire.name}}</label>
|
||||
<a ng-if="removeaction">
|
||||
<i class="fa fa-times"
|
||||
ng-click="removeaction(formulaire.name)"
|
||||
tooltip-placement="bottom" uib-tooltip="Remove">
|
||||
</i>
|
||||
</a>
|
||||
<div>
|
||||
<input class="form-control input-sm"
|
||||
ng-if="forms[formulaire.name].type == 'TextBox'"
|
||||
|
|
@ -26,7 +32,7 @@ limitations under the License.
|
|||
ng-class="{'disable': disable}"
|
||||
name="{{formulaire.name}}" />
|
||||
</div>
|
||||
<div ng-if="actiononchange == true">
|
||||
<div ng-if="actiononchange === true">
|
||||
<select class="form-control input-sm"
|
||||
ng-if="forms[formulaire.name].type == 'Select'"
|
||||
ng-change="action()"
|
||||
|
|
@ -36,7 +42,7 @@ limitations under the License.
|
|||
ng-options="option.value as (option.displayName||option.value) for option in forms[formulaire.name].options">
|
||||
</select>
|
||||
</div>
|
||||
<div ng-if="actiononchange == false">
|
||||
<div ng-if="actiononchange === false">
|
||||
<select class="form-control input-sm"
|
||||
ng-if="forms[formulaire.name].type == 'Select'"
|
||||
ng-enter="action()"
|
||||
|
|
@ -46,7 +52,7 @@ limitations under the License.
|
|||
ng-options="option.value as (option.displayName||option.value) for option in forms[formulaire.name].options">
|
||||
</select>
|
||||
</div>
|
||||
<div ng-if="actiononchange == true &&
|
||||
<div ng-if="actiononchange === true &&
|
||||
forms[formulaire.name].type == 'CheckBox'">
|
||||
<label ng-repeat="option in forms[formulaire.name].options"
|
||||
class="checkbox-item input-sm">
|
||||
|
|
@ -56,7 +62,7 @@ limitations under the License.
|
|||
ng-click="toggleCheckbox(formulaire, option, params); action()"/> {{option.displayName||option.value}}
|
||||
</label>
|
||||
</div>
|
||||
<div ng-if="actiononchange == false &&
|
||||
<div ng-if="actiononchange === false &&
|
||||
forms[formulaire.name].type == 'CheckBox'">
|
||||
<label ng-repeat="option in forms[formulaire.name].options"
|
||||
class="checkbox-item input-sm">
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ function DynamicFormDirective($templateRequest, $compile) {
|
|||
actiononchange: '=actiononchange',
|
||||
forms: '=forms',
|
||||
params: '=params',
|
||||
action: '=action'
|
||||
action: '=action',
|
||||
removeaction: '=removeaction'
|
||||
},
|
||||
|
||||
link: function (scope, element, attrs, controller) {
|
||||
|
|
|
|||
|
|
@ -1334,7 +1334,7 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope,
|
|||
}
|
||||
}
|
||||
|
||||
$scope.$on('noteForms', function (event, data) {
|
||||
$scope.$on('saveNoteForms', function (event, data) {
|
||||
$scope.note.noteForms = data.formsData.forms
|
||||
$scope.note.noteParams = data.formsData.params
|
||||
})
|
||||
|
|
@ -1350,6 +1350,10 @@ function NotebookCtrl ($scope, $route, $routeParams, $location, $rootScope,
|
|||
websocketMsgSrv.saveNoteForms($scope.note)
|
||||
}
|
||||
|
||||
$scope.removeNoteForms = function (formName) {
|
||||
websocketMsgSrv.removeNoteForms($scope.note, formName)
|
||||
}
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
angular.element(window).off('beforeunload')
|
||||
$scope.killSaveTimer()
|
||||
|
|
|
|||
|
|
@ -124,7 +124,8 @@ limitations under the License.
|
|||
actiononchange="actionOnFormSelectionChange"
|
||||
forms="note.noteForms"
|
||||
params="note.noteParams"
|
||||
action="saveNoteForms"></dynamic-forms>
|
||||
action="saveNoteForms"
|
||||
removeaction="removeNoteForms"></dynamic-forms>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -140,8 +140,8 @@ function WebsocketEventFactory ($rootScope, $websocket, $location, baseUrlSrv) {
|
|||
$rootScope.$broadcast('noteRevision', data)
|
||||
} else if (op === 'INTERPRETER_BINDINGS') {
|
||||
$rootScope.$broadcast('interpreterBindings', data)
|
||||
} else if (op === 'NOTE_FORMS') {
|
||||
$rootScope.$broadcast('noteForms', data)
|
||||
} else if (op === 'SAVE_NOTE_FORMS') {
|
||||
$rootScope.$broadcast('saveNoteForms', data)
|
||||
} else if (op === 'ERROR_INFO') {
|
||||
BootstrapDialog.show({
|
||||
closable: false,
|
||||
|
|
|
|||
|
|
@ -341,12 +341,21 @@ function WebsocketMessageService ($rootScope, websocketEvents) {
|
|||
},
|
||||
|
||||
saveNoteForms: function (note) {
|
||||
websocketEvents.sendNewEvent({op: 'NOTE_FORMS',
|
||||
websocketEvents.sendNewEvent({op: 'SAVE_NOTE_FORMS',
|
||||
data: {
|
||||
noteId: note.id,
|
||||
noteParams: note.noteParams
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
removeNoteForms: function (note, formName) {
|
||||
websocketEvents.sendNewEvent({op: 'REMOVE_NOTE_FORMS',
|
||||
data: {
|
||||
noteId: note.id,
|
||||
formName: formName
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,7 +180,8 @@ public class Message implements JsonSerializable {
|
|||
PARAGRAPH_EXECUTED_BY_SPELL, // [c-s] paragraph was executed by spell
|
||||
RUN_PARAGRAPH_USING_SPELL, // [s-c] run paragraph using spell
|
||||
PARAS_INFO, // [s-c] paragraph runtime infos
|
||||
NOTE_FORMS // set note forms
|
||||
SAVE_NOTE_FORMS, // save note forms
|
||||
REMOVE_NOTE_FORMS // remove note forms
|
||||
}
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
|
|
|
|||
Loading…
Reference in a new issue