mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:15:10 +00:00
UI: Programs: Add "Notes" field
This commit is contained in:
parent
695518083d
commit
118b431245
@ -26,7 +26,8 @@ bool App::isExtraFlagsEqual(const App &o) const
|
||||
bool App::isOptionsEqual(const App &o) const
|
||||
{
|
||||
return isFlagsEqual(o) && isZonesEqual(o) && groupIndex == o.groupIndex
|
||||
&& appOriginPath == o.appOriginPath && appPath == o.appPath && endTime == o.endTime;
|
||||
&& appOriginPath == o.appOriginPath && appPath == o.appPath && notes == o.notes
|
||||
&& endTime == o.endTime;
|
||||
}
|
||||
|
||||
bool App::isNameEqual(const App &o) const
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
QString appOriginPath;
|
||||
QString appPath;
|
||||
QString appName;
|
||||
QString notes;
|
||||
|
||||
QDateTime endTime;
|
||||
QDateTime creatTime;
|
||||
|
@ -32,6 +32,8 @@ constexpr int APP_END_TIMER_INTERVAL_MAX = 24 * 60 * 60 * 1000; // 1 day
|
||||
" t.app_id," \
|
||||
" t.origin_path," \
|
||||
" t.path," \
|
||||
" t.name," \
|
||||
" t.notes," \
|
||||
" t.is_wildcard," \
|
||||
" t.use_group_perm," \
|
||||
" t.apply_child," \
|
||||
@ -44,6 +46,7 @@ constexpr int APP_END_TIMER_INTERVAL_MAX = 24 * 60 * 60 * 1000; // 1 day
|
||||
" t.kill_process," \
|
||||
" t.accept_zones," \
|
||||
" t.reject_zones," \
|
||||
" t.end_time," \
|
||||
" g.order_index as group_index," \
|
||||
" (alert.app_id IS NOT NULL) as alerted"
|
||||
|
||||
@ -69,29 +72,29 @@ const char *const sqlSelectEndedApps = "SELECT" SELECT_APP_FIELDS " FROM app t"
|
||||
|
||||
const char *const sqlSelectAppIdByPath = "SELECT app_id FROM app WHERE path = ?1;";
|
||||
|
||||
const char *const sqlUpsertApp = "INSERT INTO app(app_group_id, origin_path, path, name,"
|
||||
const char *const sqlUpsertApp = "INSERT INTO app(app_group_id, origin_path, path, name, notes,"
|
||||
" is_wildcard, use_group_perm, apply_child, kill_child,"
|
||||
" lan_only, parked, log_blocked, log_conn,"
|
||||
" blocked, kill_process, accept_zones, reject_zones,"
|
||||
" end_time, creat_time)"
|
||||
" VALUES(?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9,"
|
||||
" ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19)"
|
||||
" ?10, ?11, ?12, ?13, ?14, ?15, ?16, ?17, ?18, ?19, ?20)"
|
||||
" ON CONFLICT(path) DO UPDATE"
|
||||
" SET app_group_id = ?2, origin_path = ?3, name = ?5,"
|
||||
" is_wildcard = ?6, use_group_perm = ?7,"
|
||||
" apply_child = ?8, kill_child = ?9, lan_only = ?10,"
|
||||
" parked = ?11, log_blocked = ?12, log_conn = ?13,"
|
||||
" blocked = ?14, kill_process = ?15,"
|
||||
" accept_zones = ?16, reject_zones = ?17, end_time = ?18"
|
||||
" notes = ?6, is_wildcard = ?7, use_group_perm = ?8,"
|
||||
" apply_child = ?9, kill_child = ?10, lan_only = ?11,"
|
||||
" parked = ?12, log_blocked = ?13, log_conn = ?14,"
|
||||
" blocked = ?15, kill_process = ?16,"
|
||||
" accept_zones = ?17, reject_zones = ?18, end_time = ?19"
|
||||
" RETURNING app_id;";
|
||||
|
||||
const char *const sqlUpdateApp = "UPDATE app"
|
||||
" SET app_group_id = ?2, origin_path = ?3, path = ?4,"
|
||||
" name = ?5, is_wildcard = ?6, use_group_perm = ?7,"
|
||||
" apply_child = ?8, kill_child = ?9, lan_only = ?10,"
|
||||
" parked = ?11, log_blocked = ?12, log_conn = ?13,"
|
||||
" blocked = ?14, kill_process = ?15,"
|
||||
" accept_zones = ?16, reject_zones = ?17, end_time = ?18"
|
||||
" SET app_group_id = ?2, origin_path = ?3, path = ?4, name = ?5,"
|
||||
" notes = ?6, is_wildcard = ?7, use_group_perm = ?8,"
|
||||
" apply_child = ?9, kill_child = ?10, lan_only = ?11,"
|
||||
" parked = ?12, log_blocked = ?13, log_conn = ?14,"
|
||||
" blocked = ?15, kill_process = ?16,"
|
||||
" accept_zones = ?17, reject_zones = ?18, end_time = ?19"
|
||||
" WHERE app_id = ?1"
|
||||
" RETURNING app_id;";
|
||||
|
||||
@ -196,10 +199,11 @@ void ConfAppManager::beginAddOrUpdateApp(
|
||||
{
|
||||
const auto vars = QVariantList()
|
||||
<< app.appId << appGroup.id() << app.appOriginPath
|
||||
<< (!app.appPath.isEmpty() ? app.appPath : QVariant()) << app.appName << app.isWildcard
|
||||
<< app.useGroupPerm << app.applyChild << app.killChild << app.lanOnly << app.parked
|
||||
<< app.logBlocked << app.logConn << app.blocked << app.killProcess << app.acceptZones
|
||||
<< app.rejectZones << (!app.endTime.isNull() ? app.endTime : QVariant())
|
||||
<< (!app.appPath.isEmpty() ? app.appPath : QVariant()) << app.appName << app.notes
|
||||
<< app.isWildcard << app.useGroupPerm << app.applyChild << app.killChild << app.lanOnly
|
||||
<< app.parked << app.logBlocked << app.logConn << app.blocked << app.killProcess
|
||||
<< app.acceptZones << app.rejectZones
|
||||
<< (!app.endTime.isNull() ? app.endTime : QVariant())
|
||||
<< (onlyUpdate ? QVariant() : QDateTime::currentDateTime());
|
||||
|
||||
const char *sql = onlyUpdate ? sqlUpdateApp : sqlUpsertApp;
|
||||
@ -575,20 +579,23 @@ void ConfAppManager::fillApp(App &app, const SqliteStmt &stmt)
|
||||
app.appId = stmt.columnInt64(0);
|
||||
app.appOriginPath = stmt.columnText(1);
|
||||
app.appPath = stmt.columnText(2);
|
||||
app.isWildcard = stmt.columnBool(3);
|
||||
app.useGroupPerm = stmt.columnBool(4);
|
||||
app.applyChild = stmt.columnBool(5);
|
||||
app.killChild = stmt.columnBool(6);
|
||||
app.lanOnly = stmt.columnBool(7);
|
||||
app.parked = stmt.columnBool(8);
|
||||
app.logBlocked = stmt.columnBool(9);
|
||||
app.logConn = stmt.columnBool(10);
|
||||
app.blocked = stmt.columnBool(11);
|
||||
app.killProcess = stmt.columnBool(12);
|
||||
app.acceptZones = stmt.columnUInt(13);
|
||||
app.rejectZones = stmt.columnUInt(14);
|
||||
app.groupIndex = stmt.columnInt(15);
|
||||
app.alerted = stmt.columnBool(16);
|
||||
app.appName = stmt.columnText(3);
|
||||
app.notes = stmt.columnText(4);
|
||||
app.isWildcard = stmt.columnBool(5);
|
||||
app.useGroupPerm = stmt.columnBool(6);
|
||||
app.applyChild = stmt.columnBool(7);
|
||||
app.killChild = stmt.columnBool(8);
|
||||
app.lanOnly = stmt.columnBool(9);
|
||||
app.parked = stmt.columnBool(10);
|
||||
app.logBlocked = stmt.columnBool(11);
|
||||
app.logConn = stmt.columnBool(12);
|
||||
app.blocked = stmt.columnBool(13);
|
||||
app.killProcess = stmt.columnBool(14);
|
||||
app.acceptZones = stmt.columnUInt(15);
|
||||
app.rejectZones = stmt.columnUInt(16);
|
||||
app.endTime = stmt.columnDateTime(17);
|
||||
app.groupIndex = stmt.columnInt(18);
|
||||
app.alerted = stmt.columnBool(19);
|
||||
}
|
||||
|
||||
bool ConfAppManager::updateDriverDeleteApp(const QString &appPath)
|
||||
|
@ -32,7 +32,7 @@ namespace {
|
||||
|
||||
const QLoggingCategory LC("conf");
|
||||
|
||||
constexpr int DATABASE_USER_VERSION = 29;
|
||||
constexpr int DATABASE_USER_VERSION = 30;
|
||||
|
||||
const char *const sqlSelectAddressGroups = "SELECT addr_group_id, include_all, exclude_all,"
|
||||
" include_zones, exclude_zones,"
|
||||
|
@ -126,6 +126,7 @@ CREATE TABLE app(
|
||||
origin_path TEXT,
|
||||
path TEXT,
|
||||
name TEXT,
|
||||
notes TEXT,
|
||||
is_wildcard BOOLEAN NOT NULL DEFAULT 0,
|
||||
use_group_perm BOOLEAN NOT NULL DEFAULT 1,
|
||||
apply_child BOOLEAN NOT NULL DEFAULT 0,
|
||||
|
@ -131,6 +131,8 @@ void ProgramEditDialog::initializeNameField(bool isSingleSelection, bool isPathE
|
||||
m_editName->setEnabled(isSingleSelection);
|
||||
m_editName->setClearButtonEnabled(isSingleSelection);
|
||||
m_btGetName->setEnabled(isSingleSelection);
|
||||
m_editNotes->setText(m_appRow.notes);
|
||||
m_editNotes->setEnabled(isSingleSelection);
|
||||
}
|
||||
|
||||
void ProgramEditDialog::activate()
|
||||
@ -156,11 +158,13 @@ void ProgramEditDialog::retranslateUi()
|
||||
|
||||
m_labelEditPath->setText(isWildcard() ? tr("Wildcard Paths:") : tr("File Path:"));
|
||||
retranslatePathPlaceholderText();
|
||||
|
||||
m_btSelectFile->setToolTip(tr("Select File"));
|
||||
|
||||
m_labelEditName->setText(tr("Name:"));
|
||||
m_btGetName->setToolTip(tr("Get Program Name"));
|
||||
|
||||
m_labelEditNotes->setText(tr("Notes:"));
|
||||
|
||||
m_labelAppGroup->setText(tr("Application Group:"));
|
||||
m_cbUseGroupPerm->setText(tr("Use Application Group's Enabled State"));
|
||||
m_cbApplyChild->setText(tr("Apply same rules to child processes"));
|
||||
@ -289,15 +293,21 @@ QLayout *ProgramEditDialog::setupAppLayout()
|
||||
// App Path
|
||||
auto pathLayout = setupAppPathLayout();
|
||||
|
||||
layout->addRow("Program Path:", pathLayout);
|
||||
layout->addRow("File Path:", pathLayout);
|
||||
m_labelEditPath = qobject_cast<QLabel *>(layout->labelForField(pathLayout));
|
||||
|
||||
// App Name
|
||||
auto nameLayout = setupAppNameLayout();
|
||||
|
||||
layout->addRow("Program Name:", nameLayout);
|
||||
layout->addRow("Name:", nameLayout);
|
||||
m_labelEditName = qobject_cast<QLabel *>(layout->labelForField(nameLayout));
|
||||
|
||||
// Notes
|
||||
auto notesLayout = setupNotesLayout();
|
||||
|
||||
layout->addRow("Notes:", notesLayout);
|
||||
m_labelEditNotes = qobject_cast<QLabel *>(layout->labelForField(notesLayout));
|
||||
|
||||
// App Group
|
||||
setupComboAppGroups();
|
||||
|
||||
@ -360,16 +370,23 @@ QLayout *ProgramEditDialog::setupAppPathLayout()
|
||||
|
||||
QLayout *ProgramEditDialog::setupAppNameLayout()
|
||||
{
|
||||
auto layout = new QHBoxLayout();
|
||||
|
||||
m_editName = new QLineEdit();
|
||||
m_editName->setMaxLength(1024);
|
||||
|
||||
m_btGetName = ControlUtil::createIconToolButton(
|
||||
":/icons/arrow_refresh_small.png", [&] { fillEditName(); });
|
||||
|
||||
layout->addWidget(m_editName);
|
||||
layout->addWidget(m_btGetName);
|
||||
auto layout = ControlUtil::createHLayoutByWidgets({ m_editName, m_btGetName });
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
QLayout *ProgramEditDialog::setupNotesLayout()
|
||||
{
|
||||
m_editNotes = new PlainTextEdit();
|
||||
m_editNotes->setFixedHeight(40);
|
||||
|
||||
auto layout = ControlUtil::createHLayoutByWidgets({ m_editNotes });
|
||||
|
||||
return layout;
|
||||
}
|
||||
@ -610,6 +627,7 @@ void ProgramEditDialog::fillApp(App &app) const
|
||||
app.killProcess = m_rbKillProcess->isChecked();
|
||||
app.groupIndex = m_comboAppGroup->currentIndex();
|
||||
app.appName = m_editName->text();
|
||||
app.notes = m_editNotes->toPlainText();
|
||||
|
||||
app.acceptZones = m_btZones->zones();
|
||||
app.rejectZones = m_btZones->uncheckedZones();
|
||||
|
@ -55,6 +55,7 @@ private:
|
||||
QLayout *setupAppLayout();
|
||||
QLayout *setupAppPathLayout();
|
||||
QLayout *setupAppNameLayout();
|
||||
QLayout *setupNotesLayout();
|
||||
void setupComboAppGroups();
|
||||
QLayout *setupLogLayout();
|
||||
QLayout *setupAllowLayout();
|
||||
@ -87,6 +88,8 @@ private:
|
||||
QLabel *m_labelEditName = nullptr;
|
||||
QLineEdit *m_editName = nullptr;
|
||||
QToolButton *m_btGetName = nullptr;
|
||||
QLabel *m_labelEditNotes = nullptr;
|
||||
PlainTextEdit *m_editNotes = nullptr;
|
||||
QLabel *m_labelAppGroup = nullptr;
|
||||
QComboBox *m_comboAppGroup = nullptr;
|
||||
QCheckBox *m_cbUseGroupPerm = nullptr;
|
||||
|
@ -451,7 +451,6 @@ void ProgramsWindow::openAppEditForm(const AppRow &appRow, const QVector<qint64>
|
||||
{
|
||||
m_formAppEdit->initialize(appRow, appIdList);
|
||||
|
||||
m_formAppEdit->show();
|
||||
m_formAppEdit->activate();
|
||||
}
|
||||
|
||||
|
@ -322,10 +322,10 @@ bool AppListModel::updateAppRow(const QString &sql, const QVariantList &vars, Ap
|
||||
}
|
||||
|
||||
appRow.appId = stmt.columnInt64(0);
|
||||
appRow.groupIndex = stmt.columnInt(1);
|
||||
appRow.appOriginPath = stmt.columnText(2);
|
||||
appRow.appPath = stmt.columnText(3);
|
||||
appRow.appName = stmt.columnText(4);
|
||||
appRow.appOriginPath = stmt.columnText(1);
|
||||
appRow.appPath = stmt.columnText(2);
|
||||
appRow.appName = stmt.columnText(3);
|
||||
appRow.notes = stmt.columnText(4);
|
||||
appRow.isWildcard = stmt.columnBool(5);
|
||||
appRow.useGroupPerm = stmt.columnBool(6);
|
||||
appRow.applyChild = stmt.columnBool(7);
|
||||
@ -338,9 +338,10 @@ bool AppListModel::updateAppRow(const QString &sql, const QVariantList &vars, Ap
|
||||
appRow.killProcess = stmt.columnBool(14);
|
||||
appRow.acceptZones = stmt.columnUInt(15);
|
||||
appRow.rejectZones = stmt.columnUInt(16);
|
||||
appRow.alerted = stmt.columnBool(17);
|
||||
appRow.endTime = stmt.columnDateTime(18);
|
||||
appRow.creatTime = stmt.columnDateTime(19);
|
||||
appRow.endTime = stmt.columnDateTime(17);
|
||||
appRow.creatTime = stmt.columnDateTime(18);
|
||||
appRow.groupIndex = stmt.columnInt(19);
|
||||
appRow.alerted = stmt.columnBool(20);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -391,10 +392,10 @@ QString AppListModel::sqlBase() const
|
||||
{
|
||||
return "SELECT"
|
||||
" t.app_id,"
|
||||
" g.order_index as group_index,"
|
||||
" t.origin_path,"
|
||||
" t.path,"
|
||||
" t.name,"
|
||||
" t.notes,"
|
||||
" t.is_wildcard,"
|
||||
" t.use_group_perm,"
|
||||
" t.apply_child,"
|
||||
@ -407,9 +408,10 @@ QString AppListModel::sqlBase() const
|
||||
" t.kill_process,"
|
||||
" t.accept_zones,"
|
||||
" t.reject_zones,"
|
||||
" (alert.app_id IS NOT NULL) as alerted,"
|
||||
" t.end_time,"
|
||||
" t.creat_time"
|
||||
" t.creat_time,"
|
||||
" g.order_index as group_index,"
|
||||
" (alert.app_id IS NOT NULL) as alerted"
|
||||
" FROM app t"
|
||||
" JOIN app_group g ON g.app_group_id = t.app_group_id"
|
||||
" LEFT JOIN app_alert alert ON alert.app_id = t.app_id";
|
||||
|
@ -59,7 +59,7 @@ QVariantList ConfAppManagerRpc::appToVarList(const App &app)
|
||||
return { app.isWildcard, app.useGroupPerm, app.applyChild, app.killChild, app.lanOnly,
|
||||
app.parked, app.logBlocked, app.logConn, app.blocked, app.killProcess, app.groupIndex,
|
||||
app.acceptZones, app.rejectZones, app.appId, app.appOriginPath, app.appPath, app.appName,
|
||||
app.endTime };
|
||||
app.notes, app.endTime };
|
||||
}
|
||||
|
||||
App ConfAppManagerRpc::varListToApp(const QVariantList &v)
|
||||
@ -82,6 +82,7 @@ App ConfAppManagerRpc::varListToApp(const QVariantList &v)
|
||||
app.appOriginPath = v.value(14).toString();
|
||||
app.appPath = v.value(15).toString();
|
||||
app.appName = v.value(16).toString();
|
||||
app.endTime = v.value(17).toDateTime();
|
||||
app.notes = v.value(17).toString();
|
||||
app.endTime = v.value(18).toDateTime();
|
||||
return app;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user