MCPcopy
hub / github.com/joeferner/redis-commander / selectTreeNodeReJSON

Function selectTreeNodeReJSON

web/static/scripts/redisCommander.js:753–790  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

751}
752
753function selectTreeNodeReJSON(data) {
754 renderEjs('templates/editReJSON.ejs', data, $('#body'), function() {
755 console.log('rendered ReJSON template')
756 // do not check if it is valid json - assume it is as its stored server-side as ReJSON
757 // simplifies handling here compared to pure string data
758 const jsonObject = losslessJSON.parse(data.value);
759 $('#jqtree_json_div').jsonViewer(jsonObject, {withQuotes: true, withLinks: false, bigNumbers: true});
760 if ((uiConfig.jsonViewAsDefault & uiConfig.const.jsonViewString) > 0) dataUIFuncs.onModeJsonButtonClick('#editJsonForm')
761
762 $('#stringValue').val(data.value);
763 addInputValidator('stringValue', 'json');
764
765 if (!redisReadOnly) {
766 $('#editJsonForm').off('submit').on('submit', function(event) {
767 console.log('saving');
768 event.preventDefault();
769 var editForm = $(event.target);
770 $('#saveKeyButton').attr('disabled', 'disabled').html('<i class="icon-refresh"></i> Saving');
771
772 $.post(editForm.attr('action'), editForm.serialize()
773 ).done(function(data2, status) {
774 console.log('saved', arguments);
775 refreshTree();
776 getKeyTree().select_node(0);
777 })
778 .fail(function(err) {
779 console.log('save error', arguments);
780 alert('Could not save "' + err.statusText + '"');
781 })
782 .always(function() {
783 setTimeout(function() {
784 $('#saveKeyButton').prop('disabled', false).html('Save');
785 }, 500);
786 });
787 });
788 }
789 });
790}
791
792function getKeyTree () {
793 return $.jstree.reference('#keyTree');

Callers 1

processDataFunction · 0.85

Calls 5

renderEjsFunction · 0.85
$Function · 0.85
addInputValidatorFunction · 0.85
refreshTreeFunction · 0.85
getKeyTreeFunction · 0.85

Tested by

no test coverage detected