Commit 689e366f by Torkel Ödegaard

refactoring: updated api url routes so they do not conflict with slug route

parent e2061312
......@@ -224,12 +224,12 @@ func (hs *HttpServer) registerRoutes() {
r.Group("/dashboards", func() {
r.Combo("/db/:slug").Get(GetDashboard).Delete(DeleteDashboard)
r.Get("/db/:dashboardId/versions", wrap(GetDashboardVersions))
r.Get("/db/:dashboardId/versions/:id", wrap(GetDashboardVersion))
r.Get("/db/:dashboardId/compare/:versions", wrap(CompareDashboardVersions))
r.Get("/db/:dashboardId/compare/:versions/html", wrap(CompareDashboardVersionsJSON))
r.Get("/db/:dashboardId/compare/:versions/basic", wrap(CompareDashboardVersionsBasic))
r.Post("/db/:dashboardId/restore", reqEditorRole, bind(dtos.RestoreDashboardVersionCommand{}), wrap(RestoreDashboardVersion))
r.Get("/id/:dashboardId/versions", wrap(GetDashboardVersions))
r.Get("/id/:dashboardId/versions/:id", wrap(GetDashboardVersion))
r.Get("/id/:dashboardId/compare/:versions", wrap(CompareDashboardVersions))
r.Get("/id/:dashboardId/compare/:versions/html", wrap(CompareDashboardVersionsJSON))
r.Get("/id/:dashboardId/compare/:versions/basic", wrap(CompareDashboardVersionsBasic))
r.Post("/id/:dashboardId/restore", reqEditorRole, bind(dtos.RestoreDashboardVersionCommand{}), wrap(RestoreDashboardVersion))
r.Post("/db", reqEditorRole, bind(m.SaveDashboardCommand{}), wrap(PostDashboard))
r.Get("/file/:file", GetDashboardFromJsonFile)
......
......@@ -11,18 +11,18 @@ export class HistorySrv {
getHistoryList(dashboard: DashboardModel, options: HistoryListOpts) {
const id = dashboard && dashboard.id ? dashboard.id : void 0;
return id ? this.backendSrv.get(`api/dashboards/db/${id}/versions`, options) : this.$q.when([]);
return id ? this.backendSrv.get(`api/dashboards/id/${id}/versions`, options) : this.$q.when([]);
}
compareVersions(dashboard: DashboardModel, compare: { new: number, original: number }, view = 'html') {
const id = dashboard && dashboard.id ? dashboard.id : void 0;
const url = `api/dashboards/db/${id}/compare/${compare.original}...${compare.new}/${view}`;
const url = `api/dashboards/id/${id}/compare/${compare.original}...${compare.new}/${view}`;
return id ? this.backendSrv.get(url) : this.$q.when({});
}
restoreDashboard(dashboard: DashboardModel, version: number) {
const id = dashboard && dashboard.id ? dashboard.id : void 0;
const url = `api/dashboards/db/${id}/restore`;
const url = `api/dashboards/id/${id}/restore`;
return id && _.isNumber(version) ? this.backendSrv.post(url, { version }) : this.$q.when({});
}
}
......
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