Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
e371e036
Commit
e371e036
authored
Mar 14, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Able to save preference version, created, updated fields
parent
0bf721a7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
1 deletions
+17
-1
pkg/api/api.go
+0
-0
pkg/api/preferences.go
+1
-1
pkg/models/preferences.go
+0
-0
pkg/services/sqlstore/migrations/preferences_mig.go
+0
-0
pkg/services/sqlstore/preferences.go
+16
-0
No files found.
pkg/api/api.go
View file @
e371e036
pkg/api/preferences.go
View file @
e371e036
...
@@ -13,7 +13,7 @@ func SavePreferences(c *middleware.Context, cmd m.SavePreferencesCommand) Respon
...
@@ -13,7 +13,7 @@ func SavePreferences(c *middleware.Context, cmd m.SavePreferencesCommand) Respon
cmd
.
OrgId
=
c
.
OrgId
cmd
.
OrgId
=
c
.
OrgId
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed to save
d
preferences"
,
err
)
return
ApiError
(
500
,
"Failed to save preferences"
,
err
)
}
}
return
ApiSuccess
(
"Preferences saved"
)
return
ApiSuccess
(
"Preferences saved"
)
...
...
pkg/models/preferences.go
View file @
e371e036
pkg/services/sqlstore/migrations/preferences_mig.go
View file @
e371e036
pkg/services/sqlstore/preferences.go
View file @
e371e036
...
@@ -3,6 +3,7 @@ package sqlstore
...
@@ -3,6 +3,7 @@ package sqlstore
import
(
import
(
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/bus"
m
"github.com/grafana/grafana/pkg/models"
m
"github.com/grafana/grafana/pkg/models"
"time"
)
)
func
init
()
{
func
init
()
{
...
@@ -54,10 +55,12 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
...
@@ -54,10 +55,12 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
savePref
.
UserId
=
cmd
.
UserId
savePref
.
UserId
=
cmd
.
UserId
savePref
.
OrgId
=
cmd
.
OrgId
savePref
.
OrgId
=
cmd
.
OrgId
savePref
.
Preference
=
cmd
.
Preference
savePref
.
Preference
=
cmd
.
Preference
savePref
=
SetPreferencesModel
(
savePref
,
false
)
affectedRows
,
saveErr
=
sess
.
Insert
(
&
savePref
)
affectedRows
,
saveErr
=
sess
.
Insert
(
&
savePref
)
}
else
{
}
else
{
savePref
=
prefResults
[
0
]
savePref
=
prefResults
[
0
]
savePref
.
Preference
=
cmd
.
Preference
savePref
.
Preference
=
cmd
.
Preference
savePref
=
SetPreferencesModel
(
savePref
,
true
)
affectedRows
,
saveErr
=
sess
.
Id
(
savePref
.
Id
)
.
Update
(
&
savePref
)
affectedRows
,
saveErr
=
sess
.
Id
(
savePref
.
Id
)
.
Update
(
&
savePref
)
}
}
...
@@ -68,3 +71,16 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
...
@@ -68,3 +71,16 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
return
saveErr
return
saveErr
})
})
}
}
func
SetPreferencesModel
(
pref
m
.
Preferences
,
updating
bool
)
m
.
Preferences
{
if
updating
{
pref
.
Version
=
pref
.
Version
+
1
}
else
{
pref
.
Version
=
0
pref
.
Created
=
time
.
Now
()
}
pref
.
Updated
=
time
.
Now
()
return
pref
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment