Commit 5e1a3c9e by Torkel Ödegaard Committed by GitHub

Merge pull request #15023 from grafana/improve-organization

More file re-organization & clean-up
parents ecbda1af 05738258
import './inspect_ctrl';
import './json_editor_ctrl'; import './json_editor_ctrl';
import './login_ctrl'; import './login_ctrl';
import './invited_ctrl'; import './invited_ctrl';
......
import angular from 'angular';
import _ from 'lodash';
import $ from 'jquery';
import coreModule from '../core_module';
export class InspectCtrl {
/** @ngInject */
constructor($scope, $sanitize) {
const model = $scope.inspector;
$scope.init = function() {
$scope.editor = { index: 0 };
if (!model.error) {
return;
}
if (_.isString(model.error.data)) {
$scope.response = $('<div>' + model.error.data + '</div>').text();
} else if (model.error.data) {
if (model.error.data.response) {
$scope.response = $sanitize(model.error.data.response);
} else {
$scope.response = angular.toJson(model.error.data, true);
}
} else if (model.error.message) {
$scope.message = model.error.message;
}
if (model.error.config && model.error.config.params) {
$scope.request_parameters = _.map(model.error.config.params, (value, key) => {
return { key: key, value: value };
});
}
if (model.error.stack) {
$scope.editor.index = 3;
$scope.stack_trace = model.error.stack;
$scope.message = model.error.message;
}
if (model.error.config && model.error.config.data) {
$scope.editor.index = 2;
if (_.isString(model.error.config.data)) {
$scope.request_parameters = this.getParametersFromQueryString(model.error.config.data);
} else {
$scope.request_parameters = _.map(model.error.config.data, (value, key) => {
return { key: key, value: angular.toJson(value, true) };
});
}
}
};
}
getParametersFromQueryString(queryString) {
const result = [];
const parameters = queryString.split('&');
for (let i = 0; i < parameters.length; i++) {
const keyValue = parameters[i].split('=');
if (keyValue[1].length > 0) {
result.push({
key: keyValue[0],
value: (window as any).unescape(keyValue[1]),
});
}
}
return result;
}
}
coreModule.controller('InspectCtrl', InspectCtrl);
import React from 'react'; import React from 'react';
import _ from 'lodash'; import _ from 'lodash';
import config from 'app/core/config'; import config from 'app/core/config';
import { PanelModel } from '../panel_model'; import { PanelModel } from '../../panel_model';
import { DashboardModel } from '../dashboard_model'; import { DashboardModel } from '../../dashboard_model';
import store from 'app/core/store'; import store from 'app/core/store';
import { LS_PANEL_COPY_KEY } from 'app/core/constants'; import { LS_PANEL_COPY_KEY } from 'app/core/constants';
import { updateLocation } from 'app/core/actions'; import { updateLocation } from 'app/core/actions';
import { store as reduxStore } from 'app/store/store'; import { store as reduxStore } from 'app/store/store';
export interface AddPanelPanelProps { export interface Props {
panel: PanelModel; panel: PanelModel;
dashboard: DashboardModel; dashboard: DashboardModel;
} }
export interface AddPanelPanelState { export interface State {
copiedPanelPlugins: any[]; copiedPanelPlugins: any[];
} }
export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelPanelState> { export class AddPanelWidget extends React.Component<Props, State> {
constructor(props) { constructor(props) {
super(props); super(props);
this.handleCloseAddPanel = this.handleCloseAddPanel.bind(this); this.handleCloseAddPanel = this.handleCloseAddPanel.bind(this);
...@@ -133,15 +133,15 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP ...@@ -133,15 +133,15 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
} }
return ( return (
<div className="panel-container add-panel-container"> <div className="panel-container add-panel-widget-container">
<div className="add-panel"> <div className="add-panel-widget">
<div className="add-panel__header grid-drag-handle"> <div className="add-panel-widget__header grid-drag-handle">
<i className="gicon gicon-add-panel" /> <i className="gicon gicon-add-panel" />
<button className="add-panel__close" onClick={this.handleCloseAddPanel}> <button className="add-panel-widget__close" onClick={this.handleCloseAddPanel}>
<i className="fa fa-close" /> <i className="fa fa-close" />
</button> </button>
</div> </div>
<div className="add-panel-btn-container"> <div className="add-panel-widget__btn-container">
<button className="btn-success btn btn-large" onClick={this.onCreateNewPanel}> <button className="btn-success btn btn-large" onClick={this.onCreateNewPanel}>
Edit Panel Edit Panel
</button> </button>
......
.add-panel-container { .add-panel-widget-container {
height: 100%; height: 100%;
} }
.add-panel { .add-panel-widget {
height: 100%; height: 100%;
} }
.add-panel__header { .add-panel-widget__header {
top: 0; top: 0;
position: absolute; position: absolute;
padding: 0 15px; padding: 0 15px;
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
} }
} }
.add-panel__close { .add-panel-widget__close {
margin-left: auto; margin-left: auto;
background-color: transparent; background-color: transparent;
border: 0; border: 0;
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
margin-right: -10px; margin-right: -10px;
} }
.add-panel-btn-container { .add-panel-widget__btn-container {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
......
export { AddPanelWidget } from './AddPanelWidget';
export { RowOptionsCtrl } from './RowOptionsCtrl';
...@@ -5,7 +5,7 @@ import classNames from 'classnames'; ...@@ -5,7 +5,7 @@ import classNames from 'classnames';
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader'; import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
import { importPluginModule } from 'app/features/plugins/plugin_loader'; import { importPluginModule } from 'app/features/plugins/plugin_loader';
import { AddPanelPanel } from './AddPanelPanel'; import { AddPanelWidget } from '../components/AddPanelWidget';
import { getPanelPluginNotFound } from './PanelPluginNotFound'; import { getPanelPluginNotFound } from './PanelPluginNotFound';
import { DashboardRow } from './DashboardRow'; import { DashboardRow } from './DashboardRow';
import { PanelChrome } from './PanelChrome'; import { PanelChrome } from './PanelChrome';
...@@ -53,7 +53,7 @@ export class DashboardPanel extends PureComponent<Props, State> { ...@@ -53,7 +53,7 @@ export class DashboardPanel extends PureComponent<Props, State> {
} }
renderAddPanel() { renderAddPanel() {
return <AddPanelPanel panel={this.props.panel} dashboard={this.props.dashboard} />; return <AddPanelWidget panel={this.props.panel} dashboard={this.props.dashboard} />;
} }
onPluginTypeChanged = (plugin: PanelPlugin) => { onPluginTypeChanged = (plugin: PanelPlugin) => {
......
...@@ -2,7 +2,6 @@ import './dashboard_ctrl'; ...@@ -2,7 +2,6 @@ import './dashboard_ctrl';
import './time_srv'; import './time_srv';
import './repeat_option/repeat_option'; import './repeat_option/repeat_option';
import './dashgrid/DashboardGridDirective'; import './dashgrid/DashboardGridDirective';
import './dashgrid/RowOptions';
import './panellinks/module'; import './panellinks/module';
// Services // Services
...@@ -25,6 +24,7 @@ import './components/UnsavedChangesModal'; ...@@ -25,6 +24,7 @@ import './components/UnsavedChangesModal';
import './components/SaveModals'; import './components/SaveModals';
import './components/ShareModal'; import './components/ShareModal';
import './components/AdHocFilters'; import './components/AdHocFilters';
import './components/RowOptions';
import DashboardPermissions from './components/DashboardPermissions/DashboardPermissions'; import DashboardPermissions from './components/DashboardPermissions/DashboardPermissions';
......
<page-header model="ctrl.navModel"></page-header>
<div class="page-container page-body">
<dashboard-permissions ng-if="ctrl.dashboard && ctrl.meta"
dashboardId="ctrl.dashboard.id"
/>
</div>
<page-header model="ctrl.navModel"></page-header>
<div class="page-container page-body">
<h2 class="page-sub-heading">Folder Settings</h2>
<div class="section gf-form-group">
<form name="folderSettingsForm" ng-submit="ctrl.save()">
<div class="gf-form">
<label class="gf-form-label width-7">Name</label>
<input type="text" class="gf-form-input width-30" ng-model='ctrl.title' ng-change="ctrl.titleChanged()"></input>
</div>
<div class="gf-form-button-row">
<button type="submit" class="btn btn-success" ng-disabled="!ctrl.canSave || !ctrl.hasChanged">
<i class="fa fa-save"></i>Save
</button>
<button class="btn btn-danger" ng-click="ctrl.delete($event)" ng-disabled="!ctrl.canSave">
<i class="fa fa-trash"></i>
Delete
</button>
</div>
</form>
</div>
</div>
<div class="modal-body" ng-controller="InspectCtrl" ng-init="init()">
<div class="modal-header">
<h2 class="modal-header-title">
<i class="fa fa-info-circle"></i>
<span class="p-l-1">Inspector</span>
</h2>
<ul class="gf-tabs">
<li class="gf-tabs-item" ng-repeat="tab in ['Panel Description', 'Request', 'Response', 'JS Error']">
<a class="gf-tabs-link" ng-click="editor.index = $index" ng-class="{active: editor.index === $index}">
{{::tab}}
</a>
</li>
</ul>
<a class="modal-header-close" ng-click="dismiss();">
<i class="fa fa-remove"></i>
</a>
</div>
<div class="modal-content">
<div ng-if="editor.index == 0" ng-bind-html="panelInfoHtml">
</div>
<div ng-if="editor.index == 1">
<h5 class="section-heading">Request details</h5>
<table class="filter-table gf-form-group">
<tr>
<td>Url</td>
<td>{{inspector.error.config.url}}</td>
</tr>
<tr>
<td>Method</td>
<td>{{inspector.error.config.method}}</td>
</tr>
<tr ng-repeat="(key, value) in inspector.error.config.headers">
<td>
{{key}}
</td>
<td>
{{value}}
</td>
</tr>
</table>
<h5 class="section-heading">Request parameters</h5>
<table class="filter-table">
<tr ng-repeat="param in request_parameters">
<td>
{{param.key}}
</td>
<td>
{{param.value}}
</td>
</tr>
</table>
</div>
<div ng-if="editor.index == 2">
<h5 ng-show="message">{{message}}</h5>
<pre class="small">
{{response}}
</pre>
</div>
<div ng-if="editor.index == 3">
<label>Message:</label>
<pre>
{{message}}
</pre>
<label>Stack trace:</label>
<pre>
{{stack_trace}}
</pre>
</div>
</div>
</div>
import appEvents from 'app/core/app_events'; import appEvents from 'app/core/app_events';
import locationUtil from 'app/core/utils/location_util'; import locationUtil from 'app/core/utils/location_util';
export class CreateFolderCtrl { export default class CreateFolderCtrl {
title = ''; title = '';
navModel: any; navModel: any;
titleTouched = false; titleTouched = false;
...@@ -38,3 +38,4 @@ export class CreateFolderCtrl { ...@@ -38,3 +38,4 @@ export class CreateFolderCtrl {
}); });
} }
} }
import { FolderPageLoader } from './services/FolderPageLoader'; import { FolderPageLoader } from './services/FolderPageLoader';
import locationUtil from 'app/core/utils/location_util'; import locationUtil from 'app/core/utils/location_util';
export class FolderDashboardsCtrl { export default class FolderDashboardsCtrl {
navModel: any; navModel: any;
folderId: number; folderId: number;
uid: string; uid: string;
...@@ -23,3 +23,4 @@ export class FolderDashboardsCtrl { ...@@ -23,3 +23,4 @@ export class FolderDashboardsCtrl {
} }
} }
} }
...@@ -232,3 +232,5 @@ export class DashboardImportCtrl { ...@@ -232,3 +232,5 @@ export class DashboardImportCtrl {
this.gnetInfo = ''; this.gnetInfo = '';
} }
} }
export default DashboardImportCtrl;
...@@ -8,14 +8,8 @@ export * from './components/UploadDashboard'; ...@@ -8,14 +8,8 @@ export * from './components/UploadDashboard';
// Controllers // Controllers
import { DashboardListCtrl } from './DashboardListCtrl'; import { DashboardListCtrl } from './DashboardListCtrl';
import { SnapshotListCtrl } from './SnapshotListCtrl'; import { SnapshotListCtrl } from './SnapshotListCtrl';
import { FolderDashboardsCtrl } from './FolderDashboardsCtrl';
import { DashboardImportCtrl } from './DashboardImportCtrl';
import { CreateFolderCtrl } from './CreateFolderCtrl';
import coreModule from 'app/core/core_module'; import coreModule from 'app/core/core_module';
coreModule.controller('DashboardListCtrl', DashboardListCtrl); coreModule.controller('DashboardListCtrl', DashboardListCtrl);
coreModule.controller('SnapshotListCtrl', SnapshotListCtrl); coreModule.controller('SnapshotListCtrl', SnapshotListCtrl);
coreModule.controller('FolderDashboardsCtrl', FolderDashboardsCtrl);
coreModule.controller('DashboardImportCtrl', DashboardImportCtrl);
coreModule.controller('CreateFolderCtrl', CreateFolderCtrl);
...@@ -290,17 +290,4 @@ export class PanelCtrl { ...@@ -290,17 +290,4 @@ export class PanelCtrl {
html += '</div>'; html += '</div>';
return sanitize(html); return sanitize(html);
} }
openInspector() {
const modalScope = this.$scope.$new();
modalScope.panel = this.panel;
modalScope.dashboard = this.dashboard;
modalScope.panelInfoHtml = this.getInfoContent({ mode: 'inspector' });
modalScope.inspector = $.extend(true, {}, this.inspector);
this.publishAppEvent('show-modal', {
src: 'public/app/features/dashboard/partials/inspector.html',
scope: modalScope,
});
}
} }
...@@ -192,11 +192,6 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => { ...@@ -192,11 +192,6 @@ module.directive('grafanaPanel', ($rootScope, $document, $timeout) => {
scope.$watchGroup(['ctrl.error', 'ctrl.panel.description'], updatePanelCornerInfo); scope.$watchGroup(['ctrl.error', 'ctrl.panel.description'], updatePanelCornerInfo);
scope.$watchCollection('ctrl.panel.links', updatePanelCornerInfo); scope.$watchCollection('ctrl.panel.links', updatePanelCornerInfo);
cornerInfoElem.on('click', () => {
infoDrop.close();
scope.$apply(ctrl.openInspector.bind(ctrl));
});
elem.on('mouseenter', mouseEnter); elem.on('mouseenter', mouseEnter);
elem.on('mouseleave', mouseLeave); elem.on('mouseleave', mouseLeave);
......
...@@ -10,6 +10,9 @@ import ApiKeys from 'app/features/api-keys/ApiKeysPage'; ...@@ -10,6 +10,9 @@ import ApiKeys from 'app/features/api-keys/ApiKeysPage';
import PluginListPage from 'app/features/plugins/PluginListPage'; import PluginListPage from 'app/features/plugins/PluginListPage';
import FolderSettingsPage from 'app/features/folders/FolderSettingsPage'; import FolderSettingsPage from 'app/features/folders/FolderSettingsPage';
import FolderPermissions from 'app/features/folders/FolderPermissions'; import FolderPermissions from 'app/features/folders/FolderPermissions';
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'; import DataSourcesListPage from 'app/features/datasources/DataSourcesListPage';
import NewDataSourcePage from '../features/datasources/NewDataSourcePage'; import NewDataSourcePage from '../features/datasources/NewDataSourcePage';
import UsersListPage from 'app/features/users/UsersListPage'; import UsersListPage from 'app/features/users/UsersListPage';
...@@ -66,8 +69,8 @@ export function setupAngularRoutes($routeProvider, $locationProvider) { ...@@ -66,8 +69,8 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
pageClass: 'page-dashboard', pageClass: 'page-dashboard',
}) })
.when('/dashboard/import', { .when('/dashboard/import', {
templateUrl: 'public/app/features/dashboard/partials/dashboard_import.html', templateUrl: 'public/app/features/manage-dashboards/partials/dashboard_import.html',
controller: 'DashboardImportCtrl', controller: DashboardImportCtrl,
controllerAs: 'ctrl', controllerAs: 'ctrl',
}) })
.when('/datasources', { .when('/datasources', {
...@@ -100,8 +103,8 @@ export function setupAngularRoutes($routeProvider, $locationProvider) { ...@@ -100,8 +103,8 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
controllerAs: 'ctrl', controllerAs: 'ctrl',
}) })
.when('/dashboards/folder/new', { .when('/dashboards/folder/new', {
templateUrl: 'public/app/features/dashboard/partials/create_folder.html', templateUrl: 'public/app/features/folders/partials/create_folder.html',
controller: 'CreateFolderCtrl', controller: CreateFolderCtrl,
controllerAs: 'ctrl', controllerAs: 'ctrl',
}) })
.when('/dashboards/f/:uid/:slug/permissions', { .when('/dashboards/f/:uid/:slug/permissions', {
...@@ -117,8 +120,8 @@ export function setupAngularRoutes($routeProvider, $locationProvider) { ...@@ -117,8 +120,8 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
}, },
}) })
.when('/dashboards/f/:uid/:slug', { .when('/dashboards/f/:uid/:slug', {
templateUrl: 'public/app/features/dashboard/partials/folder_dashboards.html', templateUrl: 'public/app/features/folders/partials/folder_dashboards.html',
controller: 'FolderDashboardsCtrl', controller: FolderDashboardsCtrl,
controllerAs: 'ctrl', controllerAs: 'ctrl',
}) })
.when('/dashboards/f/:uid', { .when('/dashboards/f/:uid', {
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
@import 'layout/page'; @import 'layout/page';
// COMPONENTS // COMPONENTS
@import '../app/features/dashboard/components/AddPanelWidget/AddPanelWidget';
@import 'components/scrollbar'; @import 'components/scrollbar';
@import 'components/cards'; @import 'components/cards';
@import 'components/buttons'; @import 'components/buttons';
...@@ -58,7 +59,6 @@ ...@@ -58,7 +59,6 @@
@import 'components/panel_table'; @import 'components/panel_table';
@import 'components/panel_text'; @import 'components/panel_text';
@import 'components/panel_heatmap'; @import 'components/panel_heatmap';
@import 'components/panel_add_panel';
@import 'components/panel_logs'; @import 'components/panel_logs';
@import 'components/settings_permissions'; @import 'components/settings_permissions';
@import 'components/tagsinput'; @import 'components/tagsinput';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment