commit
4fb24cb229
@ -164,6 +164,11 @@ func GetConnectionInfo(c *gin.Context) {
|
|||||||
c.JSON(200, res.Format()[0])
|
c.JSON(200, res.Format()[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetSequences(c *gin.Context) {
|
||||||
|
res, err := DbClient.Sequences()
|
||||||
|
serveResult(res, err, c)
|
||||||
|
}
|
||||||
|
|
||||||
func GetActivity(c *gin.Context) {
|
func GetActivity(c *gin.Context) {
|
||||||
res, err := DbClient.Activity()
|
res, err := DbClient.Activity()
|
||||||
serveResult(res, err, c)
|
serveResult(res, err, c)
|
||||||
|
@ -25,6 +25,7 @@ func SetupRoutes(router *gin.Engine) {
|
|||||||
api.POST("/connect", Connect)
|
api.POST("/connect", Connect)
|
||||||
api.GET("/databases", GetDatabases)
|
api.GET("/databases", GetDatabases)
|
||||||
api.GET("/connection", GetConnectionInfo)
|
api.GET("/connection", GetConnectionInfo)
|
||||||
|
api.GET("/sequences", GetSequences)
|
||||||
api.GET("/activity", GetActivity)
|
api.GET("/activity", GetActivity)
|
||||||
api.GET("/schemas", GetSchemas)
|
api.GET("/schemas", GetSchemas)
|
||||||
api.GET("/tables", GetTables)
|
api.GET("/tables", GetTables)
|
||||||
|
@ -136,6 +136,10 @@ func (client *Client) TableIndexes(table string) (*Result, error) {
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (client *Client) Sequences() ([]string, error) {
|
||||||
|
return client.fetchRows(statements.PG_SEQUENCES)
|
||||||
|
}
|
||||||
|
|
||||||
// Returns all active queriers on the server
|
// Returns all active queriers on the server
|
||||||
func (client *Client) Activity() (*Result, error) {
|
func (client *Client) Activity() (*Result, error) {
|
||||||
return client.query(statements.PG_ACTIVITY)
|
return client.query(statements.PG_ACTIVITY)
|
||||||
|
@ -188,6 +188,20 @@ func test_TableIndexes(t *testing.T) {
|
|||||||
assert.Equal(t, 2, len(res.Rows))
|
assert.Equal(t, 2, len(res.Rows))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func test_Sequences(t *testing.T) {
|
||||||
|
res, err := testClient.Sequences()
|
||||||
|
|
||||||
|
expected := []string{
|
||||||
|
"author_ids",
|
||||||
|
"book_ids",
|
||||||
|
"shipments_ship_id_seq",
|
||||||
|
"subject_ids",
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, nil, err)
|
||||||
|
assert.Equal(t, expected, res)
|
||||||
|
}
|
||||||
|
|
||||||
func test_Query(t *testing.T) {
|
func test_Query(t *testing.T) {
|
||||||
res, err := testClient.Query("SELECT * FROM books")
|
res, err := testClient.Query("SELECT * FROM books")
|
||||||
|
|
||||||
@ -257,6 +271,7 @@ func TestAll(t *testing.T) {
|
|||||||
test_TableRows(t)
|
test_TableRows(t)
|
||||||
test_TableInfo(t)
|
test_TableInfo(t)
|
||||||
test_TableIndexes(t)
|
test_TableIndexes(t)
|
||||||
|
test_Sequences(t)
|
||||||
test_Query(t)
|
test_Query(t)
|
||||||
test_QueryError(t)
|
test_QueryError(t)
|
||||||
test_QueryInvalidTable(t)
|
test_QueryInvalidTable(t)
|
||||||
|
File diff suppressed because one or more lines are too long
@ -31,6 +31,8 @@ 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_SEQUENCES = `SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = 'public' ORDER BY sequence_name`
|
||||||
|
|
||||||
PG_ACTIVITY = `SELECT
|
PG_ACTIVITY = `SELECT
|
||||||
datname,
|
datname,
|
||||||
query,
|
query,
|
||||||
|
@ -125,7 +125,7 @@
|
|||||||
color: #555;
|
color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
#sidebar div.tables-list #tables {
|
#sidebar div.tables-list #tables, #sequences {
|
||||||
padding: 33px 0 0;
|
padding: 33px 0 0;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
<span class="refresh" id="refresh_tables" title="Refresh tables list"><i class="fa fa-refresh"></i></span>
|
<span class="refresh" id="refresh_tables" title="Refresh tables list"><i class="fa fa-refresh"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<ul id="tables"></ul>
|
<ul id="tables"></ul>
|
||||||
|
<ul id="sequences"></ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-information">
|
<div class="table-information">
|
||||||
|
@ -23,6 +23,7 @@ function getTableStructure(table, cb) { apiCall("get", "/tables/" + table, {},
|
|||||||
function getTableIndexes(table, cb) { apiCall("get", "/tables/" + table + "/indexes", {}, cb); }
|
function getTableIndexes(table, cb) { apiCall("get", "/tables/" + table + "/indexes", {}, cb); }
|
||||||
function getHistory(cb) { apiCall("get", "/history", {}, cb); }
|
function getHistory(cb) { apiCall("get", "/history", {}, cb); }
|
||||||
function getBookmarks(cb) { apiCall("get", "/bookmarks", {}, cb); }
|
function getBookmarks(cb) { apiCall("get", "/bookmarks", {}, cb); }
|
||||||
|
function getSequences(cb) { apiCall("get", "/sequences", {}, cb); }
|
||||||
|
|
||||||
function encodeQuery(query) {
|
function encodeQuery(query) {
|
||||||
return window.btoa(query);
|
return window.btoa(query);
|
||||||
@ -46,6 +47,16 @@ function loadTables() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadSequences() {
|
||||||
|
$("#sequences li").remove();
|
||||||
|
|
||||||
|
getSequences(function(data) {
|
||||||
|
data.forEach(function(item) {
|
||||||
|
$("<li><span><i class='fa fa-chevron-right'></i> " + item + " </span></li>").appendTo("#sequences");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function escapeHtml(str) {
|
function escapeHtml(str) {
|
||||||
if (str != null || str != undefined) {
|
if (str != null || str != undefined) {
|
||||||
return jQuery("<div/>").text(str).html();
|
return jQuery("<div/>").text(str).html();
|
||||||
@ -89,6 +100,7 @@ function performTableAction(table, action) {
|
|||||||
executeQuery("DROP TABLE " + table, function(data) {
|
executeQuery("DROP TABLE " + table, function(data) {
|
||||||
if (data.error) alert(data.error);
|
if (data.error) alert(data.error);
|
||||||
loadTables();
|
loadTables();
|
||||||
|
loadSequences();
|
||||||
resetTable();
|
resetTable();
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -312,6 +324,7 @@ function runQuery() {
|
|||||||
// Refresh tables list if table was added or removed
|
// Refresh tables list if table was added or removed
|
||||||
if (query.match(re)) {
|
if (query.match(re)) {
|
||||||
loadTables();
|
loadTables();
|
||||||
|
loadSequences();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -538,6 +551,7 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$("#tables").on("click", "li", function() {
|
$("#tables").on("click", "li", function() {
|
||||||
$("#tables li.selected").removeClass("selected");
|
$("#tables li.selected").removeClass("selected");
|
||||||
|
$("#sequences li.selected").removeClass("selected");
|
||||||
$(this).addClass("selected");
|
$(this).addClass("selected");
|
||||||
$("#tables").attr("data-current", $.trim($(this).text()));
|
$("#tables").attr("data-current", $.trim($(this).text()));
|
||||||
|
|
||||||
@ -555,8 +569,20 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#sequences").on("click", "li", function() {
|
||||||
|
$("#tables li.selected").removeClass("selected");
|
||||||
|
$("#sequences li.selected").removeClass("selected");
|
||||||
|
|
||||||
|
$(this).addClass("selected");
|
||||||
|
$("#tables").attr("data-current", $.trim($(this).text()));
|
||||||
|
|
||||||
|
showTableContent();
|
||||||
|
$(".table-information ul").hide();
|
||||||
|
});
|
||||||
|
|
||||||
$("#refresh_tables").on("click", function() {
|
$("#refresh_tables").on("click", function() {
|
||||||
loadTables();
|
loadTables();
|
||||||
|
loadSequences();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#edit_connection").on("click", function() {
|
$("#edit_connection").on("click", function() {
|
||||||
@ -655,6 +681,7 @@ $(document).ready(function() {
|
|||||||
else {
|
else {
|
||||||
connected = true;
|
connected = true;
|
||||||
loadTables();
|
loadTables();
|
||||||
|
loadSequences();
|
||||||
|
|
||||||
$("#connection_window").hide();
|
$("#connection_window").hide();
|
||||||
$("#current_database").text(resp.current_database);
|
$("#current_database").text(resp.current_database);
|
||||||
@ -674,6 +701,7 @@ $(document).ready(function() {
|
|||||||
else {
|
else {
|
||||||
connected = true;
|
connected = true;
|
||||||
loadTables();
|
loadTables();
|
||||||
|
loadSequences();
|
||||||
|
|
||||||
$("#current_database").text(resp.current_database);
|
$("#current_database").text(resp.current_database);
|
||||||
$("#main").show();
|
$("#main").show();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user