2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								package  api 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  ( 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-23 18:29:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									"fmt" 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 23:59:43 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									"strings" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-05 17:37:13 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									"github.com/grafana/grafana/pkg/api/dtos" 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-03 04:54:06 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									"github.com/grafana/grafana/pkg/bus" 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-05 17:37:13 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									"github.com/grafana/grafana/pkg/middleware" 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									m  "github.com/grafana/grafana/pkg/models" 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-06 17:20:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									"github.com/grafana/grafana/pkg/plugins" 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-05 17:37:13 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									"github.com/grafana/grafana/pkg/setting" 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								func  setIndexViewData ( c  * middleware . Context )  ( * dtos . IndexViewData ,  error )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-18 21:06:44 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									settings ,  err  :=  getFrontendSettingsMap ( c ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										return  nil ,  err 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-03 04:54:06 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									prefsQuery  :=  m . GetPreferencesWithDefaultsQuery { OrgId :  c . OrgId ,  UserId :  c . UserId } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  err  :=  bus . Dispatch ( & prefsQuery ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  nil ,  err 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									prefs  :=  prefsQuery . Result 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 23:59:43 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									// Read locale from acccept-language
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									acceptLang  :=  c . Req . Header . Get ( "Accept-Language" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									locale  :=  "en-US" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  len ( acceptLang )  >  0  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										parts  :=  strings . Split ( acceptLang ,  "," ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										locale  =  parts [ 0 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-23 18:29:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									appUrl  :=  setting . AppUrl 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									appSubUrl  :=  setting . AppSubUrl 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									// special case when doing localhost call from phantomjs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  c . IsRenderCall  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										appUrl  =  fmt . Sprintf ( "%s://localhost:%s" ,  setting . Protocol ,  setting . HttpPort ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										appSubUrl  =  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										settings [ "appSubUrl" ]  =  "" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									var  data  =  dtos . IndexViewData { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										User :  & dtos . CurrentUser { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Id :              c . UserId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											IsSignedIn :      c . IsSignedIn , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Login :           c . Login , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Email :           c . Email , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Name :            c . Name , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 21:03:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											OrgCount :        c . OrgCount , 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											OrgId :           c . OrgId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											OrgName :         c . OrgName , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											OrgRole :         c . OrgRole , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											GravatarUrl :     dtos . GetGravatarUrl ( c . Email ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											IsGrafanaAdmin :  c . IsGrafanaAdmin , 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-03 04:54:06 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											LightTheme :      prefs . Theme  ==  "light" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Timezone :        prefs . Timezone , 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 23:59:43 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Locale :          locale , 
							 
						 
					
						
							
								
									
										
										
										
											2016-11-09 17:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											HelpFlags1 :      c . HelpFlags1 , 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 15:00:58 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										Settings :                 settings , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-12 03:36:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										Theme :                    prefs . Theme , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-23 18:29:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										AppUrl :                   appUrl , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										AppSubUrl :                appSubUrl , 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 15:00:58 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										GoogleAnalyticsId :        setting . GoogleAnalyticsId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										GoogleTagManagerId :       setting . GoogleTagManagerId , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										BuildVersion :             setting . BuildVersion , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										BuildCommit :              setting . BuildCommit , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										NewGrafanaVersion :        plugins . GrafanaLatestVersion , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										NewGrafanaVersionExists :  plugins . GrafanaHasUpdate , 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-01 14:40:13 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  setting . DisableGravatar  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-21 06:51:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										data . User . GravatarUrl  =  setting . AppSubUrl  +  "/public/img/transparent.png" 
							 
						 
					
						
							
								
									
										
										
										
											2015-05-01 14:40:13 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  len ( data . User . Name )  ==  0  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										data . User . Name  =  data . User . Login 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-03 17:46:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-04-02 15:21:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									themeUrlParam  :=  c . Query ( "theme" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									if  themeUrlParam  ==  "light"  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										data . User . LightTheme  =  true 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-18 15:48:37 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										data . Theme  =  "light" 
							 
						 
					
						
							
								
									
										
										
										
											2015-04-02 15:21:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-06-23 06:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  c . OrgRole  ==  m . ROLE_ADMIN  ||  c . OrgRole  ==  m . ROLE_EDITOR  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										data . NavTree  =  append ( data . NavTree ,  & dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 21:03:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Text :  "Create" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-04 23:00:22 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Id :    "create" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-23 06:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Icon :  "fa fa-fw fa-plus" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-14 00:58:33 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Url :   setting . AppSubUrl  +  "dashboard/new" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-23 06:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Children :  [ ] * dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-15 03:17:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ Text :  "Dashboard" ,  Icon :  "gicon gicon-dashboard-new" ,  Url :  setting . AppSubUrl  +  "/dashboard/new" } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-08 02:32:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ Text :  "Folder" ,  SubTitle :  "Create a new folder to organize your dashboards" ,  Id :  "folder" ,  Icon :  "gicon gicon-folder-new" ,  Url :  setting . AppSubUrl  +  "/dashboards/folder/new" } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-05 19:19:01 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ Text :  "Import" ,  SubTitle :  "Import dashboard from file or Grafana.com" ,  Id :  "import" ,  Icon :  "gicon gicon-dashboard-import" ,  Url :  setting . AppSubUrl  +  "/dashboard/import" } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-23 06:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-10 23:38:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-06-23 06:41:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									dashboardChildNavs  :=  [ ] * dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 18:32:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										{ Text :  "Home" ,  Url :  setting . AppSubUrl  +  "/" ,  Icon :  "fa fa-fw fa-home" ,  HideFromTabs :  true } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 19:51:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										{ Divider :  true ,  HideFromTabs :  true } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-05 19:25:59 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										{ Text :  "Manage" ,  Id :  "manage-dashboards" ,  Url :  setting . AppSubUrl  +  "/dashboards" ,  Icon :  "fa fa-fw fa-sitemap" } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 17:28:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										{ Text :  "Playlists" ,  Id :  "playlists" ,  Url :  setting . AppSubUrl  +  "/playlists" ,  Icon :  "fa fa-fw fa-film" } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-25 02:13:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										{ Text :  "Snapshots" ,  Id :  "snapshots" ,  Url :  setting . AppSubUrl  +  "/dashboard/snapshots" ,  Icon :  "icon-gf icon-gf-fw icon-gf-snapshot" } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-10 23:38:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									data . NavTree  =  append ( data . NavTree ,  & dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-10 23:38:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										Text :      "Dashboards" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 02:24:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										Id :        "dashboards" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 18:32:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										SubTitle :  "Manage dashboards & folders" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-15 03:17:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										Icon :      "gicon gicon-dashboard" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 19:51:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										Url :       setting . AppSubUrl  +  "/" , 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-10 23:38:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										Children :  dashboardChildNavs , 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 02:24:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  c . IsSignedIn  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 21:03:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										profileNode  :=  & dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 00:28:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Text :          c . SignedInUser . Name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											SubTitle :      c . SignedInUser . Login , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 05:17:34 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Id :            "profile" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Img :           data . User . GravatarUrl , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Url :           setting . AppSubUrl  +  "/profile" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											HideFromMenu :  true , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 02:24:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Children :  [ ] * dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 00:28:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ Text :  "Preferences" ,  Id :  "profile-settings" ,  Url :  setting . AppSubUrl  +  "/profile" ,  Icon :  "fa fa-fw fa-sliders" } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 02:24:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ Text :  "Change Password" ,  Id :  "change-password" ,  Url :  setting . AppSubUrl  +  "/profile/password" ,  Icon :  "fa fa-fw fa-lock" ,  HideFromMenu :  true } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 21:03:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ! setting . DisableSignoutMenu  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											// add sign out first
 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 00:28:24 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											profileNode . Children  =  append ( profileNode . Children ,  & dtos . NavLink { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												Text :  "Sign out" ,  Id :  "sign-out" ,  Url :  setting . AppSubUrl  +  "/logout" ,  Icon :  "fa fa-fw fa-sign-out" ,  Target :  "_self" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 21:03:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										data . NavTree  =  append ( data . NavTree ,  profileNode ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 02:24:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-25 20:32:26 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  setting . AlertingEnabled  &&  ( c . OrgRole  ==  m . ROLE_ADMIN  ||  c . OrgRole  ==  m . ROLE_EDITOR )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-16 21:21:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										alertChildNavs  :=  [ ] * dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-30 18:31:38 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											{ Text :  "Alert Rules" ,  Id :  "alert-list" ,  Url :  setting . AppSubUrl  +  "/alerting/list" ,  Icon :  "fa fa-fw fa-list-ul" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											{ Text :  "Notification channels" ,  Id :  "channels" ,  Url :  setting . AppSubUrl  +  "/alerting/notifications" ,  Icon :  "gicon gicon-alert-notification-channel" } , 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-16 21:21:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										data . NavTree  =  append ( data . NavTree ,  & dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-16 21:21:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Text :      "Alerting" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-30 22:37:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											SubTitle :  "Alert rules & notifications" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 02:24:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Id :        "alerting" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-15 03:17:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Icon :      "gicon gicon-alert" , 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-16 15:52:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Url :       setting . AppSubUrl  +  "/alerting/list" , 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-16 21:21:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Children :  alertChildNavs , 
							 
						 
					
						
							
								
									
										
										
										
											2016-05-03 22:46:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-01-11 04:37:11 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									enabledPlugins ,  err  :=  plugins . GetEnabledPlugins ( c . OrgId ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-03 23:43:55 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return  nil ,  err 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-12-22 06:09:27 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									for  _ ,  plugin  :=  range  enabledPlugins . Apps  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-12 01:03:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  plugin . Pinned  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-22 02:07:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											appLink  :=  & dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-12 01:03:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												Text :  plugin . Name , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 02:24:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												Id :    "plugin-page-"  +  plugin . Id , 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-22 17:15:47 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												Url :   plugin . DefaultNavUrl , 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-12 01:03:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												Img :   plugin . Info . Logos . Small , 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-09 21:06:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-22 02:07:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											for  _ ,  include  :=  range  plugin . Includes  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-25 20:00:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  ! c . HasUserRole ( include . Role )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-22 02:07:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  include . Type  ==  "page"  &&  include . AddToNav  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													link  :=  & dtos . NavLink { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														Url :   setting . AppSubUrl  +  "/plugins/"  +  plugin . Id  +  "/page/"  +  include . Slug , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														Text :  include . Name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													appLink . Children  =  append ( appLink . Children ,  link ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-01 18:07:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-25 20:00:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-03-22 02:07:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												if  include . Type  ==  "dashboard"  &&  include . AddToNav  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													link  :=  & dtos . NavLink { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														Url :   setting . AppSubUrl  +  "/dashboard/db/"  +  include . Slug , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
														Text :  include . Name , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													appLink . Children  =  append ( appLink . Children ,  link ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-27 20:39:51 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  len ( appLink . Children )  >  0  &&  c . OrgRole  ==  m . ROLE_ADMIN  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-22 02:07:08 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												appLink . Children  =  append ( appLink . Children ,  & dtos . NavLink { Divider :  true } ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-25 02:13:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												appLink . Children  =  append ( appLink . Children ,  & dtos . NavLink { Text :  "Plugin Config" ,  Icon :  "fa fa-fw fa-cog" ,  Url :  setting . AppSubUrl  +  "/plugins/"  +  plugin . Id  +  "/edit" } ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-09 21:06:23 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-04-25 20:00:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  len ( appLink . Children )  >  0  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												data . NavTree  =  append ( data . NavTree ,  appLink ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-25 20:00:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2015-10-06 17:20:50 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-21 15:30:39 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-11 14:30:07 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 20:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  c . OrgRole  ==  m . ROLE_ADMIN  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										cfgNode  :=  & dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-30 22:37:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Id :        "cfg" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Text :      "Configuration" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											SubTitle :  "Organization: "  +  c . OrgName , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Icon :      "fa fa-fw fa-cog" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Url :       setting . AppSubUrl  +  "/datasources" , 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-20 11:00:29 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											Children :  [ ] * dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 20:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Text :         "Data Sources" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-27 14:33:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Icon :         "gicon gicon-datasources" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Description :  "Add and configure data sources" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Id :           "datasources" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Url :          setting . AppSubUrl  +  "/datasources" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 20:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-13 18:21:33 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Text :         "Users" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Id :           "users" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 20:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Description :  "Manage org members" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-10-25 02:13:53 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Icon :         "icon-gf icon-gf-fw icon-gf-users" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Url :          setting . AppSubUrl  +  "/org/users" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 20:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-30 22:37:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Text :         "Teams" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 17:47:21 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Id :           "teams" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 20:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Description :  "Manage org groups" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-08 23:25:45 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Icon :         "gicon gicon-team" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Url :          setting . AppSubUrl  +  "/org/teams" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-18 20:49:04 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-11-30 22:37:03 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Text :         "Plugins" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Id :           "plugins" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Description :  "View and configure plugins" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Icon :         "icon-gf icon-gf-fw icon-gf-apps" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Url :          setting . AppSubUrl  +  "/plugins" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Text :         "Preferences" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Id :           "org-settings" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Description :  "Organization preferences" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Icon :         "fa fa-fw fa-sliders" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Url :          setting . AppSubUrl  +  "/org" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Text :         "API Keys" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 02:24:16 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Id :           "apikeys" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													Description :  "Create & manage API keys" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Icon :         "fa fa-fw fa-key" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													Url :          setting . AppSubUrl  +  "/org/apikeys" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-21 01:31:09 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} , 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 20:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 19:51:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  c . IsGrafanaAdmin  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cfgNode . Children  =  append ( cfgNode . Children ,  & dtos . NavLink { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												Divider :  true ,  HideFromTabs :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											cfgNode . Children  =  append ( cfgNode . Children ,  & dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 20:49:15 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												Text :          "Server Admin" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												HideFromTabs :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												SubTitle :      "Manage all users & orgs" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												Id :            "admin" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												Icon :          "fa fa-fw fa-shield" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												Url :           setting . AppSubUrl  +  "/admin/users" , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 19:51:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												Children :  [ ] * dtos . NavLink { 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 20:49:15 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
													{ Text :  "Users" ,  Id :  "global-users" ,  Url :  setting . AppSubUrl  +  "/admin/users" ,  Icon :  "icon-gf icon-gf-fw icon-gf-users" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													{ Text :  "Orgs" ,  Id :  "global-orgs" ,  Url :  setting . AppSubUrl  +  "/admin/orgs" ,  Icon :  "gicon gicon-org" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													{ Text :  "Settings" ,  Id :  "server-settings" ,  Url :  setting . AppSubUrl  +  "/admin/settings" ,  Icon :  "fa fa-fw fa-sliders" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													{ Text :  "Stats" ,  Id :  "server-stats" ,  Url :  setting . AppSubUrl  +  "/admin/stats" ,  Icon :  "fa fa-fw fa-bar-chart" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
													{ Text :  "Style Guide" ,  Id :  "styleguide" ,  Url :  setting . AppSubUrl  +  "/styleguide" ,  Icon :  "fa fa-fw fa-eyedropper" } , 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-01 19:51:46 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 20:49:12 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-15 23:52:52 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										data . NavTree  =  append ( data . NavTree ,  cfgNode ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-02-15 00:37:05 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 21:03:49 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									data . NavTree  =  append ( data . NavTree ,  & dtos . NavLink { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										Text :          "Help" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										Id :            "help" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										Url :           "#" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										Icon :          "fa fa-fw fa-question" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										HideFromMenu :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										Children :  [ ] * dtos . NavLink { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											{ Text :  "Keyboard shortcuts" ,  Url :  "/shortcuts" ,  Icon :  "fa fa-fw fa-keyboard-o" ,  Target :  "_self" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											{ Text :  "Community site" ,  Url :  "http://community.grafana.com" ,  Icon :  "fa fa-fw fa-comment" ,  Target :  "_blank" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											{ Text :  "Documentation" ,  Url :  "http://docs.grafana.org" ,  Icon :  "fa fa-fw fa-file" ,  Target :  "_blank" } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									return  & data ,  nil 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								func  Index ( c  * middleware . Context )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  data ,  err  :=  setIndexViewData ( c ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										c . Handle ( 500 ,  "Failed to get settings" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										c . HTML ( 200 ,  "index" ,  data ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-18 23:28:15 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								func  NotFoundHandler ( c  * middleware . Context )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									if  c . IsApiRequest ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-03-23 03:14:00 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										c . JsonApiErr ( 404 ,  "Not found" ,  nil ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  data ,  err  :=  setIndexViewData ( c ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
										c . Handle ( 500 ,  "Failed to get settings" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										return 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-20 16:43:10 +08:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										c . HTML ( 404 ,  "index" ,  data ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-01-29 19:10:34 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}