mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
ui: allow to configure refresh interval
Up until now, the GUI was refreshed if: - it was not minimized or hidden. - if there were new events (even if we received events from the daemon, they were filtered out if they were duplicated). But still, there were scenarios where refreshing the views every second (more or less) was too much, like when monitoring multiple machines. Now it's possible to configure the views' refresh interval, regardless of what the daemon sends. Asked here: #1073
This commit is contained in:
parent
6873fd3a2d
commit
6006717b86
4 changed files with 168 additions and 58 deletions
|
@ -122,6 +122,7 @@ class Config:
|
|||
NOTIFICATION_TYPE_SYSTEM = 0
|
||||
NOTIFICATION_TYPE_QT = 1
|
||||
|
||||
STATS_UPDATE_INTERVAL = "statsDialog/update_interval"
|
||||
STATS_GEOMETRY = "statsDialog/geometry"
|
||||
STATS_LAST_TAB = "statsDialog/last_tab"
|
||||
STATS_FILTER_TEXT = "statsDialog/general_filter_text"
|
||||
|
|
|
@ -88,6 +88,8 @@ class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self.comboUITheme.currentIndexChanged.connect(self._cb_combo_themes_changed)
|
||||
self.cmdTimeoutUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinUITimeout, self.SUM))
|
||||
self.cmdTimeoutDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinUITimeout, self.REST))
|
||||
self.cmdRefreshUIUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinUIRefresh, self.SUM))
|
||||
self.cmdRefreshUIDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinUIRefresh, self.REST))
|
||||
self.cmdDBMaxDaysUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBMaxDays, self.SUM))
|
||||
self.cmdDBMaxDaysDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBMaxDays, self.REST))
|
||||
self.cmdDBPurgesUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBPurgeInterval, self.SUM))
|
||||
|
@ -133,6 +135,8 @@ class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
|
||||
self.cmdTimeoutUp.setIcon(addIcon)
|
||||
self.cmdTimeoutDown.setIcon(delIcon)
|
||||
self.cmdRefreshUIUp.setIcon(addIcon)
|
||||
self.cmdRefreshUIDown.setIcon(delIcon)
|
||||
self.cmdDBMaxDaysUp.setIcon(addIcon)
|
||||
self.cmdDBMaxDaysDown.setIcon(delIcon)
|
||||
self.cmdDBPurgesUp.setIcon(addIcon)
|
||||
|
@ -261,6 +265,9 @@ class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self.comboUIDuration.setCurrentIndex(self._default_duration)
|
||||
self.comboUIDialogPos.setCurrentIndex(self._cfg.getInt(self._cfg.DEFAULT_POPUP_POSITION))
|
||||
|
||||
self._ui_refresh_interval = self._cfg.getInt(self._cfg.STATS_REFRESH_INTERVAL, 0)
|
||||
self.spinUIRefresh.setValue(self._ui_refresh_interval)
|
||||
|
||||
self.checkAutostart.setChecked(self._autostart.isEnabled())
|
||||
|
||||
maxmsgsize = self._cfg.getSettings(Config.DEFAULT_SERVER_MAX_MESSAGE_LENGTH)
|
||||
|
@ -601,6 +608,7 @@ class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
if self.checkUIRules.isChecked():
|
||||
self._nodes.delete_rule_by_field(Config.DURATION_FIELD, Config.RULES_DURATION_FILTER)
|
||||
|
||||
self._cfg.setSettings(self._cfg.STATS_REFRESH_INTERVAL, int(self.spinUIRefresh.value()))
|
||||
self._cfg.setSettings(self._cfg.DEFAULT_ACTION_KEY, self.comboUIAction.currentIndex())
|
||||
self._cfg.setSettings(self._cfg.DEFAULT_DURATION_KEY, int(self.comboUIDuration.currentIndex()))
|
||||
self._cfg.setSettings(self._cfg.DEFAULT_TARGET_KEY, self.comboUITarget.currentIndex())
|
||||
|
|
|
@ -339,6 +339,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self._rules.updated.connect(self._cb_app_rules_updated)
|
||||
self._actions = Actions().instance()
|
||||
self._actions.loadAll()
|
||||
self._last_update = datetime.datetime.now()
|
||||
|
||||
# TODO: allow to display multiples dialogs
|
||||
self._proc_details_dialog = ProcessDetailsDialog(appicon=appicon)
|
||||
|
@ -718,6 +719,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self.TABLES[idx]['cmdCleanStats'].setIcon(clearIcon)
|
||||
|
||||
def _load_settings(self):
|
||||
self._ui_refresh_interval = self._cfg.getInt(Config.STATS_REFRESH_INTERVAL, 0)
|
||||
dialog_geometry = self._cfg.getSettings(Config.STATS_GEOMETRY)
|
||||
dialog_last_tab = self._cfg.getSettings(Config.STATS_LAST_TAB)
|
||||
dialog_general_filter_text = self._cfg.getSettings(Config.STATS_FILTER_TEXT)
|
||||
|
@ -2517,6 +2519,7 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
|
||||
@QtCore.pyqtSlot()
|
||||
def _on_settings_saved(self):
|
||||
self._ui_refresh_interval = self._cfg.getInt(Config.STATS_REFRESH_INTERVAL, 0)
|
||||
self._show_columns()
|
||||
self.settings_saved.emit()
|
||||
|
||||
|
@ -2699,6 +2702,13 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
else:
|
||||
self._update_status_label(running=False, text=self.FIREWALL_DISABLED)
|
||||
|
||||
def _needs_refresh(self):
|
||||
diff = datetime.datetime.now() - self._last_update
|
||||
if diff.seconds < self._ui_refresh_interval:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# launched from a thread
|
||||
def update(self, is_local=True, stats=None, need_query_update=True):
|
||||
# lock mandatory when there're multiple clients
|
||||
|
@ -2706,8 +2716,9 @@ class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
if stats is not None:
|
||||
self._stats = stats
|
||||
# do not update any tab if the window is not visible
|
||||
if self.isVisible() and self.isMinimized() == False:
|
||||
if self.isVisible() and self.isMinimized() == False and self._needs_refresh():
|
||||
self._trigger.emit(is_local, need_query_update)
|
||||
self._last_update = datetime.datetime.now()
|
||||
|
||||
def update_status(self):
|
||||
self.startButton.setDown(self.daemon_connected)
|
||||
|
|
|
@ -14,13 +14,6 @@
|
|||
<string>Preferences</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
|
@ -589,7 +582,7 @@
|
|||
<string>UI</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QToolBox" name="toolBox_2">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
|
@ -606,46 +599,24 @@
|
|||
<attribute name="label">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_14">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="labelThemeError">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboUILang"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboUITheme">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>System</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_27">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh interval (seconds)</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_21">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -658,7 +629,45 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboUITheme">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>System</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelThemeError">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="comboUILang"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="checkAutostart">
|
||||
<property name="toolTip">
|
||||
<string>By default the GUI is started when login</string>
|
||||
|
@ -671,6 +680,78 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdRefreshUIUp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="list-add">
|
||||
<normaloff>../../../../../../../../../../../../../../.designer/backup</normaloff>../../../../../../../../../../../../../../.designer/backup</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinUIRefresh">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cmdRefreshUIDown">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="list-remove">
|
||||
<normaloff>../../../../../../../../../../../../../../.designer/backup</normaloff>../../../../../../../../../../../../../../.designer/backup</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_6">
|
||||
|
@ -678,8 +759,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>259</width>
|
||||
<height>157</height>
|
||||
<width>586</width>
|
||||
<height>270</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
|
@ -762,7 +843,9 @@
|
|||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_24">
|
||||
<property name="toolTip">
|
||||
<string><p>Simple: no authentication, TLS simple/mutual: use SSL certificates to authenticate nodes.</p><p>Visit the wiki for more information.</p></string>
|
||||
<string><p>Simple: no authentication</p>
|
||||
<p>TLS simple/mutual: use SSL certificates to authenticate nodes.</p>
|
||||
<p>Visit the wiki for more information.</p></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Authentication type</string>
|
||||
|
@ -783,8 +866,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>321</width>
|
||||
<height>112</height>
|
||||
<width>586</width>
|
||||
<height>264</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
|
@ -879,8 +962,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>219</width>
|
||||
<height>115</height>
|
||||
<width>586</width>
|
||||
<height>264</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
|
@ -1643,8 +1726,8 @@ Temporary rules will still be valid, and you can use them when prompted to allow
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>586</width>
|
||||
<height>200</height>
|
||||
<width>226</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
|
@ -2045,6 +2128,13 @@ Temporary rules will still be valid, and you can use them when prompted to allow
|
|||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="statusLabel">
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
Loading…
Add table
Reference in a new issue