Search in sources :

Example 36 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Admin method exportCSVForm.

// --------------------------------------------------------------------------
public static void exportCSVForm(Request request) throws IOException {
    HTMLWriter writer = request.writer;
    MethodForm method_form = new MethodForm(Admin.class);
    method_form.open("exportCSV", request);
    Table table = new Table(writer);
    table.tr().td("filename").td();
    writer.textInput("filename", null, null);
    table.close();
    method_form.close(writer);
}
Also used : HTMLWriter(web.HTMLWriter) Table(web.Table) JDBCTable(db.JDBCTable)

Example 37 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Admin method writeSessionAttributes.

// --------------------------------------------------------------------------
private void writeSessionAttributes(Request request) throws IOException {
    String remove = request.getParameter("remove");
    if (remove != null)
        request.removeSessionAttribute(remove);
    componentOpen(null, request);
    HTMLWriter writer = request.writer;
    Table table = new Table(writer).addClass("table table-condensed table-striped").addStyle("width", "auto");
    table.th("name").th("value").th("action");
    HttpSession session = request.request.getSession();
    ArrayList<String> l = Collections.list(session.getAttributeNames());
    Collections.sort(l);
    for (String name : l) {
        Object value = session.getAttribute(name);
        table.tr().td(name).td();
        DBObject.write(value, writer);
        table.td();
        writer.aOnClick("remove", componentReplaceJS("action=get_session_attributes&remove=" + name, request));
    }
    table.close();
    writer.tagClose();
}
Also used : HTMLWriter(web.HTMLWriter) Table(web.Table) JDBCTable(db.JDBCTable) HttpSession(javax.servlet.http.HttpSession) DBObject(db.DBObject)

Example 38 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Admin method writeSQLForm.

// --------------------------------------------------------------------------
private void writeSQLForm(Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.write("Select <input id=\"columns\" /> from <input id=\"tables\" /> where <input id=\"where\" />");
    writer.nbsp();
    writer.aButtonOnClick("execute", "new Request({url:context+'/admin',method:'get',data:'action=sql&columns='+encodeURIComponent(this.getParent().getElementById('columns').get('value'))+'&tables='+encodeURIComponent(this.getParent().getElementById('tables').get('value'))+'&where='+encodeURIComponent(this.getParent().getElementById('where').get('value')),onComplete:function(t){this.getParent().getElementById('results').set('html',t)}.bind(this)}).send()");
    writer.br().br();
    writer.textAreaOpen(null, "5", "80");
    String sql = (String) request.getSessionAttribute("sql");
    if (sql != null)
        writer.write(sql);
    writer.tagClose();
    writer.nbsp();
    writer.aButtonOnClick("execute", "new Request({url:context+'/admin',method:'post',data:'action=sql&sql='+encodeURIComponent(this.getParent().getElement('textarea').get('value')),onComplete:function(t){this.getParent().getElementById('results').set('html',t)}.bind(this)}).send()");
    writer.write("<div id=\"results\"></div>");
}
Also used : HTMLWriter(web.HTMLWriter)

Example 39 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Admin method writeDefaultForm.

// --------------------------------------------------------------------------
private void writeDefaultForm(String table, JDBCColumn jdbc_column, Request request) throws IOException {
    HTMLWriter writer = request.writer;
    writer.write("<form method=\"POST\">");
    writer.hiddenInput("table", table);
    writer.write("<table style=\"width:100%\">");
    writer.hiddenInput("action", "set column default");
    writer.hiddenInput("column", jdbc_column.name);
    writer.write("<tr><td class=\"db_form_label\">default</td><td>");
    writer.textInput("default", null, jdbc_column.getDefaultValue());
    writer.write("</td></tr>");
    writer.write("<tr><td>&nbsp;</td></tr></table></form>");
}
Also used : HTMLWriter(web.HTMLWriter)

Example 40 with HTMLWriter

use of web.HTMLWriter in project common by zenlunatics.

the class Admin method writeAdminPage.

