mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(import): save gnetId for dashbards imported from grafana.net
This commit is contained in:
@@ -29,6 +29,7 @@ type Dashboard struct {
|
|||||||
Id int64
|
Id int64
|
||||||
Slug string
|
Slug string
|
||||||
OrgId int64
|
OrgId int64
|
||||||
|
GnetId int64
|
||||||
Version int
|
Version int
|
||||||
|
|
||||||
Created time.Time
|
Created time.Time
|
||||||
@@ -77,6 +78,10 @@ func NewDashboardFromJson(data *simplejson.Json) *Dashboard {
|
|||||||
dash.Updated = time.Now()
|
dash.Updated = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if gnetId, err := dash.Data.Get("gnetId").Float64(); err == nil {
|
||||||
|
dash.GnetId = int64(gnetId)
|
||||||
|
}
|
||||||
|
|
||||||
return dash
|
return dash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,4 +102,9 @@ func addDashboardMigration(mg *Migrator) {
|
|||||||
mg.AddMigration("Add column created_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{
|
mg.AddMigration("Add column created_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{
|
||||||
Name: "created_by", Type: DB_Int, Nullable: true,
|
Name: "created_by", Type: DB_Int, Nullable: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// add column to store gnetId
|
||||||
|
mg.AddMigration("Add column gnetId in dashboard", NewAddColumnMigration(dashboardV2, &Column{
|
||||||
|
Name: "gnet_id", Type: DB_BigInt, Nullable: true,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ function (angular, $, _, moment) {
|
|||||||
this.schemaVersion = data.schemaVersion || 0;
|
this.schemaVersion = data.schemaVersion || 0;
|
||||||
this.version = data.version || 0;
|
this.version = data.version || 0;
|
||||||
this.links = data.links || [];
|
this.links = data.links || [];
|
||||||
|
this.gnetId = data.gnetId || null;
|
||||||
this._updateSchema(data);
|
this._updateSchema(data);
|
||||||
this._initMeta(meta);
|
this._initMeta(meta);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,10 +147,11 @@ export class DashImportCtrl {
|
|||||||
return this.backendSrv.get('api/gnet/dashboards/' + dashboardId).then(res => {
|
return this.backendSrv.get('api/gnet/dashboards/' + dashboardId).then(res => {
|
||||||
this.gnetInfo = res;
|
this.gnetInfo = res;
|
||||||
// store reference to grafana.net
|
// store reference to grafana.net
|
||||||
res.json.gnetId = dashboardId;
|
res.json.gnetId = res.id;
|
||||||
this.onUpload(res.json);
|
this.onUpload(res.json);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
this.gnetError = err.message || err;
|
err.isHandled = true;
|
||||||
|
this.gnetError = err.data.message || err;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user