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
9c8d5082
Commit
9c8d5082
authored
Mar 06, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made API handling better, removed unused components
parent
8f42bec2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
34 additions
and
79 deletions
+34
-79
pkg/api/preferences.go
+10
-3
pkg/models/preferences.go
+2
-2
pkg/services/sqlstore/preferences.go
+21
-10
public/app/core/components/sidemenu/sidemenu.ts
+0
-1
public/app/core/routes/routes.ts
+0
-4
public/app/features/all.js
+0
-1
public/app/features/profile/partials/preferences.html
+0
-32
public/app/features/profile/partials/profile.html
+1
-1
public/app/features/profile/preferencesCtrl.js
+0
-25
No files found.
pkg/api/preferences.go
View file @
9c8d5082
...
...
@@ -20,13 +20,20 @@ func SaveUserPreferences(c *middleware.Context, cmd m.SavePreferencesCommand) Re
}
func
GetUserPreferences
(
c
*
middleware
.
Context
)
Response
{
// GET /api/user/prefs
func
GetUserPreferences
(
c
*
middleware
.
Context
)
{
query
:=
m
.
GetPreferencesQuery
{
PrefId
:
c
.
UserId
,
PrefType
:
`user`
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed to get
user"
,
err
)
c
.
JsonApiErr
(
500
,
"Failed to get preferences for
user"
,
err
)
}
return
Json
(
200
,
query
.
Result
)
dto
:=
m
.
PreferencesDTO
{
PrefId
:
query
.
Result
.
PrefId
,
PrefType
:
query
.
Result
.
PrefType
,
PrefData
:
query
.
Result
.
PrefData
,
}
c
.
JSON
(
200
,
dto
)
}
pkg/models/preferences.go
View file @
9c8d5082
...
...
@@ -6,7 +6,7 @@ import (
// Typed errors
var
(
ErrPreference
NotFound
=
errors
.
New
(
"Preference
not found"
)
ErrPreference
sNotFound
=
errors
.
New
(
"Preferences
not found"
)
)
type
Preferences
struct
{
...
...
@@ -23,7 +23,7 @@ type GetPreferencesQuery struct {
PrefId
int64
PrefType
string
Result
PreferencesDTO
Result
*
Preferences
}
// ---------------------
...
...
pkg/services/sqlstore/preferences.go
View file @
9c8d5082
...
...
@@ -22,10 +22,11 @@ func GetPreferences(query *m.GetPreferencesQuery) error {
if
resultsErr
!=
nil
{
return
resultsErr
}
query
.
Result
=
m
.
PreferencesDTO
{
PrefId
:
prefResults
[
0
]
.
PrefId
,
PrefType
:
prefResults
[
0
]
.
PrefType
,
PrefData
:
prefResults
[
0
]
.
PrefData
,
if
len
(
prefResults
)
>
0
{
query
.
Result
=
&
prefResults
[
0
]
}
else
{
query
.
Result
=
new
(
m
.
Preferences
)
}
return
nil
...
...
@@ -45,15 +46,25 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
return
resultsErr
}
var
matchedPref
m
.
Preferences
matchedPref
=
prefResults
[
0
]
matchedPref
.
PrefData
=
cmd
.
PrefData
affectedRows
,
updateErr
:=
sess
.
Id
(
matchedPref
.
Id
)
.
Update
(
&
matchedPref
)
var
savePref
m
.
Preferences
var
affectedRows
int64
var
saveErr
error
if
len
(
prefResults
)
==
0
{
savePref
.
PrefId
=
cmd
.
PrefId
savePref
.
PrefType
=
cmd
.
PrefType
savePref
.
PrefData
=
cmd
.
PrefData
affectedRows
,
saveErr
=
sess
.
Insert
(
&
savePref
)
}
else
{
savePref
=
prefResults
[
0
]
savePref
.
PrefData
=
cmd
.
PrefData
affectedRows
,
saveErr
=
sess
.
Id
(
savePref
.
Id
)
.
Update
(
&
savePref
)
}
if
affectedRows
==
0
{
return
m
.
ErrPreferenceNotFound
return
m
.
ErrPreference
s
NotFound
}
return
updat
eErr
return
sav
eErr
})
}
public/app/core/components/sidemenu/sidemenu.ts
View file @
9c8d5082
...
...
@@ -39,7 +39,6 @@ export class SideMenuCtrl {
this
.
orgMenu
=
[
{
section
:
'You'
,
cssClass
:
'dropdown-menu-title'
},
{
text
:
'Profile'
,
url
:
this
.
getUrl
(
'/profile'
)},
{
text
:
'Preferences'
,
url
:
this
.
getUrl
(
'/preferences'
)},
];
if
(
this
.
isSignedIn
)
{
...
...
public/app/core/routes/routes.ts
View file @
9c8d5082
...
...
@@ -89,10 +89,6 @@ function setupAngularRoutes($routeProvider, $locationProvider) {
templateUrl
:
'public/app/features/profile/partials/profile.html'
,
controller
:
'ProfileCtrl'
,
})
.
when
(
'/preferences'
,
{
templateUrl
:
'public/app/features/profile/partials/preferences.html'
,
controller
:
'PreferencesCtrl'
,
})
.
when
(
'/profile/password'
,
{
templateUrl
:
'public/app/features/profile/partials/password.html'
,
controller
:
'ChangePasswordCtrl'
,
...
...
public/app/features/all.js
View file @
9c8d5082
...
...
@@ -10,6 +10,5 @@ define([
'./profile/profileCtrl'
,
'./profile/changePasswordCtrl'
,
'./profile/selectOrgCtrl'
,
'./profile/preferencesCtrl'
,
'./styleguide/styleguide'
,
],
function
()
{});
public/app/features/profile/partials/preferences.html
deleted
100644 → 0
View file @
8f42bec2
<navbar
icon=
"icon-gf icon-gf-users"
title=
"Preferences"
title-url=
"preferences"
>
</navbar>
<div
class=
"page-container"
>
<div
class=
"page-header"
>
<h1>
Preferences
</h1>
</div>
<form
name=
"userForm"
class=
"gf-form-group"
>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Home Dashboard
</span>
<input
class=
"gf-form-input max-width-21"
type=
"text"
ng-model=
"prefData.homeDashboard"
>
</div>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Time Range
</span>
<input
class=
"gf-form-input max-width-21"
type=
"text"
ng-model=
"prefData.timeRange"
>
</div>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-10"
>
Theme
</span>
<input
class=
"gf-form-input max-width-21"
type=
"text"
ng-model=
"prefData.theme"
>
</div>
<div
class=
"gf-form-button-row"
>
<button
type=
"submit"
class=
"btn btn-success"
ng-click=
"setUserPreferences()"
>
Set Preferences
</button>
<a
class=
"btn-text"
href=
"profile"
>
Cancel
</a>
</div>
</form>
</div>
public/app/features/profile/partials/profile.html
View file @
9c8d5082
...
...
@@ -7,7 +7,7 @@
</div>
<form
name=
"userForm"
class=
"gf-form-group"
>
<h3
class=
"page-heading"
>
Information
</h3>
<h3
class=
"page-heading"
>
Preferences
</h3>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label width-7"
>
Name
</span>
...
...
public/app/features/profile/preferencesCtrl.js
deleted
100644 → 0
View file @
8f42bec2
define
([
'angular'
,
'app/core/config'
,
],
function
(
angular
)
{
'use strict'
;
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'PreferencesCtrl'
,
function
(
$scope
,
backendSrv
,
$location
)
{
$scope
.
prefData
=
{};
$scope
.
setUserPreferences
=
function
()
{
if
(
!
$scope
.
userForm
.
$valid
)
{
return
;
}
console
.
log
(
$scope
.
command
);
backendSrv
.
put
(
'/api/user/prefs'
,
{
prefData
:
$scope
.
prefData
}).
then
(
function
()
{
$location
.
path
(
"profile"
);
});
};
});
});
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