grafana/public/app/routes/routes.ts

351 lines
11 KiB
TypeScript
Raw Normal View History

2017-12-20 05:33:33 -06:00
import './dashboard_loaders';
import './ReactContainer';
import { applyRouteRegistrationHandlers } from './registry';
2018-04-26 04:58:42 -05:00
2019-02-04 06:49:14 -06:00
// Pages
2018-09-07 10:55:38 -05:00
import ServerStats from 'app/features/admin/ServerStats';
2018-09-02 09:11:21 -05:00
import AlertRuleList from 'app/features/alerting/AlertRuleList';
import TeamPages from 'app/features/teams/TeamPages';
import TeamList from 'app/features/teams/TeamList';
2018-09-25 09:23:43 -05:00
import ApiKeys from 'app/features/api-keys/ApiKeysPage';
2018-09-25 07:53:55 -05:00
import PluginListPage from 'app/features/plugins/PluginListPage';
import FolderSettingsPage from 'app/features/folders/FolderSettingsPage';
import FolderPermissions from 'app/features/folders/FolderPermissions';
2019-01-23 13:21:07 -06:00
import CreateFolderCtrl from 'app/features/folders/CreateFolderCtrl';
import FolderDashboardsCtrl from 'app/features/folders/FolderDashboardsCtrl';
import DashboardImportCtrl from 'app/features/manage-dashboards/DashboardImportCtrl';
import DataSourcesListPage from 'app/features/datasources/DataSourcesListPage';
2018-10-02 09:18:42 -05:00
import NewDataSourcePage from '../features/datasources/NewDataSourcePage';
2018-10-03 02:43:10 -05:00
import UsersListPage from 'app/features/users/UsersListPage';
2018-10-17 07:36:18 -05:00
import DataSourceDashboards from 'app/features/datasources/DataSourceDashboards';
import DataSourceSettingsPage from '../features/datasources/settings/DataSourceSettingsPage';
2018-10-25 00:45:22 -05:00
import OrgDetailsPage from '../features/org/OrgDetailsPage';
import SoloPanelPage from '../features/dashboard/containers/SoloPanelPage';
2019-02-02 12:23:19 -06:00
import DashboardPage from '../features/dashboard/containers/DashboardPage';
import config from 'app/core/config';
2016-02-09 04:17:49 -06:00
2019-02-04 06:49:14 -06:00
// Types
import { DashboardRouteInfo } from 'app/types';
/** @ngInject */
export function setupAngularRoutes($routeProvider, $locationProvider) {
2016-02-09 04:17:49 -06:00
$locationProvider.html5Mode(true);
$routeProvider
2017-12-20 05:33:33 -06:00
.when('/', {
2019-02-03 07:53:42 -06:00
template: '<react-container />',
2017-12-20 05:33:33 -06:00
pageClass: 'page-dashboard',
2019-02-04 06:49:14 -06:00
routeInfo: DashboardRouteInfo.Home,
2019-02-03 07:53:42 -06:00
reloadOnSearch: false,
resolve: {
component: () => DashboardPage,
},
})
.when('/d/:uid/:slug', {
2019-02-02 12:23:19 -06:00
template: '<react-container />',
pageClass: 'page-dashboard',
2019-02-04 06:49:14 -06:00
routeInfo: DashboardRouteInfo.Normal,
2019-02-02 12:23:19 -06:00
reloadOnSearch: false,
resolve: {
component: () => DashboardPage,
},
})
.when('/d/:uid', {
2019-02-03 07:53:42 -06:00
template: '<react-container />',
pageClass: 'page-dashboard',
2019-02-03 07:53:42 -06:00
reloadOnSearch: false,
2019-02-04 06:49:14 -06:00
routeInfo: DashboardRouteInfo.Normal,
2019-02-03 07:53:42 -06:00
resolve: {
component: () => DashboardPage,
},
})
2017-12-20 05:33:33 -06:00
.when('/dashboard/:type/:slug', {
2019-02-03 07:53:42 -06:00
template: '<react-container />',
pageClass: 'page-dashboard',
2019-02-04 10:36:04 -06:00
routeInfo: DashboardRouteInfo.Normal,
2019-02-04 06:49:14 -06:00
reloadOnSearch: false,
resolve: {
component: () => DashboardPage,
},
})
.when('/dashboard/new', {
template: '<react-container />',
pageClass: 'page-dashboard',
routeInfo: DashboardRouteInfo.New,
2019-02-03 07:53:42 -06:00
reloadOnSearch: false,
resolve: {
component: () => DashboardPage,
},
})
.when('/d-solo/:uid/:slug', {
template: '<react-container />',
pageClass: 'dashboard-solo',
2019-02-04 06:49:14 -06:00
routeInfo: DashboardRouteInfo.Normal,
reloadOnSearch: false,
resolve: {
component: () => SoloPanelPage,
},
})
2017-12-20 05:33:33 -06:00
.when('/dashboard-solo/:type/:slug', {
template: '<react-container />',
pageClass: 'dashboard-solo',
2019-02-04 10:36:04 -06:00
routeInfo: DashboardRouteInfo.Normal,
reloadOnSearch: false,
resolve: {
component: () => SoloPanelPage,
},
})
2017-12-20 05:33:33 -06:00
.when('/dashboard/import', {
templateUrl: 'public/app/features/manage-dashboards/partials/dashboard_import.html',
controller: DashboardImportCtrl,
2017-12-20 05:33:33 -06:00
controllerAs: 'ctrl',
})
.when('/datasources', {
template: '<react-container />',
resolve: {
component: () => DataSourcesListPage,
},
2017-12-20 05:33:33 -06:00
})
2018-10-24 09:17:25 -05:00
.when('/datasources/edit/:id/', {
template: '<react-container />',
resolve: {
component: () => DataSourceSettingsPage,
2018-10-24 09:17:25 -05:00
},
})
2018-01-18 10:42:40 -06:00
.when('/datasources/edit/:id/dashboards', {
2018-10-08 07:09:02 -05:00
template: '<react-container />',
resolve: {
2018-10-17 07:36:18 -05:00
component: () => DataSourceDashboards,
2018-10-08 07:09:02 -05:00
},
2017-12-20 05:33:33 -06:00
})
.when('/datasources/new', {
2018-10-02 09:18:42 -05:00
template: '<react-container />',
resolve: {
component: () => NewDataSourcePage,
},
2017-12-20 05:33:33 -06:00
})
.when('/dashboards', {
templateUrl: 'public/app/features/manage-dashboards/partials/dashboard_list.html',
2017-12-20 05:33:33 -06:00
controller: 'DashboardListCtrl',
controllerAs: 'ctrl',
})
.when('/dashboards/folder/new', {
2019-01-23 13:21:07 -06:00
templateUrl: 'public/app/features/folders/partials/create_folder.html',
controller: CreateFolderCtrl,
2017-12-20 05:33:33 -06:00
controllerAs: 'ctrl',
})
.when('/dashboards/f/:uid/:slug/permissions', {
template: '<react-container />',
resolve: {
component: () => FolderPermissions,
},
})
.when('/dashboards/f/:uid/:slug/settings', {
template: '<react-container />',
resolve: {
component: () => FolderSettingsPage,
},
})
.when('/dashboards/f/:uid/:slug', {
2019-01-23 13:21:07 -06:00
templateUrl: 'public/app/features/folders/partials/folder_dashboards.html',
controller: FolderDashboardsCtrl,
2017-12-20 05:33:33 -06:00
controllerAs: 'ctrl',
})
.when('/dashboards/f/:uid', {
templateUrl: 'public/app/features/folders/partials/folder_dashboards.html',
controller: FolderDashboardsCtrl,
controllerAs: 'ctrl',
})
.when('/explore', {
2018-04-26 04:58:42 -05:00
template: '<react-container />',
reloadOnSearch: false,
2018-04-26 04:58:42 -05:00
resolve: {
roles: () => (config.viewersCanEdit ? [] : ['Editor', 'Admin']),
component: () => import(/* webpackChunkName: "explore" */ 'app/features/explore/Wrapper'),
2018-04-26 04:58:42 -05:00
},
})
2017-12-20 05:33:33 -06:00
.when('/org', {
2018-10-25 00:45:22 -05:00
template: '<react-container />',
resolve: {
component: () => OrgDetailsPage,
},
2017-12-20 05:33:33 -06:00
})
.when('/org/new', {
templateUrl: 'public/app/features/org/partials/newOrg.html',
controller: 'NewOrgCtrl',
})
.when('/org/users', {
2018-10-03 02:43:10 -05:00
template: '<react-container />',
resolve: {
component: () => UsersListPage,
},
2017-12-20 05:33:33 -06:00
})
.when('/org/users/invite', {
templateUrl: 'public/app/features/org/partials/invite.html',
controller: 'UserInviteCtrl',
controllerAs: 'ctrl',
})
.when('/org/apikeys', {
2018-09-25 09:23:43 -05:00
template: '<react-container />',
resolve: {
roles: () => ['Editor', 'Admin'],
component: () => ApiKeys,
},
})
2017-12-20 05:33:33 -06:00
.when('/org/teams', {
template: '<react-container />',
resolve: {
roles: () => ['Editor', 'Admin'],
component: () => TeamList,
},
2017-12-20 05:33:33 -06:00
})
.when('/org/teams/new', {
2018-10-31 14:21:16 -05:00
templateUrl: 'public/app/features/teams/partials/create_team.html',
controller: 'CreateTeamCtrl',
controllerAs: 'ctrl',
})
.when('/org/teams/edit/:id/:page?', {
template: '<react-container />',
resolve: {
roles: () => ['Admin'],
component: () => TeamPages,
},
2017-12-20 05:33:33 -06:00
})
.when('/profile', {
templateUrl: 'public/app/features/profile/partials/profile.html',
2017-12-20 05:33:33 -06:00
controller: 'ProfileCtrl',
controllerAs: 'ctrl',
})
.when('/profile/password', {
templateUrl: 'public/app/features/profile/partials/change_password.html',
2017-12-20 05:33:33 -06:00
controller: 'ChangePasswordCtrl',
})
.when('/profile/select-org', {
templateUrl: 'public/app/features/org/partials/select_org.html',
controller: 'SelectOrgCtrl',
})
// ADMIN
2017-12-20 05:33:33 -06:00
.when('/admin', {
templateUrl: 'public/app/features/admin/partials/admin_home.html',
controller: 'AdminHomeCtrl',
controllerAs: 'ctrl',
})
.when('/admin/settings', {
templateUrl: 'public/app/features/admin/partials/settings.html',
controller: 'AdminSettingsCtrl',
controllerAs: 'ctrl',
})
.when('/admin/users', {
templateUrl: 'public/app/features/admin/partials/users.html',
controller: 'AdminListUsersCtrl',
controllerAs: 'ctrl',
})
.when('/admin/users/create', {
templateUrl: 'public/app/features/admin/partials/new_user.html',
controller: 'AdminEditUserCtrl',
})
.when('/admin/users/edit/:id', {
templateUrl: 'public/app/features/admin/partials/edit_user.html',
controller: 'AdminEditUserCtrl',
})
.when('/admin/orgs', {
templateUrl: 'public/app/features/admin/partials/orgs.html',
controller: 'AdminListOrgsCtrl',
controllerAs: 'ctrl',
})
.when('/admin/orgs/edit/:id', {
templateUrl: 'public/app/features/admin/partials/edit_org.html',
controller: 'AdminEditOrgCtrl',
controllerAs: 'ctrl',
})
.when('/admin/stats', {
template: '<react-container />',
resolve: {
component: () => ServerStats,
},
})
// LOGIN / SIGNUP
2017-12-20 05:33:33 -06:00
.when('/login', {
templateUrl: 'public/app/partials/login.html',
controller: 'LoginCtrl',
pageClass: 'login-page sidemenu-hidden',
})
.when('/invite/:code', {
templateUrl: 'public/app/partials/signup_invited.html',
controller: 'InvitedCtrl',
pageClass: 'sidemenu-hidden',
})
.when('/signup', {
templateUrl: 'public/app/partials/signup_step2.html',
controller: 'SignUpCtrl',
pageClass: 'sidemenu-hidden',
})
.when('/user/password/send-reset-email', {
templateUrl: 'public/app/partials/reset_password.html',
controller: 'ResetPasswordCtrl',
pageClass: 'sidemenu-hidden',
})
.when('/user/password/reset', {
templateUrl: 'public/app/partials/reset_password.html',
controller: 'ResetPasswordCtrl',
pageClass: 'sidemenu-hidden',
})
.when('/dashboard/snapshots', {
templateUrl: 'public/app/features/manage-dashboards/partials/snapshot_list.html',
controller: 'SnapshotListCtrl',
2017-12-20 05:33:33 -06:00
controllerAs: 'ctrl',
})
.when('/plugins', {
2018-09-25 07:53:55 -05:00
template: '<react-container />',
resolve: {
component: () => PluginListPage,
},
2017-12-20 05:33:33 -06:00
})
.when('/plugins/:pluginId/edit', {
templateUrl: 'public/app/features/plugins/partials/plugin_edit.html',
controller: 'PluginEditCtrl',
controllerAs: 'ctrl',
})
.when('/plugins/:pluginId/page/:slug', {
templateUrl: 'public/app/features/plugins/partials/plugin_page.html',
controller: 'AppPageCtrl',
controllerAs: 'ctrl',
})
.when('/styleguide/:page?', {
controller: 'StyleGuideCtrl',
controllerAs: 'ctrl',
2018-09-10 06:38:45 -05:00
templateUrl: 'public/app/features/admin/partials/styleguide.html',
2017-12-20 05:33:33 -06:00
})
.when('/alerting', {
redirectTo: '/alerting/list',
})
.when('/alerting/list', {
template: '<react-container />',
reloadOnSearch: false,
resolve: {
component: () => AlertRuleList,
},
})
2017-12-20 05:33:33 -06:00
.when('/alerting/notifications', {
templateUrl: 'public/app/features/alerting/partials/notifications_list.html',
2017-12-20 05:33:33 -06:00
controller: 'AlertNotificationsListCtrl',
controllerAs: 'ctrl',
})
2017-12-20 05:33:33 -06:00
.when('/alerting/notification/new', {
templateUrl: 'public/app/features/alerting/partials/notification_edit.html',
2017-12-20 05:33:33 -06:00
controller: 'AlertNotificationEditCtrl',
controllerAs: 'ctrl',
})
2017-12-20 05:33:33 -06:00
.when('/alerting/notification/:id/edit', {
templateUrl: 'public/app/features/alerting/partials/notification_edit.html',
2017-12-20 05:33:33 -06:00
controller: 'AlertNotificationEditCtrl',
controllerAs: 'ctrl',
})
.otherwise({
2017-12-20 05:33:33 -06:00
templateUrl: 'public/app/partials/error.html',
controller: 'ErrorCtrl',
});
applyRouteRegistrationHandlers($routeProvider);
2016-02-09 04:17:49 -06:00
}