File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 4
4
"encoding/json"
5
5
"os"
6
6
"path"
7
- "strconv"
8
7
"strings"
9
8
10
9
"github.com/grafana/grafana/pkg/api/dtos"
@@ -49,6 +48,20 @@ func GetDashboard(c *middleware.Context) {
49
48
}
50
49
51
50
dash := query .Result
51
+
52
+ // Finding the last updater of the dashboard
53
+ updater := "Anonymous"
54
+ if dash .UpdatedBy != 0 {
55
+ userQuery := m.GetUserByIdQuery {Id : dash .UpdatedBy }
56
+ userErr := bus .Dispatch (& userQuery )
57
+ if userErr != nil {
58
+ updater = "Unknown"
59
+ } else {
60
+ user := userQuery .Result
61
+ updater = user .Login
62
+ }
63
+ }
64
+
52
65
dto := dtos.DashboardFullWithMeta {
53
66
Dashboard : dash .Data ,
54
67
Meta : dtos.DashboardMeta {
@@ -60,7 +73,7 @@ func GetDashboard(c *middleware.Context) {
60
73
CanEdit : canEditDashboard (c .OrgRole ),
61
74
Created : dash .Created ,
62
75
Updated : dash .Updated ,
63
- UpdatedBy : strconv . FormatInt ( dash . UpdatedBy , 10 ) ,
76
+ UpdatedBy : updater ,
64
77
},
65
78
}
66
79
@@ -89,7 +102,12 @@ func DeleteDashboard(c *middleware.Context) {
89
102
90
103
func PostDashboard (c * middleware.Context , cmd m.SaveDashboardCommand ) {
91
104
cmd .OrgId = c .OrgId
92
- cmd .UpdatedBy = c .UserId
105
+
106
+ if ! c .IsSignedIn {
107
+ cmd .UpdatedBy = 0
108
+ } else {
109
+ cmd .UpdatedBy = c .UserId
110
+ }
93
111
94
112
dash := cmd .GetDashboardModel ()
95
113
if dash .Id == 0 {
You can’t perform that action at this time.
0 commit comments