diff --git a/pkg/api/dashboard_snapshot.go b/pkg/api/dashboard_snapshot.go index 99c8d4dd85f..8ed848a7b11 100644 --- a/pkg/api/dashboard_snapshot.go +++ b/pkg/api/dashboard_snapshot.go @@ -118,5 +118,23 @@ func SearchDashboardSnapshots(c *middleware.Context) Response { return ApiError(500, "Search failed", err) } - return Json(200, searchQuery.Result) + dtos := make([]*m.DashboardSnapshotDTO, len(searchQuery.Result)) + for i, snapshot := range searchQuery.Result { + dtos[i] = &m.DashboardSnapshotDTO{ + Id: snapshot.Id, + Name: snapshot.Name, + Key: snapshot.Key, + DeleteKey: snapshot.DeleteKey, + OrgId: snapshot.OrgId, + UserId: snapshot.UserId, + External: snapshot.External, + ExternalUrl: snapshot.ExternalUrl, + Expires: snapshot.Expires, + Created: snapshot.Created, + Updated: snapshot.Updated, + } + } + + return Json(200, dtos) + //return Json(200, searchQuery.Result) } diff --git a/pkg/models/dashboard_snapshot.go b/pkg/models/dashboard_snapshot.go index 8c1a0f47a06..9bfbd06c1ef 100644 --- a/pkg/models/dashboard_snapshot.go +++ b/pkg/models/dashboard_snapshot.go @@ -20,6 +20,22 @@ type DashboardSnapshot struct { Dashboard map[string]interface{} } +// DashboardSnapshotDTO without dashboard map +type DashboardSnapshotDTO struct { + Id int64 `json:"id"` + Name string `json:"name"` + Key string `json:"key"` + DeleteKey string `json:"deleteKey"` + OrgId int64 `json:"orgId"` + UserId int64 `json:"userId"` + External bool `json:"external"` + ExternalUrl string `json:"externalUrl"` + + Expires time.Time `json:"expires"` + Created time.Time `json:"created"` + Updated time.Time `json:"updated"` +} + // ----------------- // COMMANDS diff --git a/public/app/features/snapshot/partials/snapshots.html b/public/app/features/snapshot/partials/snapshots.html index 58b6c872617..e1fcf16f0ef 100644 --- a/public/app/features/snapshot/partials/snapshots.html +++ b/public/app/features/snapshot/partials/snapshots.html @@ -16,13 +16,13 @@ - {{snapshot.Name}} + {{snapshot.name}} - dashboard/snapshot/{{snapshot.Key}} + dashboard/snapshot/{{snapshot.key}} - + View diff --git a/public/app/features/snapshot/snapshot_ctrl.ts b/public/app/features/snapshot/snapshot_ctrl.ts index 60b09bf892e..5b27016f0aa 100644 --- a/public/app/features/snapshot/snapshot_ctrl.ts +++ b/public/app/features/snapshot/snapshot_ctrl.ts @@ -16,7 +16,7 @@ export class SnapshotsCtrl { $scope.removeSnapshot = function(snapshot) { $scope.appEvent('confirm-modal', { title: 'Confirm delete snapshot', - text: 'Are you sure you want to delete snapshot ' + snapshot.Name + '?', + text: 'Are you sure you want to delete snapshot ' + snapshot.name + '?', yesText: "Delete", icon: "fa-warning", onConfirm: function() { @@ -26,8 +26,8 @@ export class SnapshotsCtrl { }; $scope.removeSnapshotConfirmed = function(snapshot) { - _.remove($scope.snapshots, {Key: snapshot.Key}); - backendSrv.get('/api/snapshots-delete/' + snapshot.DeleteKey) + _.remove($scope.snapshots, {key: snapshot.key}); + backendSrv.get('/api/snapshots-delete/' + snapshot.deleteKey) .then(function() { $scope.appEvent('alert-success', ['Snapshot deleted', '']); }, function() {