// --------------------------------------------------------------------------
// private void
// writeAddModuleForm(Request request)
// {
// ClassFinder finder = new ClassFinder();
// finder.add(new File(new FilePathStringBuilder(System.getProperty("catalina.base")).append("shared").append("lib").append("calendar.jar").toString()));
// finder.add(new File(request.getBaseFilePath().append("WEB-INF").append("lib").toString()));
// ArrayList<ClassInfo> found_classes = new ArrayList<ClassInfo>();
// finder.findClasses(found_classes);
// for (ClassInfo classInfo : found_classes) {
// String[] interfaces = classInfo.getInterfaces();
// System.out.println ("Found " + classInfo.getClassName() + interfaces);
// }
// }
// --------------------------------------------------------------------------
private void writeAdminPage(Request request) throws IOException {
    HTMLWriter writer = request.writer;
    request.site.newHead(request).styleSheet("/codemirror-3.21/lib/codemirror").styleSheet("/codemirror-3.21/css/codemirror-ui").script(request.getContext() + "/codemirror-3.21/lib/codemirror").script(request.getContext() + "/codemirror-3.21/mode/xml/xml").script(request.getContext() + "/codemirror-3.21/js/codemirror-ui").script(request.getContext() + "/codemirror-3.21/mode/javascript/javascript").script(request.getContext() + "/codemirror-3.21/mode/css/css").script("quick_edit").styleSheet("choices.min").script("choices.min").close();
    NavBar nav_bar = new NavBar(request.writer).setStaticTop(true).open();
    nav_bar.aOnClick("Home", "document.location='" + request.getContext() + "/" + request.site.getHomePage() + "'");
    nav_bar.aOnClick("Backup", "XHR_post('admin','action=backup',function(){dialog_alert('','done')})");
    nav_bar.aOnClick("File Manager", "new_tab('File Manager','get file manager')");
    nav_bar.aOnClick("Import", "new_tab('Import','import file')");
    if (request.site.getSettings().getString("log path") != null)
        nav_bar.aOnClick("Logs", "new_tab('Logs','get logs')");
    nav_bar.dropdownOpen("Remote");
    nav_bar.aOnClick((request.site.allowRemote() ? "don't allow" : "allow") + " remote access to this site", "XHR_post('admin','action=toggle_remote',function(r){dialog_alert('',r.text)})");
    nav_bar.aOnClick("drop all Id map tables", "XHR_post('admin','method=dropAllIdMapTables&class=Admin',function(r){dialog_alert('',r.text)})");
    nav_bar.aOnClick("import table", "new_tab('Import Table','get_method_form&class=Admin&method=importTable')");
    nav_bar.aOnClick("import views", "new_tab('Import Views','get_method_form&class=Admin&method=importViews')");
    nav_bar.aOnClick("export views", "new_tab('Export Views','get_method_form&class=Admin&method=exportViews')");
    nav_bar.aOnClick("schema diff", "new_tab('Schema Diff','get_schema_diff_form')");
    nav_bar.dropdownClose();
    nav_bar.aOnClick("Search", "new_tab('Search','search')");
    nav_bar.aOnClick("Settings", "new_tab('Settings','edit settings')");
    nav_bar.aOnClick("SQL", "new_tab('SQL','get sql form')");
    nav_bar.aOnClick("State", "new_tab('State','get state')");
    nav_bar.ulOpen(true);
    request.site.writeUserDropdown(nav_bar, request);
    nav_bar.close();
    writer.write("<table style=\"width:100%\"><tr><td id=\"navlist\" valign=\"top\" style=\"width:10%\">");
    writeAccordion(request);
    writer.write("</td><td valign=\"top\">");
    Tabs tabs = new Tabs("admin", writer).setShowClose(true);
    tabs.open();
    tabs.close();
    writer.write("</td></tr></table>");
    writer.scriptOpen();
    writer.jsFunction("column_drop", "table,column,f", "dialog_confirm('Drop column '+column+'?',function(){XHR_post('admin','action=column_drop&table='+table+'&column='+column,f)})");
    writer.jsFunction("column_rename", "table,column,f", "var new_name=prompt('enter new name', column);" + "if(new_name)" + "XHR_post('admin','action=column_rename&table='+table+'&column='+column+'&newname='+new_name,f)");
    writer.jsFunction("create_table_def", null, "var table=prompt('enter table name');" + "if(table)" + "XHR_post('admin','action=create_table_def&table_def='+table,function(){get_nav_list('table defs')});");
    writer.jsFunction("create_view", null, "var view=prompt('enter view name');" + "if(view)" + "XHR_post('admin','action=create_view&view='+view,function(){get_nav_list('views')})");
    writer.jsFunction("get_nav_list", "section", "$('navlist').replace('admin?action=get_nav_list&display='+section);");
    writer.write("var num_tabs=1;");
    writer.jsFunction("new_tab", "label,action", "var tabs=$('" + tabs.getID() + "').tabs;" + "var tab=tabs.addTab((num_tabs++)+':'+label);" + "tab.panel.replace('admin?action='+action,{on_complete:function(){tabs.show(tab);}})");
    writer.jsFunction("table_delete", "table", "var where=prompt('delete where');" + "if(where)" + "XHR_post('admin','action=table_delete&table='+table+'&where='+encodeURIComponent(where),function(){dialog_alert('','done')})");
    writer.jsFunction("table_drop", "table", "dialog_confirm('Drop table '+table+'?',function(){XHR_post('admin','action=table_drop&table='+table,function(){$('admin tabs').tabs.closeTab();get_nav_list('tables');})})");
    writer.jsFunction("truncate_table", "table", "dialog_confirm('Delete all rows from table '+table+'?',function(){XHR_post('admin','action=truncate table&table='+table,function(){dialog_alert('','done')})})");
    writer.jsFunction("table_rename", "table", "var new_name=prompt('enter new name', table);" + "if(new_name)" + "XHR_post('admin','action=table_rename&table='+table+'&newname='+new_name,function(){dialog_alert('','table renamed');get_nav_list('tables')})");
    writer.scriptClose();
    request.close();
}
Also used : HTMLWriter(web.HTMLWriter) NavBar(web.NavBar) Tabs(web.Tabs)

Aggregations

HTMLWriter (web.HTMLWriter)109 Select (db.Select)18 SQLException (java.sql.SQLException)16 ResultSet (java.sql.ResultSet)14 Table (web.Table)12 JDBCTable (db.JDBCTable)10 Person (app.Person)7 Calendar (java.util.Calendar)7 ArrayList (java.util.ArrayList)6 JDBCColumn (db.JDBCColumn)5 View (db.View)5 DBObject (db.DBObject)4 Form (db.Form)4 File (java.io.File)4 AdminTask (web.AdminTask)4 FilePathStringBuilder (web.FilePathStringBuilder)4 Select (web.Select)4 Mode (db.View.Mode)3 IOException (java.io.IOException)3 NumberFormat (java.text.NumberFormat)3