commit
0251a8bb73
11
api.go
11
api.go
@ -54,6 +54,7 @@ func setupRoutes(router *gin.Engine) {
|
|||||||
api.POST("/connect", API_Connect)
|
api.POST("/connect", API_Connect)
|
||||||
api.GET("/databases", API_GetDatabases)
|
api.GET("/databases", API_GetDatabases)
|
||||||
api.GET("/connection", API_ConnectionInfo)
|
api.GET("/connection", API_ConnectionInfo)
|
||||||
|
api.GET("/activity", API_Activity)
|
||||||
api.GET("/tables", API_GetTables)
|
api.GET("/tables", API_GetTables)
|
||||||
api.GET("/tables/:table", API_GetTable)
|
api.GET("/tables/:table", API_GetTable)
|
||||||
api.GET("/tables/:table/rows", API_GetTableRows)
|
api.GET("/tables/:table/rows", API_GetTableRows)
|
||||||
@ -272,6 +273,16 @@ func API_ConnectionInfo(c *gin.Context) {
|
|||||||
c.JSON(200, res.Format()[0])
|
c.JSON(200, res.Format()[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func API_Activity(c *gin.Context) {
|
||||||
|
res, err := dbClient.Activity()
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(400, NewError(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(200, res)
|
||||||
|
}
|
||||||
|
|
||||||
func API_TableIndexes(c *gin.Context) {
|
func API_TableIndexes(c *gin.Context) {
|
||||||
res, err := dbClient.TableIndexes(c.Params.ByName("table"))
|
res, err := dbClient.TableIndexes(c.Params.ByName("table"))
|
||||||
|
|
||||||
|
36
bindata.go
36
bindata.go
File diff suppressed because one or more lines are too long
@ -127,6 +127,11 @@ func (client *Client) TableIndexes(table string) (*Result, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns all active queriers on the server
|
||||||
|
func (client *Client) Activity() (*Result, error) {
|
||||||
|
return client.query(PG_ACTIVITY)
|
||||||
|
}
|
||||||
|
|
||||||
func (client *Client) Query(query string) (*Result, error) {
|
func (client *Client) Query(query string) (*Result, error) {
|
||||||
res, err := client.query(query)
|
res, err := client.query(query)
|
||||||
|
|
||||||
|
@ -28,4 +28,18 @@ FROM information_schema.columns
|
|||||||
WHERE table_name = $1`
|
WHERE table_name = $1`
|
||||||
|
|
||||||
PG_TABLES = `SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_schema,table_name`
|
PG_TABLES = `SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_schema,table_name`
|
||||||
|
|
||||||
|
PG_ACTIVITY = `SELECT
|
||||||
|
datname,
|
||||||
|
query,
|
||||||
|
state,
|
||||||
|
waiting,
|
||||||
|
query_start,
|
||||||
|
state_change,
|
||||||
|
pid,
|
||||||
|
datid,
|
||||||
|
application_name,
|
||||||
|
client_addr
|
||||||
|
FROM pg_stat_activity
|
||||||
|
WHERE state IS NOT NULL`
|
||||||
)
|
)
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
padding: 0px;
|
padding: 0px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
display: block;
|
display: block;
|
||||||
width: 550px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#nav ul li {
|
#nav ul li {
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<li id="table_indexes">Indexes</li>
|
<li id="table_indexes">Indexes</li>
|
||||||
<li id="table_query" class="selected">SQL Query</li>
|
<li id="table_query" class="selected">SQL Query</li>
|
||||||
<li id="table_history">History</li>
|
<li id="table_history">History</li>
|
||||||
|
<li id="table_activity">Activity</li>
|
||||||
<li id="table_connection">Connection</li>
|
<li id="table_connection">Connection</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -221,6 +221,16 @@ function showConnectionPanel() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showActivityPanel() {
|
||||||
|
setCurrentTab("table_activity");
|
||||||
|
|
||||||
|
apiCall("get", "/activity", {}, function(data) {
|
||||||
|
buildTable(data);
|
||||||
|
$("#input").hide();
|
||||||
|
$("#output").addClass("full");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function runQuery() {
|
function runQuery() {
|
||||||
setCurrentTab("table_query");
|
setCurrentTab("table_query");
|
||||||
|
|
||||||
@ -404,6 +414,7 @@ $(document).ready(function() {
|
|||||||
$("#table_history").on("click", function() { showQueryHistory(); });
|
$("#table_history").on("click", function() { showQueryHistory(); });
|
||||||
$("#table_query").on("click", function() { showQueryPanel(); });
|
$("#table_query").on("click", function() { showQueryPanel(); });
|
||||||
$("#table_connection").on("click", function() { showConnectionPanel(); });
|
$("#table_connection").on("click", function() { showConnectionPanel(); });
|
||||||
|
$("#table_activity").on("click", function() { showActivityPanel(); });
|
||||||
|
|
||||||
$("#run").on("click", function() {
|
$("#run").on("click", function() {
|
||||||
runQuery();
|
runQuery();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user