Hi,
Here is partial patch to have colored lines for backends. I followed Dave's
proposition:
Say green for running OK, orange for running, but with the query time being
past a configurable limit, blue for idle, and red when waiting for a lock etc.
The patch is not complete because of these:
* Shouldn't the colors be customizable? I can add a tab on frmOptions.
* Where do I put the configuration of the time limit? on a toolbar of the
frmStatus window, or in the frmOptions dialog?
Comments welcomed :)
Thanks.
--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com
Index: pgadmin/include/frm/frmStatus.h
===================================================================
--- pgadmin/include/frm/frmStatus.h (révision 8034)
+++ pgadmin/include/frm/frmStatus.h (copie de travail)
@@ -47,6 +47,7 @@
MNU_TERMINATE,
MNU_COMMIT,
MNU_ROLLBACK,
+ MNU_HIGHLIGHTSTATUS,
TIMER_REFRESHUI_ID,
TIMER_STATUS_ID,
TIMER_LOCKS_ID,
@@ -145,6 +146,7 @@
void OnToggleLogPane(wxCommandEvent& event);
void OnToggleToolBar(wxCommandEvent& event);
void OnDefaultView(wxCommandEvent& event);
+ void OnHighlightStatus(wxCommandEvent& event);
void OnRefreshUITimer(wxTimerEvent &event);
void OnRefreshStatusTimer(wxTimerEvent &event);
Index: pgadmin/frm/frmStatus.cpp
===================================================================
--- pgadmin/frm/frmStatus.cpp (révision 8034)
+++ pgadmin/frm/frmStatus.cpp (copie de travail)
@@ -52,6 +52,7 @@
EVT_MENU(MNU_LOGPAGE, frmStatus::OnToggleLogPane)
EVT_MENU(MNU_TOOLBAR, frmStatus::OnToggleToolBar)
EVT_MENU(MNU_DEFAULTVIEW, frmStatus::OnDefaultView)
+ EVT_MENU(MNU_HIGHLIGHTSTATUS, frmStatus::OnHighlightStatus)
EVT_AUI_PANE_CLOSE( frmStatus::OnPaneClose)
@@ -146,6 +147,8 @@
frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn) : pgFrame(NULL, _title)
{
+ bool highlight = false;
+
dlgName = wxT("frmStatus");
loaded = false;
@@ -192,6 +195,7 @@
viewMenu->Append(MNU_LOGPAGE, _("Log&file\tCtrl-Alt-F"), _("Show or hide the logfile tab."), wxITEM_CHECK);
viewMenu->AppendSeparator();
viewMenu->Append(MNU_TOOLBAR, _("Tool&bar\tCtrl-Alt-B"), _("Show or hide the toolbar."), wxITEM_CHECK);
+ viewMenu->Append(MNU_HIGHLIGHTSTATUS, _("Highlight items of the activity list"), _("Highlight or not the items of the activity list."), wxITEM_CHECK);
viewMenu->AppendSeparator();
viewMenu->Append(MNU_DEFAULTVIEW, _("&Default view\tCtrl-Alt-V"), _("Restore the default view."));
@@ -282,6 +286,10 @@
viewMenu->Check(MNU_XACTPAGE, manager.GetPane(wxT("Transactions")).IsShown());
viewMenu->Check(MNU_LOGPAGE, manager.GetPane(wxT("Logfile")).IsShown());
viewMenu->Check(MNU_TOOLBAR, manager.GetPane(wxT("toolBar")).IsShown());
+
+ // Read the highlight status checkbox
+ settings->Read(wxT("frmStatus/HighlightStatus"), &highlight, true);
+ viewMenu->Check(MNU_HIGHLIGHTSTATUS, highlight);
// Get our PID
backend_pid = connection->GetBackendPID();
@@ -310,6 +318,9 @@
settings->Write(wxT("frmStatus/Perspective-") + VerFromRev(FRMSTATUS_PERSPECTIVE_VER), manager.SavePerspective());
manager.UnInit();
SavePosition();
+
+ // Save the highlight status checkbox
+ settings->Write(wxT("frmStatus/HighlightStatus"), viewMenu->IsChecked(MNU_HIGHLIGHTSTATUS));
// For each current page, save the slider's position and delete the timer
settings->Write(wxT("frmStatus/RefreshStatusRate"), statusRate);
@@ -850,6 +861,14 @@
}
+void frmStatus::OnHighlightStatus(wxCommandEvent& event)
+{
+ wxTimerEvent evt;
+
+ OnRefreshStatusTimer(evt);
+}
+
+
void frmStatus::OnHelp(wxCommandEvent& event)
{
wxString page;
@@ -970,7 +989,11 @@
connection->ExecuteVoid(wxT("SET log_statement='none';SET log_duration='off';"),false);
long row=0;
- pgSet *dataSet1=connection->ExecuteSet(wxT("SELECT *,(SELECT min(pid) FROM pg_locks l1 WHERE GRANTED AND relation IN (SELECT relation FROM pg_locks l2 WHERE l2.pid=procpid AND NOT granted)) AS blockedby FROM pg_stat_activity ORDER BY procpid"));
+ pgSet *dataSet1=connection->ExecuteSet(wxT("SELECT *, ")
+ wxT("CASE WHEN query_start IS NULL THEN false ELSE query_start + '10 seconds'::interval > now() END AS slowquery, ")
+ wxT("(SELECT min(pid) FROM pg_locks l1 WHERE GRANTED AND relation IN ")
+ wxT("(SELECT relation FROM pg_locks l2 WHERE l2.pid=procpid AND NOT granted)) AS blockedby ")
+ wxT("FROM pg_stat_activity ORDER BY procpid"));
if (dataSet1)
{
statusList->Freeze();
@@ -1024,6 +1047,21 @@
statusList->SetItem(row, colpos++, dataSet1->GetVal(wxT("blockedby")));
statusList->SetItem(row, colpos, qry.Left(250));
+
+ // Colorize the new line
+ if (viewMenu->IsChecked(MNU_HIGHLIGHTSTATUS))
+ {
+ statusList->SetItemBackgroundColour(row, *wxGREEN);
+ if (qry == wxT("<IDLE>"))
+ statusList->SetItemBackgroundColour(row, *wxBLUE);
+ if (dataSet1->GetVal(wxT("blockedby")).Length() > 0)
+ statusList->SetItemBackgroundColour(row, *wxRED);
+ if (dataSet1->GetBool(wxT("slowquery")))
+ statusList->SetItemBackgroundColour(row, wxColour(227,104,21));
+ }
+ else
+ statusList->SetItemBackgroundColour(row, *wxWHITE);
+
row++;
}
dataSet1->MoveNext();
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers