Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 133 lines (103 sloc) 4.36 kb
ff20af9 @alobbs Adds the new admin
alobbs authored
1 # -*- coding: utf-8 -*-
2 #
3 # Cherokee-admin
4 #
5 # Authors:
6 # Alvaro Lopez Ortega <alvaro@alobbs.com>
5364b9c git-svn-id: svn://cherokee-project.com/cherokee/trunk@5147 5dc97367-97f1...
taher authored
7 # Taher Shihadeh <taher@octality.com>
ff20af9 @alobbs Adds the new admin
alobbs authored
8 #
920e20b @alobbs Happy new year!
alobbs authored
9 # Copyright (C) 2001-2011 Alvaro Lopez Ortega
ff20af9 @alobbs Adds the new admin
alobbs authored
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of version 2 of the GNU General Public
13 # License as published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 # 02110-1301, USA.
24 #
25
26 import re
27 import CTK
28 import Page
29 import Graph
30 import Cherokee
31 import validations
32 import SelectionPanel
33
34 from CTK.Submitter import HEADER as Submit_HEADER
35 from configured import *
36
37 URL_BASE = '/status'
38
39 # Help entries
40 HELPS = [('config_status', N_("Status"))]
41
42
43 class LiveLogs_Instancer (CTK.Container):
44 class LiveLogs (CTK.Box):
45 def __init__ (self, refreshable, vserver = None, **kwargs):
46 CTK.Box.__init__ (self, **kwargs)
47
48 self.refreshable = refreshable
49 self.vserver = vserver
50
51 def __init__ (self, vserver):
52 CTK.Container.__init__ (self)
53
54 # Refresher
55 refresh = CTK.Refreshable ({'id': 'log-area'})
56 refresh.register (lambda: self.LiveLogs(refresh, vserver).Render())
57 self += refresh
58
59
60 class Render_Content (CTK.Container):
61 def __call__ (self, vsrv = None):
62
63 # Render graphs
64 if CTK.request.url.endswith('/general'):
65 vsrv_nam = None
66 title = _('Server Wide Monitoring')
67 graph = Graph.GraphServer_Instancer()
68 else:
69 vsrv_num = CTK.request.url.split('/')[-1]
70 vsrv_nam = CTK.cfg.get_val ("vserver!%s!nick" %(vsrv_num), _("Unknown"))
71 title ='%s: %s' %(_('Virtual Server Monitoring'), vsrv_nam)
72 graph = Graph.GraphVServer_Instancer(vsrv_num)
73
74 cont = CTK.Container()
75 cont += CTK.RawHTML ('<h2>%s</h2>' %(title))
76 cont += graph
77
78 render = cont.Render()
79 return render.toJSON()
80
81
93b1194 Changes empty class definitions to improve compatibility
taher authored
82 class Render:
ff20af9 @alobbs Adds the new admin
alobbs authored
83 class PanelList (CTK.Container):
84 def __init__ (self, right_box):
85 CTK.Container.__init__ (self)
86
87 # Helpers
88 entry = lambda klass, key: CTK.Box ({'class': klass}, CTK.RawHTML (CTK.cfg.get_val(key, '')))
89 special = lambda klass, txt: CTK.Box ({'class': klass}, CTK.RawHTML (txt))
90
91 # Build the panel list
92 panel = SelectionPanel.SelectionPanel (None, right_box.id, URL_BASE, '', container='status_panel')
93 self += panel
94
95 # Build the Virtual Server list
96 vservers = CTK.cfg.keys('vserver')
97 vservers.sort (lambda x,y: cmp(int(x), int(y)))
98 vservers.reverse()
99
100 # Special Panel entries
101 content = [special('nick', _('General')),
102 special('droot', _('System wide status'))]
103 panel.Add ('general', '%s/content/general'%(URL_BASE), content, draggable=False)
104
105 # Regular list entries
106 for k in vservers:
107 content = [entry('nick', 'vserver!%s!nick'%(k))]
108 panel.Add (k, '%s/content/%s'%(URL_BASE, k), content, draggable=False)
109
110
111 def __call__ (self):
112 title = _('Status')
113
114 # Content
115 left = CTK.Box({'class': 'panel'})
116 left += CTK.RawHTML('<h2>%s</h2>'%(title))
117
118 right = CTK.Box({'class': 'status_content'})
119 left += CTK.Box({'class': 'filterbox'}, CTK.TextField({'class':'filter', 'optional_string': _('Virtual Server Filtering'), 'optional': True}))
120 left += CTK.Box ({'id': 'status_panel'}, self.PanelList(right))
121
122 # Build the page
123 page = Page.Base(title, body_id='status', helps=HELPS, headers=Submit_HEADER)
124 page += left
125 page += right
126
127 return page.Render()
128
129
130 CTK.publish (r'^%s$' %(URL_BASE), Render)
131 CTK.publish ('^%s/content/[\d]+$' %(URL_BASE), Render_Content)
132 CTK.publish ('^%s/content/general$'%(URL_BASE), Render_Content)
Something went wrong with that request. Please try again.