Commit b22b3e5b by Torkel Ödegaard

mysql: added default query template

parent ea53e722
......@@ -61,11 +61,6 @@ func InsertSqlTestData(cmd *m.InsertSqlTestDataCommand) error {
sqlRandomWalk("server2", "frontend", 100, 1.123, sess)
sqlRandomWalk("server3", "frontend", 100, 1.123, sess)
sqlRandomWalk("server1", "backend", 100, 1.123, sess)
sqlRandomWalk("server2", "backend", 100, 1.123, sess)
sqlRandomWalk("server3", "backend", 100, 1.123, sess)
sqlRandomWalk("db-server1", "backend", 100, 1.123, sess)
return err
})
}
......@@ -9,12 +9,23 @@ export interface MysqlQuery {
refId: string;
format: string;
alias: string;
rawSql: string;
}
export interface QueryMeta {
sql: string;
}
var defaulQuery = `SELECT
UNIX_TIMESTAMP(<time_column>) as time_sec,
<value column> as value,
<series name column> as metric
FROM <table name>
WHERE $__timeFilter(time_column)
ORDER BY <time_column> ASC
`;
class MysqlQueryCtrl extends QueryCtrl {
static templateUrl = 'partials/query.editor.html';
......@@ -35,6 +46,10 @@ class MysqlQueryCtrl extends QueryCtrl {
{text: 'Table', value: 'table'},
];
if (!this.target.rawSql) {
this.target.rawSql = defaulQuery;
}
this.panelCtrl.events.on('data-received', this.onDataReceived.bind(this), $scope);
this.panelCtrl.events.on('data-error', this.onDataError.bind(this), $scope);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment