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
69a57850
Unverified
Commit
69a57850
authored
Nov 13, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restore user profile preferences
parent
68eecf6c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
2 deletions
+96
-2
public/app/features/all.ts
+1
-2
public/app/features/profile/PrefControlCtrl.ts
+92
-0
public/app/features/profile/all.ts
+3
-0
No files found.
public/app/features/all.ts
View file @
69a57850
...
...
@@ -10,5 +10,4 @@ import './alerting/NotificationsEditCtrl';
import
'./alerting/NotificationsListCtrl'
;
import
'./manage-dashboards'
;
import
'./teams/CreateTeamCtrl'
;
import
'./profile/ProfileCtrl'
;
import
'./profile/ChangePasswordCtrl'
;
import
'./profile/all'
;
public/app/features/profile/PrefControlCtrl.ts
0 → 100644
View file @
69a57850
import
config
from
'app/core/config'
;
import
coreModule
from
'app/core/core_module'
;
export
class
PrefsControlCtrl
{
prefs
:
any
;
oldTheme
:
any
;
prefsForm
:
any
;
mode
:
string
;
timezones
:
any
=
[
{
value
:
''
,
text
:
'Default'
},
{
value
:
'browser'
,
text
:
'Local browser time'
},
{
value
:
'utc'
,
text
:
'UTC'
},
];
themes
:
any
=
[{
value
:
''
,
text
:
'Default'
},
{
value
:
'dark'
,
text
:
'Dark'
},
{
value
:
'light'
,
text
:
'Light'
}];
/** @ngInject */
constructor
(
private
backendSrv
,
private
$location
)
{}
$onInit
()
{
return
this
.
backendSrv
.
get
(
`/api/
${
this
.
mode
}
/preferences`
).
then
(
prefs
=>
{
this
.
prefs
=
prefs
;
this
.
oldTheme
=
prefs
.
theme
;
});
}
updatePrefs
()
{
if
(
!
this
.
prefsForm
.
$valid
)
{
return
;
}
const
cmd
=
{
theme
:
this
.
prefs
.
theme
,
timezone
:
this
.
prefs
.
timezone
,
homeDashboardId
:
this
.
prefs
.
homeDashboardId
,
};
this
.
backendSrv
.
put
(
`/api/
${
this
.
mode
}
/preferences`
,
cmd
).
then
(()
=>
{
window
.
location
.
href
=
config
.
appSubUrl
+
this
.
$location
.
path
();
});
}
}
const
template
=
`
<form name="ctrl.prefsForm" class="section gf-form-group">
<h3 class="page-heading">Preferences</h3>
<div class="gf-form">
<span class="gf-form-label width-11">UI Theme</span>
<div class="gf-form-select-wrapper max-width-20">
<select class="gf-form-input" ng-model="ctrl.prefs.theme" ng-options="f.value as f.text for f in ctrl.themes"></select>
</div>
</div>
<div class="gf-form">
<span class="gf-form-label width-11">
Home Dashboard
<info-popover mode="right-normal">
Not finding dashboard you want? Star it first, then it should appear in this select box.
</info-popover>
</span>
<dashboard-selector class="gf-form-select-wrapper max-width-20" model="ctrl.prefs.homeDashboardId">
</dashboard-selector>
</div>
<div class="gf-form">
<label class="gf-form-label width-11">Timezone</label>
<div class="gf-form-select-wrapper max-width-20">
<select class="gf-form-input" ng-model="ctrl.prefs.timezone" ng-options="f.value as f.text for f in ctrl.timezones"></select>
</div>
</div>
<div class="gf-form-button-row">
<button type="submit" class="btn btn-success" ng-click="ctrl.updatePrefs()">Save</button>
</div>
</form>
`
;
export
function
prefsControlDirective
()
{
return
{
restrict
:
'E'
,
controller
:
PrefsControlCtrl
,
bindToController
:
true
,
controllerAs
:
'ctrl'
,
template
:
template
,
scope
:
{
mode
:
'@'
,
},
};
}
coreModule
.
directive
(
'prefsControl'
,
prefsControlDirective
);
public/app/features/profile/all.ts
0 → 100644
View file @
69a57850
import
'./ProfileCtrl'
;
import
'./ChangePasswordCtrl'
;
import
'./PrefControlCtrl'
;
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