Skip to content

Commit

Permalink
Frontend: Get view definition
Browse files Browse the repository at this point in the history
  • Loading branch information
smurfpandey committed Feb 6, 2015
1 parent 43bd4ed commit 94882e5
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ function editFunction(dbName, fnName, fnDef, cb) {
definition: fnDef
}, cb);
}
function getViewDefiniton(dbName, viewName, cb) {
apiCall("get", "/databases/" + dbName + "/views/" + viewName, {}, cb);
}


var fnGetSelectedTable = function() {
return theTable;
Expand Down Expand Up @@ -400,6 +404,25 @@ var showEditFunction = function(funcName, treeNode) {
});
};

var showEditView = function(viewName, treeNode) {
var dbName = treeNode.parent.parent.name;

getViewDefiniton(dbName, viewName, function(data) {
if (data.error) {
//show error
return;
}

var procText = data.rows[0][1];

fnCreateEditorTab(dbName + '.' + viewName, procText, viewName, {
proc_name: viewName,
db_name: dbName,
proc_type: 'VIEW'
});
});
};

var fnGetProcName = function(procText) {
//Get start point
var startIndex = 17;
Expand All @@ -417,7 +440,7 @@ var fnGetProcName = function(procText) {

return $.trim(procName);

}
};

var showCreateProcedure = function(dbName) {

Expand Down Expand Up @@ -689,6 +712,10 @@ function forTheTree() {
{
type: 'function',
menu_element: $('#fnMenu')
},
{
type: 'view',
menu_element: $('#vwMenu')
}
];

Expand Down Expand Up @@ -719,6 +746,9 @@ function forTheTree() {
},
"create-fn": function(node) {
showCreateFunction(node.name);
},
"edit-vw": function(node) {
showEditView(node.name, node);
}
});
}
Expand Down

0 comments on commit 94882e5

Please sign in to comment.