Angular cleanup: Remove unused <panel-links-editor> + controller (#36838)

pull/36842/head
Ashley Harrison 4 years ago committed by GitHub
parent 67b977fd63
commit a70eafb732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      public/app/features/panel/all.ts
  2. 70
      public/app/features/panel/panellinks/module.html
  3. 63
      public/app/features/panel/panellinks/module.ts

@ -2,4 +2,3 @@ import './panel_directive';
import './query_ctrl';
import './panel_editor_tab';
import './query_editor_row';
import './panellinks/module';

@ -1,70 +0,0 @@
<div class="editor-row">
<div class="gf-form-group" ng-repeat="link in panel.links">
<div class="section">
<div class="gf-form max-width-25">
<span class="gf-form-label width-7">Type</span>
<div class="gf-form-select-wrapper gf-form--grow">
<select class="gf-form-input" ng-model="link.type" ng-options="f for f in ['dashboard','absolute']"></select>
</div>
</div>
<div class="gf-form max-width-25">
<span class="gf-form-label width-7" ng-show="link.type === 'dashboard'">Dashboard</span>
<input
ng-show="link.type === 'dashboard'"
type="text"
ng-model="link.dashboard"
bs-typeahead="searchDashboards"
class="gf-form-input"
ng-blur="dashboardChanged(link)"
/>
<span class="gf-form-label width-7" ng-show="link.type === 'absolute'">Url</span>
<input ng-show="link.type === 'absolute'" type="text" ng-model="link.url" class="gf-form-input max-width-14" />
</div>
<div class="gf-form max-width-25">
<div class="gf-form-label width-7">Title</div>
<input type="text" ng-model="link.title" class="gf-form-input" />
</div>
</div>
<div class="section">
<div class="gf-form">
<span class="gf-form-label width-10">Url params</span>
<input type="text" ng-model="link.params" class="gf-form-input width-10" />
</div>
<gf-form-switch
class="gf-form"
label-class="width-10"
label="Include time range"
checked="link.keepTime"
></gf-form-switch>
<gf-form-switch
class="gf-form"
label-class="width-10"
label="Include variables"
checked="link.includeVars"
></gf-form-switch>
<gf-form-switch
class="gf-form"
label-class="width-10"
label="Open in new tab "
checked="link.targetBlank"
></gf-form-switch>
</div>
<div class="section">
<div class="gf-form">
<button class="btn btn-inverse gf-form-btn" ng-click="deleteLink(link)">
<icon name="trash-alt"></icon> Remove Link
</button>
</div>
</div>
</div>
</div>
<div class="editor-row">
<button class="btn btn-inverse" ng-click="addLink()"><icon name="'plus'"></icon> Add link</button>
</div>

@ -1,63 +0,0 @@
import angular from 'angular';
import { map, find, without } from 'lodash';
import './link_srv';
import { backendSrv } from 'app/core/services/backend_srv';
function panelLinksEditor() {
return {
scope: {
panel: '=',
},
restrict: 'E',
controller: 'PanelLinksEditorCtrl',
templateUrl: 'public/app/features/panel/panellinks/module.html',
link: () => {},
};
}
export class PanelLinksEditorCtrl {
/** @ngInject */
constructor($scope: any) {
$scope.panel.links = $scope.panel.links || [];
$scope.addLink = () => {
$scope.panel.links.push({
type: 'dashboard',
});
};
$scope.searchDashboards = (queryStr: string, callback: Function) => {
backendSrv.search({ query: queryStr }).then((hits) => {
const dashboards = map(hits, (dash) => {
return dash.title;
});
callback(dashboards);
});
};
$scope.dashboardChanged = (link: any) => {
backendSrv.search({ query: link.dashboard }).then((hits) => {
const dashboard: any = find(hits, { title: link.dashboard });
if (dashboard) {
if (dashboard.url) {
link.url = dashboard.url;
} else {
// To support legacy url's
link.dashUri = dashboard.uri;
}
link.title = dashboard.title;
}
});
};
$scope.deleteLink = (link: any) => {
$scope.panel.links = without($scope.panel.links, link);
};
}
}
angular
.module('grafana.directives')
.directive('panelLinksEditor', panelLinksEditor)
.controller('PanelLinksEditorCtrl', PanelLinksEditorCtrl);
Loading…
Cancel
Save