routes.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. import './dashboard_loaders';
  2. import './ReactContainer';
  3. import { applyRouteRegistrationHandlers } from './registry';
  4. import ServerStats from 'app/features/admin/ServerStats';
  5. import AlertRuleList from 'app/features/alerting/AlertRuleList';
  6. import TeamPages from 'app/features/teams/TeamPages';
  7. import TeamList from 'app/features/teams/TeamList';
  8. import ApiKeys from 'app/features/api-keys/ApiKeysPage';
  9. import PluginListPage from 'app/features/plugins/PluginListPage';
  10. import FolderSettingsPage from 'app/features/folders/FolderSettingsPage';
  11. import FolderPermissions from 'app/features/folders/FolderPermissions';
  12. import CreateFolderCtrl from 'app/features/folders/CreateFolderCtrl';
  13. import FolderDashboardsCtrl from 'app/features/folders/FolderDashboardsCtrl';
  14. import DashboardImportCtrl from 'app/features/manage-dashboards/DashboardImportCtrl';
  15. import DataSourcesListPage from 'app/features/datasources/DataSourcesListPage';
  16. import NewDataSourcePage from '../features/datasources/NewDataSourcePage';
  17. import UsersListPage from 'app/features/users/UsersListPage';
  18. import DataSourceDashboards from 'app/features/datasources/DataSourceDashboards';
  19. import DataSourceSettingsPage from '../features/datasources/settings/DataSourceSettingsPage';
  20. import OrgDetailsPage from '../features/org/OrgDetailsPage';
  21. import SoloPanelPage from '../features/dashboard/containers/SoloPanelPage';
  22. import config from 'app/core/config';
  23. /** @ngInject */
  24. export function setupAngularRoutes($routeProvider, $locationProvider) {
  25. $locationProvider.html5Mode(true);
  26. $routeProvider
  27. .when('/', {
  28. templateUrl: 'public/app/partials/dashboard.html',
  29. controller: 'LoadDashboardCtrl',
  30. reloadOnSearch: false,
  31. pageClass: 'page-dashboard',
  32. })
  33. .when('/d/:uid/:slug', {
  34. templateUrl: 'public/app/partials/dashboard.html',
  35. controller: 'LoadDashboardCtrl',
  36. reloadOnSearch: false,
  37. pageClass: 'page-dashboard',
  38. })
  39. .when('/d/:uid', {
  40. templateUrl: 'public/app/partials/dashboard.html',
  41. controller: 'LoadDashboardCtrl',
  42. reloadOnSearch: false,
  43. pageClass: 'page-dashboard',
  44. })
  45. .when('/dashboard/:type/:slug', {
  46. templateUrl: 'public/app/partials/dashboard.html',
  47. controller: 'LoadDashboardCtrl',
  48. reloadOnSearch: false,
  49. pageClass: 'page-dashboard',
  50. })
  51. .when('/d-solo/:uid/:slug', {
  52. template: '<react-container />',
  53. pageClass: 'dashboard-solo',
  54. resolve: {
  55. component: () => SoloPanelPage,
  56. },
  57. })
  58. .when('/dashboard-solo/:type/:slug', {
  59. template: '<react-container />',
  60. pageClass: 'dashboard-solo',
  61. resolve: {
  62. component: () => SoloPanelPage,
  63. },
  64. })
  65. .when('/dashboard/new', {
  66. templateUrl: 'public/app/partials/dashboard.html',
  67. controller: 'NewDashboardCtrl',
  68. reloadOnSearch: false,
  69. pageClass: 'page-dashboard',
  70. })
  71. .when('/dashboard/import', {
  72. templateUrl: 'public/app/features/manage-dashboards/partials/dashboard_import.html',
  73. controller: DashboardImportCtrl,
  74. controllerAs: 'ctrl',
  75. })
  76. .when('/datasources', {
  77. template: '<react-container />',
  78. resolve: {
  79. component: () => DataSourcesListPage,
  80. },
  81. })
  82. .when('/datasources/edit/:id/', {
  83. template: '<react-container />',
  84. resolve: {
  85. component: () => DataSourceSettingsPage,
  86. },
  87. })
  88. .when('/datasources/edit/:id/dashboards', {
  89. template: '<react-container />',
  90. resolve: {
  91. component: () => DataSourceDashboards,
  92. },
  93. })
  94. .when('/datasources/new', {
  95. template: '<react-container />',
  96. resolve: {
  97. component: () => NewDataSourcePage,
  98. },
  99. })
  100. .when('/dashboards', {
  101. templateUrl: 'public/app/features/manage-dashboards/partials/dashboard_list.html',
  102. controller: 'DashboardListCtrl',
  103. controllerAs: 'ctrl',
  104. })
  105. .when('/dashboards/folder/new', {
  106. templateUrl: 'public/app/features/folders/partials/create_folder.html',
  107. controller: CreateFolderCtrl,
  108. controllerAs: 'ctrl',
  109. })
  110. .when('/dashboards/f/:uid/:slug/permissions', {
  111. template: '<react-container />',
  112. resolve: {
  113. component: () => FolderPermissions,
  114. },
  115. })
  116. .when('/dashboards/f/:uid/:slug/settings', {
  117. template: '<react-container />',
  118. resolve: {
  119. component: () => FolderSettingsPage,
  120. },
  121. })
  122. .when('/dashboards/f/:uid/:slug', {
  123. templateUrl: 'public/app/features/folders/partials/folder_dashboards.html',
  124. controller: FolderDashboardsCtrl,
  125. controllerAs: 'ctrl',
  126. })
  127. .when('/dashboards/f/:uid', {
  128. templateUrl: 'public/app/features/dashboard/partials/folder_dashboards.html',
  129. controller: 'FolderDashboardsCtrl',
  130. controllerAs: 'ctrl',
  131. })
  132. .when('/explore', {
  133. template: '<react-container />',
  134. reloadOnSearch: false,
  135. resolve: {
  136. roles: () => (config.viewersCanEdit ? [] : ['Editor', 'Admin']),
  137. component: () => import(/* webpackChunkName: "explore" */ 'app/features/explore/Wrapper'),
  138. },
  139. })
  140. .when('/org', {
  141. template: '<react-container />',
  142. resolve: {
  143. component: () => OrgDetailsPage,
  144. },
  145. })
  146. .when('/org/new', {
  147. templateUrl: 'public/app/features/org/partials/newOrg.html',
  148. controller: 'NewOrgCtrl',
  149. })
  150. .when('/org/users', {
  151. template: '<react-container />',
  152. resolve: {
  153. component: () => UsersListPage,
  154. },
  155. })
  156. .when('/org/users/invite', {
  157. templateUrl: 'public/app/features/org/partials/invite.html',
  158. controller: 'UserInviteCtrl',
  159. controllerAs: 'ctrl',
  160. })
  161. .when('/org/apikeys', {
  162. template: '<react-container />',
  163. resolve: {
  164. roles: () => ['Editor', 'Admin'],
  165. component: () => ApiKeys,
  166. },
  167. })
  168. .when('/org/teams', {
  169. template: '<react-container />',
  170. resolve: {
  171. roles: () => ['Editor', 'Admin'],
  172. component: () => TeamList,
  173. },
  174. })
  175. .when('/org/teams/new', {
  176. templateUrl: 'public/app/features/teams/partials/create_team.html',
  177. controller: 'CreateTeamCtrl',
  178. controllerAs: 'ctrl',
  179. })
  180. .when('/org/teams/edit/:id/:page?', {
  181. template: '<react-container />',
  182. resolve: {
  183. roles: () => ['Admin'],
  184. component: () => TeamPages,
  185. },
  186. })
  187. .when('/profile', {
  188. templateUrl: 'public/app/features/profile/partials/profile.html',
  189. controller: 'ProfileCtrl',
  190. controllerAs: 'ctrl',
  191. })
  192. .when('/profile/password', {
  193. templateUrl: 'public/app/features/profile/partials/change_password.html',
  194. controller: 'ChangePasswordCtrl',
  195. })
  196. .when('/profile/select-org', {
  197. templateUrl: 'public/app/features/org/partials/select_org.html',
  198. controller: 'SelectOrgCtrl',
  199. })
  200. // ADMIN
  201. .when('/admin', {
  202. templateUrl: 'public/app/features/admin/partials/admin_home.html',
  203. controller: 'AdminHomeCtrl',
  204. controllerAs: 'ctrl',
  205. })
  206. .when('/admin/settings', {
  207. templateUrl: 'public/app/features/admin/partials/settings.html',
  208. controller: 'AdminSettingsCtrl',
  209. controllerAs: 'ctrl',
  210. })
  211. .when('/admin/users', {
  212. templateUrl: 'public/app/features/admin/partials/users.html',
  213. controller: 'AdminListUsersCtrl',
  214. controllerAs: 'ctrl',
  215. })
  216. .when('/admin/users/create', {
  217. templateUrl: 'public/app/features/admin/partials/new_user.html',
  218. controller: 'AdminEditUserCtrl',
  219. })
  220. .when('/admin/users/edit/:id', {
  221. templateUrl: 'public/app/features/admin/partials/edit_user.html',
  222. controller: 'AdminEditUserCtrl',
  223. })
  224. .when('/admin/orgs', {
  225. templateUrl: 'public/app/features/admin/partials/orgs.html',
  226. controller: 'AdminListOrgsCtrl',
  227. controllerAs: 'ctrl',
  228. })
  229. .when('/admin/orgs/edit/:id', {
  230. templateUrl: 'public/app/features/admin/partials/edit_org.html',
  231. controller: 'AdminEditOrgCtrl',
  232. controllerAs: 'ctrl',
  233. })
  234. .when('/admin/stats', {
  235. template: '<react-container />',
  236. resolve: {
  237. component: () => ServerStats,
  238. },
  239. })
  240. // LOGIN / SIGNUP
  241. .when('/login', {
  242. templateUrl: 'public/app/partials/login.html',
  243. controller: 'LoginCtrl',
  244. pageClass: 'login-page sidemenu-hidden',
  245. })
  246. .when('/invite/:code', {
  247. templateUrl: 'public/app/partials/signup_invited.html',
  248. controller: 'InvitedCtrl',
  249. pageClass: 'sidemenu-hidden',
  250. })
  251. .when('/signup', {
  252. templateUrl: 'public/app/partials/signup_step2.html',
  253. controller: 'SignUpCtrl',
  254. pageClass: 'sidemenu-hidden',
  255. })
  256. .when('/user/password/send-reset-email', {
  257. templateUrl: 'public/app/partials/reset_password.html',
  258. controller: 'ResetPasswordCtrl',
  259. pageClass: 'sidemenu-hidden',
  260. })
  261. .when('/user/password/reset', {
  262. templateUrl: 'public/app/partials/reset_password.html',
  263. controller: 'ResetPasswordCtrl',
  264. pageClass: 'sidemenu-hidden',
  265. })
  266. .when('/dashboard/snapshots', {
  267. templateUrl: 'public/app/features/manage-dashboards/partials/snapshot_list.html',
  268. controller: 'SnapshotListCtrl',
  269. controllerAs: 'ctrl',
  270. })
  271. .when('/plugins', {
  272. template: '<react-container />',
  273. resolve: {
  274. component: () => PluginListPage,
  275. },
  276. })
  277. .when('/plugins/:pluginId/edit', {
  278. templateUrl: 'public/app/features/plugins/partials/plugin_edit.html',
  279. controller: 'PluginEditCtrl',
  280. controllerAs: 'ctrl',
  281. })
  282. .when('/plugins/:pluginId/page/:slug', {
  283. templateUrl: 'public/app/features/plugins/partials/plugin_page.html',
  284. controller: 'AppPageCtrl',
  285. controllerAs: 'ctrl',
  286. })
  287. .when('/styleguide/:page?', {
  288. controller: 'StyleGuideCtrl',
  289. controllerAs: 'ctrl',
  290. templateUrl: 'public/app/features/admin/partials/styleguide.html',
  291. })
  292. .when('/alerting', {
  293. redirectTo: '/alerting/list',
  294. })
  295. .when('/alerting/list', {
  296. template: '<react-container />',
  297. reloadOnSearch: false,
  298. resolve: {
  299. component: () => AlertRuleList,
  300. },
  301. })
  302. .when('/alerting/notifications', {
  303. templateUrl: 'public/app/features/alerting/partials/notifications_list.html',
  304. controller: 'AlertNotificationsListCtrl',
  305. controllerAs: 'ctrl',
  306. })
  307. .when('/alerting/notification/new', {
  308. templateUrl: 'public/app/features/alerting/partials/notification_edit.html',
  309. controller: 'AlertNotificationEditCtrl',
  310. controllerAs: 'ctrl',
  311. })
  312. .when('/alerting/notification/:id/edit', {
  313. templateUrl: 'public/app/features/alerting/partials/notification_edit.html',
  314. controller: 'AlertNotificationEditCtrl',
  315. controllerAs: 'ctrl',
  316. })
  317. .otherwise({
  318. templateUrl: 'public/app/partials/error.html',
  319. controller: 'ErrorCtrl',
  320. });
  321. applyRouteRegistrationHandlers($routeProvider);
  322. }