def get_ui(self): ui = self.app.inflate('sysmon:main') self._mgr = apis.dashboard.WidgetManager(self.app) self._mgr.refresh() self._failed = [] self.fill('l', self._mgr.list_left(), ui, 'cleft') self.fill('r', self._mgr.list_right(), ui, 'cright') if self._failed != []: ui.find('ui-dashboard-buttons').append( UI.Button(id='btnCleanUp', text='Clean Up', iconfont='gen-remove')) ui.insertText('host', platform.node()) ui.insertText('distro', detect_distro()) ui.find('icon').set( 'src', '/dl/sysmon/distributor-logo-%s.png' % detect_platform(mapping=False)) if self._adding_widget == True: dlg = self.app.inflate('sysmon:add-widget') idx = 0 for prov in sorted(self.app.grab_plugins(apis.dashboard.IWidget)): if hasattr(prov, 'hidden'): continue dlg.append( 'list', UI.ListItem( UI.HContainer( UI.IconFont(iconfont=prov.iconfont), UI.Label(text=' ' + prov.name), ), id=prov.plugin_id, )) idx += 1 ui.append('main', dlg) elif self._adding_widget != None: ui.append( 'main', self._mgr.get_by_name(self._adding_widget).get_config_dialog()) if UpdateCheck.get().get_status()[0] == True: self.put_message( 'info', 'An update for Genesis is available. See the Settings pane for details.' ) return ui
def get_ui(self): from genesis.plugins.security.firewall import RuleManager, FWMonitor mgr = self.app.get_backend(apis.services.IServiceManager) rum = RuleManager(self.app) self._rules_list = rum.get_by_plugin(self.plugin_id) fwm = FWMonitor(self.app) res = UI.DT(UI.DTR(UI.DTH(width=20), UI.DTH(UI.Label(text='Service')), UI.DTH(width=20), header=True), width='100%', noborder=True) alert = False services = self.plugin_info.services if hasattr( self.plugin_info, 'services') else self.services for s in services: ctl = UI.HContainer() try: st = mgr.get_status(s['binary']) except: st = 'failed' alert = True try: en = mgr.get_enabled(s['binary']) except: en = 'failed' if st == 'running': ctl.append( UI.TipIcon(text='Stop', cls='servicecontrol', iconfont='gen-stop', id='stop/' + s['binary'])) ctl.append( UI.TipIcon(text='Restart', cls='servicecontrol', iconfont='gen-loop-2', id='restart/' + s['binary'])) else: ctl.append( UI.TipIcon(text='Start', cls='servicecontrol', iconfont='gen-play-2', id='start/' + s['binary'])) alert = True if en == 'enabled': ctl.append( UI.TipIcon(text='Disable', cls='servicecontrol', iconfont='gen-minus-circle', id='disable/' + s['binary'])) else: ctl.append( UI.TipIcon(text='Enable', cls='servicecontrol', iconfont='gen-plus-circle', id='enable/' + s['binary'])) t = UI.DTR( UI.HContainer( UI.IconFont(iconfont='gen-' + ('play-2' if st == 'running' else 'stop')), UI.IconFont( iconfont='gen-' + ('checkmark' if en == 'enabled' else 'close-2')), ), UI.Label(text='%s (%s)' % (s['name'], s['binary'])), ctl) res.append(t) ptalert = False if self._rules_list != []: pts = UI.DT(UI.DTR(UI.DTH(width=20), UI.DTH(UI.Label(text='Application')), UI.DTH(UI.Label(text='Ports')), UI.DTH(UI.Label(text='Authorization')), UI.DTH(width=20), header=True), width='100%', noborder=True) for p in self._rules_list: if p[1] == 1: perm, ic, show = 'Local', 'gen-home', [2, 0] elif p[1] == 2: perm, ic, show = 'All', 'gen-earth', [1, 0] else: perm, ic, show = 'None', 'gen-close', [2, 1] ptalert = True pts.append( UI.DTR( UI.IconFont(iconfont=p[0].icon), UI.Label(text=p[0].name), UI.Label(text=', '.join( str(x[1]) for x in p[0].ports)), UI.HContainer( UI.IconFont(iconfont=ic), UI.Label(text=' '), UI.Label(text=perm), ), UI.HContainer( (UI.TipIcon(iconfont='gen-earth', text='Allow All', cls='servicecontrol', id='2/' + str(self._rules_list.index(p))) if 2 in show else None), (UI.TipIcon(iconfont='gen-home', text='Local Only', cls='servicecontrol', id='1/' + str(self._rules_list.index(p))) if 1 in show else None), (UI.TipIcon( iconfont='gen-close', text='Deny All', cls='servicecontrol', id='0/' + str(self._rules_list.index(p)), warning= 'Are you sure you wish to deny all access to %s? ' 'This will prevent anyone (including you) from connecting to it.' % p[0].name) if 0 in show else None), ), )) panel = UI.ServicePluginPanel( alert=('True' if alert else 'False'), ports=('True' if self._rules_list != [] else 'False'), ptalert=('True' if ptalert else 'False'), ) if self.display: dlg = UI.DialogBox(UI.ScrollContainer(res, width=300, height=300), id='dlgServices', hidecancel='True') return UI.Container(panel, dlg, self.get_main_ui()) elif self.disports: dlg = UI.DialogBox(UI.ScrollContainer(pts, width=300, height=300), id='dlgPorts', hidecancel='True') return UI.Container(panel, dlg, self.get_main_ui()) else: return UI.Container(panel, self.get_main_ui())