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
55d95f90
Commit
55d95f90
authored
Apr 03, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(prefs): moved context srv to typescript
parent
ab1048b7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
47 deletions
+67
-47
public/app/core/services/context_srv.js
+0
-47
public/app/core/services/context_srv.ts
+67
-0
No files found.
public/app/core/services/context_srv.js
deleted
100644 → 0
View file @
ab1048b7
define
([
'angular'
,
'lodash'
,
'../core_module'
,
'app/core/store'
,
'app/core/config'
,
],
function
(
angular
,
_
,
coreModule
,
store
,
config
)
{
'use strict'
;
coreModule
.
default
.
service
(
'contextSrv'
,
function
()
{
function
User
()
{
if
(
config
.
bootData
.
user
)
{
_
.
extend
(
this
,
config
.
bootData
.
user
);
}
}
this
.
hasRole
=
function
(
role
)
{
return
this
.
user
.
orgRole
===
role
;
};
this
.
setPinnedState
=
function
(
val
)
{
this
.
pinned
=
val
;
store
.
set
(
'grafana.sidemenu.pinned'
,
val
);
};
this
.
toggleSideMenu
=
function
()
{
this
.
sidemenu
=
!
this
.
sidemenu
;
if
(
!
this
.
sidemenu
)
{
this
.
setPinnedState
(
false
);
}
};
this
.
pinned
=
store
.
getBool
(
'grafana.sidemenu.pinned'
,
false
);
if
(
this
.
pinned
)
{
this
.
sidemenu
=
true
;
}
this
.
version
=
config
.
buildInfo
.
version
;
this
.
lightTheme
=
false
;
this
.
user
=
new
User
();
this
.
isSignedIn
=
this
.
user
.
isSignedIn
;
this
.
isGrafanaAdmin
=
this
.
user
.
isGrafanaAdmin
;
this
.
isEditor
=
this
.
hasRole
(
'Editor'
)
||
this
.
hasRole
(
'Admin'
);
});
});
public/app/core/services/context_srv.ts
0 → 100644
View file @
55d95f90
///<reference path="../../headers/common.d.ts" />
import
config
from
'app/core/config'
;
import
_
from
'lodash'
;
import
$
from
'jquery'
;
import
coreModule
from
'app/core/core_module'
;
import
store
from
'app/core/store'
;
export
class
User
{
isGrafanaAdmin
:
any
;
isSignedIn
:
any
;
orgRole
:
any
;
constructor
()
{
if
(
config
.
bootData
.
user
)
{
_
.
extend
(
this
,
config
.
bootData
.
user
);
}
}
}
export
class
ContextSrv
{
pinned
:
any
;
version
:
any
;
user
:
User
;
isSignedIn
:
any
;
isGrafanaAdmin
:
any
;
isEditor
:
any
;
sidemenu
:
any
;
lightTheme
:
any
;
constructor
()
{
this
.
pinned
=
store
.
getBool
(
'grafana.sidemenu.pinned'
,
false
);
if
(
this
.
pinned
)
{
this
.
sidemenu
=
true
;
}
this
.
version
=
config
.
buildInfo
.
version
;
this
.
lightTheme
=
false
;
this
.
user
=
new
User
();
this
.
isSignedIn
=
this
.
user
.
isSignedIn
;
this
.
isGrafanaAdmin
=
this
.
user
.
isGrafanaAdmin
;
this
.
isEditor
=
this
.
hasRole
(
'Editor'
)
||
this
.
hasRole
(
'Admin'
);
}
hasRole
(
role
)
{
return
this
.
user
.
orgRole
===
role
;
}
setPinnedState
(
val
)
{
this
.
pinned
=
val
;
store
.
set
(
'grafana.sidemenu.pinned'
,
val
);
}
toggleSideMenu
()
{
this
.
sidemenu
=
!
this
.
sidemenu
;
if
(
!
this
.
sidemenu
)
{
this
.
setPinnedState
(
false
);
}
}
}
var
contextSrv
=
new
ContextSrv
();
export
{
contextSrv
};
coreModule
.
factory
(
'contextSrv'
,
function
()
{
return
contextSrv
;
});
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