diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | extjsdemo-controller.lua | 52 | ||||
-rw-r--r-- | extjsdemo-html.lsp | 107 | ||||
-rw-r--r-- | extjsdemo-model.lua | 25 | ||||
-rw-r--r-- | extjsdemo.menu | 1 |
5 files changed, 189 insertions, 0 deletions
@@ -6,6 +6,10 @@ APP_DIST=\ bar-controller.lua \ bar-html.lsp \ bar.menu \ + extjsdemo-controller.lua\ + extjsdemo-model.lua \ + extjsdemo-html.lsp \ + extjsdemo.menu \ foo-controller.lua \ foo-html.lsp \ foo.menu \ diff --git a/extjsdemo-controller.lua b/extjsdemo-controller.lua new file mode 100644 index 0000000..6a7a13e --- /dev/null +++ b/extjsdemo-controller.lua @@ -0,0 +1,52 @@ +-- ipsec controller + +module(..., package.seeall) + +require("posix") +require("json") + +function test(self) + local a = {} +-- a.path = posix.cwd() + return a +end + +-- quick and dirty json resolver. could be done with viewtype? +-- anyway... the file would be a oneliner anyway... +local function json_resolver(self) + io.write("\n\n"..json.encode(self).."\n") +end + +function submit(self) + -- overwrite resolver. quick and dirty... + view_resolver = function(self) + return json_resolver + end + + local ret = {} + + -- only validation here is we test if mask is 'aaa' + if self.clientdata.mask == "aaa" then + ret.success = false + ret.errors = { mask = "'aaa' is a netmask...?" } + else + ret.success = true + end + + return ret +end + +function load(self) + -- overwrite resolver. quick and dirty... + view_resolver = function(self) + return json_resolver + end + + local ret = {} + -- we must define 'success' and 'data' fields + ret.success = "true" + ret.data = { address = "1.2.3.4", mask = "255.255.255.0" } + return ret +end + + diff --git a/extjsdemo-html.lsp b/extjsdemo-html.lsp new file mode 100644 index 0000000..7fd9534 --- /dev/null +++ b/extjsdemo-html.lsp @@ -0,0 +1,107 @@ +<? local ctl = ... ?> + +<!-- this could go in a separate .js file --> + +<script type="text/javascript"> + +Ext.onReady(function() { + Ext.QuickTips.init(); + + // turn on validation errors beside the field globally + Ext.form.Field.prototype.msgTarget = 'side'; + + var fp = new Ext.FormPanel({ + xtype:"form", + title:"Interface", + buttonAlign:"right", + id: "interface", + items:[{ + xtype:"fieldset", + title:"Eth0", + autoHeight:true, + items:[{ + xtype:"checkbox", + fieldLabel:"Enable interface", + boxLabel:"", + name:"ifenable", + inputValue:"cbvalue" + }, + + // create combobox + new Ext.form.ComboBox({ + fieldLabel:"Type", + hiddenName:"iftype", + store: new Ext.data.SimpleStore({ + fields: ['type', 'typedesc'], + data:[ + ['dhcp', 'Automatic (DHCP)'], + ['static', 'Static IP Address'] + ] + }), + valueField: 'type', + displayField: 'typedesc', + typeAhead: true, + triggerAction: 'all', + mode: 'local', + emptyText: 'Select Interface type...', + allowBlank: false, + selectOnFocus: true + }), + { + xtype:"textfield", + fieldLabel:"Address", + name:"address", +// allowBlank: false + },{ + xtype:"textfield", + fieldLabel:"Netmask", + name:"mask", +// allowBlank: false + },{ + xtype:"textfield", + fieldLabel:"Gateway", + name:"gateway" + }] + }], + }); + + var applybt = fp.addButton({ + text: 'Apply', +// disabled: true, + handler: function() { + fp.getForm().submit({ + url: 'submit', + waitMsg: 'Saving Data...' + }); + } + }); + + fp.render('interface-example'); + + // this connects to extjsdemo-controller.lua: load() + fp.getForm().load({url: 'load', waitMsg: 'Loading'}); + + fp.on({ + + actioncomplete: function(form, action) { + if (action.type == 'submit'){ + // we disable the apply button above to indicate succes + applybt.disable(); + } + }, +// actionfailed: function(form, action) { + // something failed +// alert('form.id = ' + form.id); +// } + + }); + + +}); + +</script> + +<h1>Extjs Test</h1> +<div id="msg"></div> +<div id="interface-example"></div> + diff --git a/extjsdemo-model.lua b/extjsdemo-model.lua new file mode 100644 index 0000000..7103e2d --- /dev/null +++ b/extjsdemo-model.lua @@ -0,0 +1,25 @@ +-- ipsec controller + +module(..., package.seeall) + +require("posix") + +--------------------------------------------------------- +-- privileged funcs + +priv = {} +function priv.getuid() + return posix.getpid().euid +end + + + +------------------------------------------------------------- +-- Unprivileged funcs + +function getuid(self) + return posix.getpid().euid +end + + + diff --git a/extjsdemo.menu b/extjsdemo.menu new file mode 100644 index 0000000..540b463 --- /dev/null +++ b/extjsdemo.menu @@ -0,0 +1 @@ +Test ExtJS_Demo Define test |