Changeset 929
- Timestamp:
- 10/04/07 18:18:53 (1 year ago)
- Files:
-
- cherokee-admin/trunk/admin.html (modified) (2 diffs)
- cherokee-admin/trunk/admin.js (modified) (1 diff)
- cherokee-admin/trunk/server.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee-admin/trunk/admin.html
r926 r929 1 1 <html> 2 2 <head> 3 <link rel="stylesheet" type="text/css" href=" /admin/js/resources/css/ext-all.css" />3 <link rel="stylesheet" type="text/css" href="js/resources/css/ext-all.css" /> 4 4 </head> 5 5 <body> … … 8 8 <script type="text/javascript" src="admin.js"></script> 9 9 <div id="vserver-list" style="width: 180px;"></div> 10 <div id="vserver-options"></div> 10 11 </body> 11 12 </html> cherokee-admin/trunk/admin.js
r926 r929 1 1 Ext.onReady(function () { 2 2 3 var recordDefinition = Ext.data.Record.create([{name: 'vserver'}]); 3 function render_configuration_objects (path) { 4 function onSuccess (response) { 5 var targetElement = document.getElementById("vserver-options"); 6 targetElement.innerHTML = response.responseText; 7 8 } 9 var connection = new Ext.data.Connection(); 10 connection.request({ 11 url: path, 12 success: onSuccess 13 }); 14 } 4 15 5 var vserverReader = new Ext.data.JsonReader({root: "vservers"}, recordDefinition); 16 function change_vserver (grid, rowIndex, columnIndex) { 17 var record = grid.getDataSource().getAt(rowIndex); 18 var vserver = record.data.vserver.toString(); 19 20 render_configuration_objects("/config/vserver/" + vserver); 21 } 22 23 var recordDefinition = Ext.data.Record.create ([{name: 'vserver'}]); 24 25 var vserverReader = new Ext.data.JsonReader ({root: "vservers"}, recordDefinition); 6 26 7 27 var ds = new Ext.data.Store({ 8 proxy: new Ext.data.HttpProxy ({url: "/config/vserver/?widget=grid"}),28 proxy: new Ext.data.HttpProxy ({url: "/config/vserver/?widget=grid"}), 9 29 reader: vserverReader, 10 30 }); 11 31 ds.load(); 12 32 13 var colModel = new Ext.grid.ColumnModel([{id: 'name', header: "Virtual Server", width: 160, sortable: false, locked:false, dataIndex: 'vserver'}]);33 var colModel = new Ext.grid.ColumnModel ([{id: 'name', header: "Virtual Server", width: 160, sortable: false, locked:false, dataIndex: 'vserver'}]); 14 34 15 35 // create the Grid 16 var grid = new Ext.grid.Grid('vserver-list', { 17 ds: ds, 18 cm: colModel 19 }); 20 21 grid.render(); 22 grid.getSelectionModel().selectFirstRow(); 36 var grid = new Ext.grid.Grid ('vserver-list', { 37 ds: ds, 38 cm: colModel 39 }); 40 41 grid.on ('cellclick', change_vserver); 42 43 grid.render (); 44 grid.getSelectionModel ().selectFirstRow (); 23 45 }); 24 46 cherokee-admin/trunk/server.py
r926 r929 25 25 request_uri = self.env['REQUEST_URI'] 26 26 27 if request_uri.startswith('/admin'):28 self._admin_request(request_uri)29 return30 27 31 28 if request_uri.startswith("/config"): 32 29 self._config_request(request_uri) 30 return 31 32 # By deafault, it's an admin interface request 33 self._admin_request(request_uri) 34 33 35 34 36 def _config_request(self, request_uri): … … 37 39 if "?" in request_uri: 38 40 request_path, request_options = request_uri.split("?") 39 else:41 else: 40 42 request_path = request_uri 41 request_options = "" 42 43 request_options = "" 44 45 43 46 request_path = strip_slashes(request_path) 44 47 request_options = self._parse_options(request_options) 45 48 49 request_uri_elements = request_path.split("/") 50 config_path = request_uri_elements[1:] # Override the /config/ element 51 46 52 config_node = self.config.root 47 request_uri_elements = request_path.split("/") 48 49 for path_element in request_uri_elements[1:]: 53 54 for path_element in config_path: 50 55 path_element = path_element.replace("$", "/") 51 56 52 57 if not path_element: 53 58 continue 54 59 55 60 config_node = config_node[path_element] 56 61 57 62 #Special EXT JS request for the treeview 58 if request_uri_elements[-1] == "vserver" \63 if request_uri_elements[-1] == "vserver" \ 59 64 and request_options.has_key("widget"): 60 65 widget = request_options ["widget"] … … 68 73 if config_node: 69 74 self._return_node_as_json(config_node) 70 75 71 76 def _admin_request(self, request_uri): 72 77 """Javascript or CSS content request handler.""" 73 78 if request_uri.endswith(".js") or request_uri.endswith(".css"): 74 content = open(request_uri[ 7:])79 content = open(request_uri[1:]) 75 80 self.wfile.write(content.read()) 76 content.close()81 content.close() 77 82 return 78 83 79 if strip_slashes(request_uri) == "admin": 80 ui = open(ADMIN_TEMPLATE) 81 self.wfile.write(ui.read()) 82 ui.close() 83 return 84 ui = open(ADMIN_TEMPLATE) 85 self.wfile.write(ui.read()) 86 ui.close() 87 return 84 88 85 89 def _return_vserver_grid(self, config_node): 86 90 comma = False 87 91 88 92 records = "[" 89 93 for vserver in config_node: 90 94 if comma: 91 95 records += ", " 92 96 93 97 records += '{"vserver": "%s"}' % (vserver,) 94 98 comma = True 95 96 99 97 100 records += "]" 98 101 … … 103 106 def _return_vserver_treeview(self, config_node): 104 107 """JSON formatted EXT JS vserver treeview response.""" 105 108 106 109 comma = False 107 110 108 111 self.wfile.write("[") 109 112 id = 0 … … 111 114 if comma: 112 115 self.wfile.write(", ") 113 116 114 117 self.wfile.write('{"id": "%s", "text": "%s", "cls": "icon", "leaf": true}' \ 115 118 % (vserver, vserver)) … … 117 120 id += 1 118 121 comma = True 119 120 122 121 123 self.wfile.write("]") 122 124