mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
remove dashboard from playlist when its destroyed
This commit is contained in:
parent
be1fb13162
commit
ee400df930
@ -12,12 +12,12 @@ var (
|
|||||||
|
|
||||||
// Playlist model
|
// Playlist model
|
||||||
type Playlist struct {
|
type Playlist struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Timespan string `json:"timespan"`
|
Timespan string `json:"timespan"`
|
||||||
Data []int `json:"data"`
|
Data []int64 `json:"data"`
|
||||||
OrgId int64 `json:"-"`
|
OrgId int64 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlaylistDashboard struct {
|
type PlaylistDashboard struct {
|
||||||
@ -49,7 +49,7 @@ type UpdatePlaylistQuery struct {
|
|||||||
Title string
|
Title string
|
||||||
Type string
|
Type string
|
||||||
Timespan string
|
Timespan string
|
||||||
Data []int
|
Data []int64
|
||||||
|
|
||||||
Result *Playlist
|
Result *Playlist
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ type CreatePlaylistQuery struct {
|
|||||||
Title string
|
Title string
|
||||||
Type string
|
Type string
|
||||||
Timespan string
|
Timespan string
|
||||||
Data []int
|
Data []int64
|
||||||
OrgId int64
|
OrgId int64
|
||||||
|
|
||||||
Result *Playlist
|
Result *Playlist
|
||||||
|
@ -220,6 +220,26 @@ func DeleteDashboard(cmd *m.DeleteDashboardCommand) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var playlists = make(m.Playlists, 0)
|
||||||
|
err = sess.Where("data LIKE ?", fmt.Sprintf("%%%v%%", dashboard.Id)).Find(&playlists)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, playlist := range playlists {
|
||||||
|
filteredData := make([]int64, 0)
|
||||||
|
for _, plDashboardId := range playlist.Data {
|
||||||
|
if plDashboardId != dashboard.Id {
|
||||||
|
filteredData = append(filteredData, plDashboardId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playlist.Data = filteredData
|
||||||
|
_, err = sess.Id(playlist.Id).Cols("data").Update(playlist)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user