def __init__(self): CTK.Container.__init__(self) # Build the panel list right_box = CTK.Box({'class': 'vserver_new_content'}) panel = SelectionPanel.SelectionPanel(None, right_box.id, URL_BASE, '', cookie_name='new_vsrv_selected') self += panel self += right_box # Special 1st: Manual content = [ CTK.Box({'class': 'title'}, CTK.RawHTML(_('Manual'))), CTK.Box({'class': 'description'}, CTK.RawHTML(_('Manual configuration'))) ] panel.Add('manual', URL_NEW_MANUAL, content, draggable=False) # Wizard Categories for cat in Wizard.Categories(Wizard.TYPE_VSERVER): url_pre = '%s/%s' % (Wizard.URL_CAT_LIST_VSRV, cat['name']) title, descr = cat['title'], cat['descr'] content = [ CTK.Box({'class': 'title'}, CTK.RawHTML(_(title))), CTK.Box({'class': 'description'}, CTK.RawHTML(_(descr))) ] panel.Add(cat['name'], url_pre, content, draggable=False)
def __init__ (self): CTK.Container.__init__ (self) # Build the panel list right_box = CTK.Box({'class': 'vserver_new_content'}) panel = SelectionPanel.SelectionPanel (None, right_box.id, URL_BASE, '', draggable=False, cookie_name='new_vsrv_selected') self += panel self += right_box # Special 1st: Manual content = [CTK.Box({'class': 'title'}, CTK.RawHTML(_('Manual'))), CTK.Box({'class': 'description'}, CTK.RawHTML(_('Manual configuration')))] panel.Add ('manual', URL_NEW_MANUAL, content, draggable=False) # Wizard Categories wizards2_path = os.path.realpath (__file__ + "/../wizards2") if os.path.exists (wizards2_path): # Wizards 2.0 import wizards2 categories = wizards2.Categories.get() for cat in categories: url_pre = '%s/%s' %(wizards2.Categories.URL_CAT_LIST_VSRV, categories.index(cat)) content = [CTK.Box({'class': 'title'}, CTK.RawHTML(_(cat)))] panel.Add (cat.replace(' ','_'), url_pre, content, draggable=False) else: # Wizards 1.0 for cat in Wizard.Categories (Wizard.TYPE_VSERVER): url_pre = '%s/%s' %(Wizard.URL_CAT_LIST_VSRV, cat['name']) title, descr = cat['title'], cat['descr'] content = [CTK.Box({'class': 'title'}, CTK.RawHTML(_(title))), CTK.Box({'class': 'description'}, CTK.RawHTML(_(descr)))] panel.Add (cat['name'], url_pre, content, draggable=False)
def __init__ (self, right_box): CTK.Container.__init__ (self) # Helpers entry = lambda klass, key: CTK.Box ({'class': klass}, CTK.RawHTML (CTK.cfg.get_val(key, ''))) special = lambda klass, txt: CTK.Box ({'class': klass}, CTK.RawHTML (txt)) # Build the panel list panel = SelectionPanel.SelectionPanel (None, right_box.id, URL_BASE, '', container='status_panel') self += panel # Build the Virtual Server list vservers = CTK.cfg.keys('vserver') vservers.sort (lambda x,y: cmp(int(x), int(y))) vservers.reverse() # Special Panel entries content = [special('nick', _('General')), special('droot', _('System wide status'))] panel.Add ('general', '%s/content/general'%(URL_BASE), content, draggable=False) # Regular list entries for k in vservers: content = [entry('nick', 'vserver!%s!nick'%(k))] panel.Add (k, '%s/content/%s'%(URL_BASE, k), content, draggable=False)
def __init__ (self, refresh, right_box): CTK.Container.__init__ (self) # Sanity check if not CTK.cfg.keys('vserver'): CTK.cfg['vserver!1!nick'] = 'default' CTK.cfg['vserver!1!document_root'] = '/tmp' CTK.cfg['vserver!1!rule!1!match'] = 'default' CTK.cfg['vserver!1!rule!1!handler'] = 'common' # Helper entry = lambda klass, key: CTK.Box ({'class': klass}, CTK.RawHTML (CTK.escape_html (CTK.cfg.get_val(key, '')))) # Build the panel list panel = SelectionPanel.SelectionPanel (reorder, right_box.id, URL_BASE, '', container='vservers_panel') self += panel # Build the Virtual Server list vservers = CTK.cfg.keys('vserver') vservers.sort (lambda x,y: cmp(int(x), int(y))) vservers.reverse() for k in vservers: # Document root widget droot_str = CTK.cfg.get_val ('vserver!%s!document_root'%(k), '') # Market install base scenario if self.__is_market_installation (k, droot_str): droot_widget = CTK.Box ({'class': 'droot'}, CTK.RawHTML(_('Market installation'))) else: droot_widget = CTK.Box ({'class': 'droot'}, CTK.RawHTML(CTK.escape_html (droot_str))) if k == vservers[-1]: content = [entry('nick', 'vserver!%s!nick'%(k)), droot_widget] panel.Add (k, '/vserver/content/%s'%(k), content, draggable=False) else: nick = CTK.cfg.get_val ('vserver!%s!nick'%(k), _('Unknown')) nick_esc = CTK.escape_html (nick) # Remove dialog = CTK.Dialog ({'title': _('Do you really want to remove it?'), 'width': 480}) dialog.AddButton (_('Cancel'), "close") dialog.AddButton (_('Remove'), CTK.JS.Ajax (URL_APPLY, async=True, data = {'vserver!%s'%(k):''}, success = dialog.JS_to_close() + \ refresh.JS_to_refresh())) dialog += CTK.RawHTML (_(NOTE_DELETE_DIALOG) %(locals())) self += dialog remove = CTK.ImageStock('del') remove.bind ('click', dialog.JS_to_show() + "return false;") # Disable is_disabled = bool (int (CTK.cfg.get_val('vserver!%s!disabled'%(k), "0"))) disclass = ('','vserver-inactive')[is_disabled][:] disabled = CTK.ToggleButtonOnOff (not is_disabled) disabled.bind ('changed', CTK.JS.Ajax (URL_APPLY, async=True, data = '{"vserver!%s!disabled": event.value}'%(k)))
def __init__(self, refresh, right_box): CTK.Container.__init__(self) # Helper entry = lambda klass, key: CTK.Box( {'class': klass}, CTK.RawHTML(CTK.escape_html(CTK.cfg.get_val(key, '')))) # Build the panel list panel = SelectionPanel.SelectionPanel(None, right_box.id, "/source", '%s/empty' % (URL_CONTENT), draggable=False, container='source_panel', cookie_name=COOKIE) self += panel sources = CTK.cfg.keys('source') sources.sort(lambda x, y: cmp(int(x), int(y))) self.protected_sources = _protected_sources() for k in sources: tipe = CTK.cfg.get_val('source!%s!type' % (k)) dialog = self._get_dialog(k, refresh) self += dialog remove = CTK.ImageStock('del') remove.bind('click', dialog.JS_to_show() + "return false;") group = CTK.Box({'class': 'sel-actions'}, [remove]) if tipe == 'host': panel.Add(k, '%s/%s' % (URL_CONTENT, k), [ group, entry('nick', 'source!%s!nick' % (k)), entry('type', 'source!%s!type' % (k)), entry('host', 'source!%s!host' % (k)) ]) elif tipe == 'interpreter': panel.Add(k, '%s/%s' % (URL_CONTENT, k), [ group, entry('nick', 'source!%s!nick' % (k)), entry('type', 'source!%s!type' % (k)), entry('host', 'source!%s!host' % (k)), entry('inter', 'source!%s!interpreter' % (k)) ])
def __init__(self, refresh, right_box, vsrv_num): CTK.Container.__init__(self) url_base = '/vserver/%s/rule' % (vsrv_num) url_apply = URL_APPLY % (vsrv_num) # Build the panel list panel = SelectionPanel.SelectionPanel(reorder, right_box.id, url_base, '', container='rules_panel') self += panel # Build the Rule list rules = CTK.cfg.keys('vserver!%s!rule' % (vsrv_num)) rules.sort(lambda x, y: cmp(int(x), int(y))) rules.reverse() for r in rules: rule = Rule('vserver!%s!rule!%s!match' % (vsrv_num, r)) rule_name = rule.GetName() rule_name_esc = CTK.escape_html(rule_name) # Comment comment = [] handler = CTK.cfg.get_val('vserver!%s!rule!%s!handler' % (vsrv_num, r)) if handler: desc = filter(lambda x: x[0] == handler, HANDLERS)[0][1] comment.append(_(desc)) auth = CTK.cfg.get_val('vserver!%s!rule!%s!auth' % (vsrv_num, r)) if auth: desc = filter(lambda x: x[0] == auth, VALIDATORS)[0][1] comment.append(_(desc)) for e in CTK.cfg.keys('vserver!%s!rule!%s!encoder' % (vsrv_num, r)): val = CTK.cfg.get_val('vserver!%s!rule!%s!encoder!%s' % (vsrv_num, r, e)) if val == 'allow': comment.append(e) elif val == 'forbid': comment.append("no %s" % (e)) if CTK.cfg.get_val('vserver!%s!rule!%s!flcache' % (vsrv_num, r)) == "allow": comment.append('Cache') if CTK.cfg.get_val('vserver!%s!rule!%s!timeout' % (vsrv_num, r)): comment.append('Timeout') if CTK.cfg.get_val('vserver!%s!rule!%s!rate' % (vsrv_num, r)): comment.append('Traffic') if int( CTK.cfg.get_val( 'vserver!%s!rule!%s!no_log' % (vsrv_num, r), "0")) > 0: comment.append('No log') # List entry row_id = '%s_%s' % (r, vsrv_num) if r == rules[-1]: content = [ CTK.Box({'class': 'name'}, CTK.RawHTML(rule_name_esc)), CTK.Box({'class': 'comment'}, CTK.RawHTML(', '.join(comment))) ] panel.Add(row_id, '/vserver/%s/rule/content/%s' % (vsrv_num, r), content, draggable=False) else: # Remove dialog = CTK.Dialog({ 'title': _('Do you really want to remove it?'), 'width': 480 }) dialog.AddButton(_('Cancel'), "close") dialog.AddButton (_('Remove'), CTK.JS.Ajax (url_apply, async=False, data = {'vserver!%s!rule!%s'%(vsrv_num, r):''}, success = dialog.JS_to_close() + \ refresh.JS_to_refresh())) dialog += CTK.RawHTML( _(NOTE_DELETE_DIALOG) % (rule_name_esc)) self += dialog remove = CTK.ImageStock('del') remove.bind('click', dialog.JS_to_show() + "return false;") # Disable is_disabled = bool( int( CTK.cfg.get_val( 'vserver!%s!rule!%s!disabled' % (vsrv_num, r), "0"))) disclass = ('', 'rule-inactive')[is_disabled][:] disabled = CTK.ToggleButtonOnOff(not is_disabled) disabled.bind( 'changed', CTK.JS.Ajax( url_apply, async=True, data='{"vserver!%s!rule!%s!disabled": event.value}' % (vsrv_num, r)))