From fadfc665e473c1b979ce1def31fa9cb9e6113d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 19 Dec 2017 16:06:54 +0100 Subject: [PATCH] tech: ran pretttier on all typescript files --- public/app/app.ts | 166 +-- public/app/core/app_events.ts | 2 +- .../components/code_editor/code_editor.ts | 50 +- .../components/colorpicker/spectrum_picker.ts | 13 +- .../app/core/components/dashboard_selector.ts | 19 +- .../components/form_dropdown/form_dropdown.ts | 83 +- public/app/core/components/gf_page.ts | 12 +- public/app/core/components/grafana_app.ts | 166 ++- public/app/core/components/help/help.ts | 82 +- public/app/core/components/info_popover.ts | 43 +- .../core/components/json_explorer/helpers.ts | 50 +- .../components/json_explorer/json_explorer.ts | 158 ++- .../app/core/components/jsontree/jsontree.ts | 41 +- .../layout_selector/layout_selector.ts | 49 +- .../manage_dashboards/manage_dashboards.ts | 119 +- public/app/core/components/navbar/navbar.ts | 28 +- public/app/core/components/org_switcher.ts | 20 +- .../core/components/query_part/query_part.ts | 39 +- .../query_part/query_part_editor.ts | 82 +- public/app/core/components/scroll/scroll.ts | 16 +- public/app/core/components/search/search.ts | 76 +- .../core/components/search/search_results.ts | 30 +- .../app/core/components/sidemenu/sidemenu.ts | 66 +- public/app/core/components/switch.ts | 13 +- public/app/core/components/team_picker.ts | 35 +- public/app/core/components/user_picker.ts | 35 +- public/app/core/config.ts | 66 +- public/app/core/constants.ts | 3 +- public/app/core/controllers/error_ctrl.ts | 13 +- public/app/core/controllers/inspect_ctrl.ts | 40 +- public/app/core/controllers/invited_ctrl.ts | 42 +- .../app/core/controllers/json_editor_ctrl.ts | 12 +- public/app/core/controllers/login_ctrl.ts | 45 +- .../core/controllers/reset_password_ctrl.ts | 43 +- public/app/core/controllers/signup_ctrl.ts | 48 +- public/app/core/core.ts | 94 +- public/app/core/directives/array_join.ts | 18 +- public/app/core/directives/diff-view.ts | 33 +- public/app/core/directives/give_focus.ts | 32 +- .../app/core/directives/ng_model_on_blur.ts | 36 +- .../app/core/directives/rebuild_on_change.ts | 20 +- public/app/core/directives/tags.ts | 146 ++- public/app/core/filters/filters.ts | 42 +- public/app/core/live/live_srv.ts | 44 +- public/app/core/mod_defs.d.ts | 8 +- public/app/core/nav_model_srv.ts | 12 +- public/app/core/profiler.ts | 82 +- public/app/core/routes/bundle_loader.ts | 28 +- public/app/core/routes/dashboard_loaders.ts | 55 +- public/app/core/routes/routes.ts | 550 ++++---- public/app/core/services/alert_srv.ts | 82 +- public/app/core/services/analytics.ts | 30 +- public/app/core/services/backend_srv.ts | 253 ++-- public/app/core/services/context_srv.ts | 25 +- .../core/services/dynamic_directive_srv.ts | 48 +- public/app/core/services/global_event_srv.ts | 26 +- public/app/core/services/impression_srv.ts | 8 +- public/app/core/services/keybindingSrv.ts | 131 +- public/app/core/services/ng_react.ts | 100 +- public/app/core/services/popover_srv.ts | 17 +- public/app/core/services/search_srv.ts | 88 +- public/app/core/services/timer.ts | 9 +- public/app/core/services/util_srv.ts | 15 +- public/app/core/specs/backend_srv_specs.ts | 46 +- public/app/core/specs/datemath.jest.ts | 124 +- public/app/core/specs/emitter.jest.ts | 40 +- public/app/core/specs/flatten.jest.ts | 30 +- .../app/core/specs/global_event_srv.jest.ts | 18 +- public/app/core/specs/kbn.jest.ts | 382 +++--- .../app/core/specs/manage_dashboards.jest.ts | 276 ++-- public/app/core/specs/org_switcher.jest.ts | 39 +- public/app/core/specs/rangeutil.jest.ts | 136 +- public/app/core/specs/search.jest.ts | 127 +- public/app/core/specs/search_results.jest.ts | 76 +- public/app/core/specs/search_srv.jest.ts | 176 +-- public/app/core/specs/store.jest.ts | 20 +- public/app/core/specs/table_model.jest.ts | 19 +- public/app/core/specs/time_series.jest.ts | 204 +-- .../core/specs/value_select_dropdown_specs.ts | 81 +- public/app/core/store.ts | 4 +- public/app/core/table_model.ts | 3 +- public/app/core/time_series2.ts | 122 +- public/app/core/utils/colors.ts | 73 +- public/app/core/utils/css_loader.ts | 27 +- public/app/core/utils/datemath.ts | 41 +- public/app/core/utils/file_export.ts | 124 +- public/app/core/utils/flatten.ts | 9 +- public/app/core/utils/kbn.ts | 987 +++++++------- public/app/core/utils/model_utils.ts | 8 +- public/app/core/utils/outline.ts | 24 +- public/app/core/utils/rangeutil.ts | 130 +- public/app/core/utils/react2angular.ts | 17 +- public/app/core/utils/ticks.ts | 41 +- public/app/core/utils/version.ts | 8 +- public/app/features/admin/admin.ts | 29 +- .../app/features/admin/admin_edit_org_ctrl.ts | 36 +- .../features/admin/admin_edit_user_ctrl.ts | 99 +- .../features/admin/admin_list_orgs_ctrl.ts | 25 +- .../features/admin/admin_list_users_ctrl.ts | 44 +- public/app/features/alerting/alert_def.ts | 140 +- .../app/features/alerting/alert_list_ctrl.ts | 50 +- .../app/features/alerting/alert_tab_ctrl.ts | 210 +-- public/app/features/alerting/all.ts | 7 +- .../alerting/notification_edit_ctrl.ts | 90 +- .../alerting/notifications_list_ctrl.ts | 8 +- .../alerting/specs/alert_tab_specs.ts | 12 +- .../alerting/specs/threshold_mapper_specs.ts | 50 +- .../app/features/alerting/threshold_mapper.ts | 31 +- public/app/features/annotations/all.ts | 13 +- .../annotations/annotation_tooltip.ts | 64 +- .../features/annotations/annotations_srv.ts | 58 +- .../app/features/annotations/editor_ctrl.ts | 40 +- public/app/features/annotations/event.ts | 1 - .../app/features/annotations/event_editor.ts | 85 +- .../app/features/annotations/event_manager.ts | 61 +- .../features/annotations/events_processing.ts | 16 +- .../specs/annotations_srv_specs.jest.ts | 81 +- .../specs/annotations_srv_specs.ts | 44 +- public/app/features/dashboard/acl/acl.ts | 88 +- .../features/dashboard/acl/specs/acl_specs.ts | 121 +- .../app/features/dashboard/ad_hoc_filters.ts | 88 +- public/app/features/dashboard/alerting_srv.ts | 6 +- public/app/features/dashboard/all.ts | 82 +- .../features/dashboard/create_folder_ctrl.ts | 14 +- .../app/features/dashboard/dashboard_ctrl.ts | 167 +-- .../dashboard/dashboard_import_ctrl.ts | 80 +- .../features/dashboard/dashboard_migration.ts | 143 ++- .../app/features/dashboard/dashboard_model.ts | 143 ++- .../app/features/dashboard/dashboard_srv.ts | 80 +- .../dashgrid/DashboardGridDirective.ts | 8 +- .../dashboard/dashgrid/PanelContainer.ts | 5 +- .../dashboard/dashgrid/PanelLoader.ts | 13 +- .../features/dashboard/dashgrid/RowOptions.ts | 12 +- .../app/features/dashboard/dashnav/dashnav.ts | 162 +-- .../features/dashboard/export/export_modal.ts | 35 +- .../app/features/dashboard/export/exporter.ts | 146 +-- .../export_data/export_data_modal.ts | 39 +- .../dashboard/folder_dashboards_ctrl.ts | 4 +- .../features/dashboard/folder_page_loader.ts | 90 +- .../dashboard/folder_permissions_ctrl.ts | 8 +- .../dashboard/folder_picker/picker.ts | 57 +- .../dashboard/folder_settings_ctrl.ts | 81 +- .../app/features/dashboard/history/history.ts | 170 +-- .../features/dashboard/history/history_srv.ts | 18 +- .../move_to_folder_modal/move_to_folder.ts | 33 +- public/app/features/dashboard/panel_model.ts | 25 +- .../dashboard/repeat_option/repeat_option.ts | 23 +- .../app/features/dashboard/save_as_modal.ts | 14 +- public/app/features/dashboard/save_modal.ts | 16 +- .../features/dashboard/settings/settings.ts | 123 +- .../app/features/dashboard/shareModalCtrl.ts | 66 +- .../specs/dashboard_import_ctrl.jest.ts | 44 +- .../specs/dashboard_migration.jest.ts | 314 +++-- .../dashboard/specs/dashboard_model.jest.ts | 252 ++-- .../dashboard/specs/dashboard_srv_specs.ts | 6 +- .../dashboard/specs/exporter_specs.ts | 155 ++- .../dashboard/specs/history_ctrl_specs.ts | 295 +++-- .../features/dashboard/specs/history_mocks.ts | 307 ++--- .../dashboard/specs/history_srv_specs.ts | 106 +- .../features/dashboard/specs/repeat.jest.ts | 423 +++--- .../dashboard/specs/save_as_modal.jest.ts | 51 +- .../dashboard/specs/share_modal_ctrl_specs.ts | 111 +- .../dashboard/specs/time_srv_specs.ts | 128 +- .../specs/unsaved_changes_srv_specs.ts | 66 +- .../dashboard/specs/viewstate_srv_specs.ts | 63 +- .../app/features/dashboard/submenu/submenu.ts | 24 +- public/app/features/dashboard/time_srv.ts | 101 +- .../dashboard/timepicker/timepicker.ts | 90 +- .../dashboard/unsaved_changes_modal.ts | 15 +- public/app/features/dashboard/upload.ts | 27 +- .../app/features/dashboard/view_state_srv.ts | 3 +- .../app/features/org/change_password_ctrl.ts | 23 +- public/app/features/org/create_team_modal.ts | 23 +- public/app/features/org/new_org_ctrl.ts | 17 +- public/app/features/org/org_api_keys_ctrl.ts | 26 +- public/app/features/org/org_details_ctrl.ts | 27 +- public/app/features/org/org_users_ctrl.ts | 53 +- public/app/features/org/prefs_control.ts | 32 +- public/app/features/org/profile_ctrl.ts | 32 +- public/app/features/org/select_org_ctrl.ts | 15 +- .../org/specs/team_details_ctrl_specs.ts | 67 +- public/app/features/org/team_details_ctrl.ts | 52 +- public/app/features/org/teams_ctrl.ts | 4 +- .../app/features/panel/metrics_panel_ctrl.ts | 176 +-- public/app/features/panel/metrics_tab.ts | 50 +- public/app/features/panel/panel_directive.ts | 95 +- public/app/features/panel/panel_editor_tab.ts | 10 +- public/app/features/panel/panel_header.ts | 54 +- public/app/features/panel/query_ctrl.ts | 8 +- public/app/features/panel/query_editor_row.ts | 23 +- .../features/panel/query_troubleshooter.ts | 37 +- public/app/features/panel/solo_panel_ctrl.ts | 21 +- public/app/features/panellinks/link_srv.ts | 64 +- public/app/features/panellinks/module.ts | 30 +- .../panellinks/specs/link_srv.jest.ts | 52 +- .../features/playlist/playlist_edit_ctrl.ts | 67 +- .../app/features/playlist/playlist_search.ts | 28 +- public/app/features/playlist/playlist_srv.ts | 32 +- .../app/features/playlist/playlists_ctrl.ts | 31 +- .../specs/playlist_edit_ctrl_specs.ts | 53 +- .../app/features/plugins/built_in_plugins.ts | 44 +- public/app/features/plugins/ds_edit_ctrl.ts | 146 ++- public/app/features/plugins/ds_list_ctrl.ts | 59 +- .../plugins/import_list/import_list.ts | 68 +- .../app/features/plugins/plugin_component.ts | 174 ++- .../app/features/plugins/plugin_edit_ctrl.ts | 158 ++- .../app/features/plugins/plugin_list_ctrl.ts | 14 +- public/app/features/plugins/plugin_loader.ts | 146 ++- .../app/features/plugins/plugin_page_ctrl.ts | 28 +- public/app/features/plugins/row_ctrl.ts | 22 +- .../plugins/specs/datasource_srv_specs.ts | 90 +- public/app/features/snapshot/snapshot_ctrl.ts | 40 +- public/app/features/styleguide/styleguide.ts | 48 +- .../app/features/templating/adhoc_variable.ts | 34 +- .../features/templating/constant_variable.ts | 22 +- .../features/templating/custom_variable.ts | 28 +- .../templating/datasource_variable.ts | 45 +- public/app/features/templating/editor_ctrl.ts | 114 +- .../features/templating/interval_variable.ts | 59 +- .../app/features/templating/query_variable.ts | 95 +- .../templating/specs/adhoc_variable.jest.ts | 55 +- .../templating/specs/query_variable.jest.ts | 74 +- .../templating/specs/template_srv.jest.ts | 364 +++--- .../templating/specs/variable.jest.ts | 61 +- .../specs/variable_srv_init_specs.ts | 232 ++-- .../templating/specs/variable_srv_specs.ts | 843 +++++++----- .../app/features/templating/template_srv.ts | 82 +- public/app/features/templating/variable.ts | 26 +- .../app/features/templating/variable_srv.ts | 142 ++- public/app/index.ts | 3 +- .../app/testdata/datasource/datasource.ts | 51 +- .../plugins/app/testdata/datasource/module.ts | 13 +- .../app/testdata/datasource/query_ctrl.ts | 23 +- public/app/plugins/app/testdata/module.ts | 13 +- .../datasource/cloudwatch/config_ctrl.ts | 27 +- .../datasource/cloudwatch/datasource.d.ts | 1 - .../plugins/datasource/cloudwatch/module.ts | 13 +- .../datasource/cloudwatch/query_ctrl.ts | 9 +- .../cloudwatch/query_parameter_ctrl.ts | 207 ++- .../cloudwatch/specs/datasource_specs.ts | 407 +++--- .../datasource/elasticsearch/config_ctrl.ts | 35 +- .../datasource/elasticsearch/datasource.ts | 271 ++-- .../elasticsearch/elastic_response.ts | 152 ++- .../datasource/elasticsearch/index_pattern.ts | 25 +- .../datasource/elasticsearch/module.ts | 12 +- .../datasource/elasticsearch/query_builder.ts | 138 +- .../datasource/elasticsearch/query_ctrl.ts | 54 +- .../datasource/elasticsearch/query_def.ts | 214 ++-- .../elasticsearch/specs/datasource_specs.ts | 360 +++--- .../specs/elastic_response_specs.ts | 944 ++++++++------ .../specs/index_pattern_specs.ts | 49 +- .../specs/query_builder_specs.ts | 359 +++--- .../elasticsearch/specs/query_def_specs.ts | 86 +- .../datasource/grafana-live/datasource.ts | 10 +- .../plugins/datasource/grafana-live/module.ts | 12 +- .../plugins/datasource/grafana/datasource.ts | 27 +- .../app/plugins/datasource/grafana/module.ts | 16 +- .../datasource/graphite/config_ctrl.ts | 28 +- .../plugins/datasource/graphite/datasource.ts | 223 ++-- .../app/plugins/datasource/graphite/gfunc.ts | 6 +- .../datasource/graphite/graphite_query.ts | 132 +- .../app/plugins/datasource/graphite/lexer.ts | 1131 ++++++++++++++--- .../app/plugins/datasource/graphite/module.ts | 11 +- .../app/plugins/datasource/graphite/parser.ts | 116 +- .../plugins/datasource/graphite/query_ctrl.ts | 246 ++-- .../graphite/specs/datasource_specs.ts | 229 ++-- .../datasource/graphite/specs/gfunc.jest.ts | 145 +-- .../datasource/graphite/specs/lexer.jest.ts | 135 +- .../datasource/graphite/specs/parser.jest.ts | 185 +-- .../graphite/specs/query_ctrl_specs.ts | 321 +++-- .../plugins/datasource/influxdb/datasource.ts | 202 +-- .../datasource/influxdb/influx_query.ts | 118 +- .../datasource/influxdb/influx_series.ts | 103 +- .../app/plugins/datasource/influxdb/module.ts | 12 +- .../datasource/influxdb/query_builder.ts | 66 +- .../plugins/datasource/influxdb/query_ctrl.ts | 324 +++-- .../plugins/datasource/influxdb/query_part.ts | 251 ++-- .../datasource/influxdb/response_parser.ts | 11 +- .../influxdb/specs/influx_query.jest.ts | 442 ++++--- .../influxdb/specs/influx_series.jest.ts | 234 ++-- .../influxdb/specs/query_builder.jest.ts | 193 +-- .../influxdb/specs/query_ctrl_specs.ts | 205 +-- .../influxdb/specs/query_part.jest.ts | 47 +- .../influxdb/specs/response_parser.jest.ts | 96 +- .../plugins/datasource/mixed/datasource.ts | 16 +- public/app/plugins/datasource/mixed/module.ts | 5 +- .../plugins/datasource/mysql/datasource.ts | 180 +-- public/app/plugins/datasource/mysql/module.ts | 11 +- .../plugins/datasource/mysql/query_ctrl.ts | 30 +- .../datasource/mysql/response_parser.ts | 53 +- .../mysql/specs/datasource_specs.ts | 197 +-- .../datasource/opentsdb/config_ctrl.ts | 16 +- .../datasource/opentsdb/datasource.d.ts | 1 - .../app/plugins/datasource/opentsdb/module.ts | 10 +- .../plugins/datasource/opentsdb/query_ctrl.ts | 93 +- .../opentsdb/specs/datasource-specs.ts | 128 +- .../opentsdb/specs/query-ctrl-specs.ts | 130 +- .../plugins/datasource/postgres/datasource.ts | 178 +-- .../app/plugins/datasource/postgres/module.ts | 15 +- .../plugins/datasource/postgres/query_ctrl.ts | 30 +- .../datasource/postgres/response_parser.ts | 45 +- .../postgres/specs/datasource_specs.ts | 193 +-- .../datasource/prometheus/completer.ts | 162 ++- .../datasource/prometheus/datasource.ts | 222 +++- .../prometheus/metric_find_query.ts | 6 +- .../plugins/datasource/prometheus/module.ts | 10 +- .../datasource/prometheus/query_ctrl.ts | 62 +- .../prometheus/specs/completer_specs.ts | 169 ++- .../prometheus/specs/datasource_specs.ts | 711 ++++++----- .../specs/metric_find_query_specs.ts | 223 +++- public/app/plugins/panel/alertlist/module.ts | 89 +- public/app/plugins/panel/dashlist/module.ts | 62 +- .../plugins/panel/gettingstarted/module.ts | 93 +- public/app/plugins/panel/graph/axes_editor.ts | 54 +- .../app/plugins/panel/graph/data_processor.ts | 96 +- public/app/plugins/panel/graph/graph.ts | 247 ++-- public/app/plugins/panel/graph/histogram.ts | 9 +- public/app/plugins/panel/graph/legend.ts | 139 +- public/app/plugins/panel/graph/module.ts | 158 ++- .../panel/graph/series_overrides_ctrl.ts | 151 ++- .../panel/graph/specs/data_processor.jest.ts | 64 +- .../panel/graph/specs/graph_ctrl_specs.ts | 68 +- .../plugins/panel/graph/specs/graph_specs.ts | 549 ++++---- .../panel/graph/specs/histogram.jest.ts | 33 +- .../graph/specs/series_override_ctrl_specs.ts | 74 +- .../graph/specs/threshold_manager_specs.ts | 102 +- .../panel/graph/specs/tooltip_specs.ts | 236 ++-- .../plugins/panel/graph/threshold_manager.ts | 99 +- .../plugins/panel/graph/thresholds_form.ts | 20 +- .../app/plugins/panel/heatmap/axes_editor.ts | 24 +- .../app/plugins/panel/heatmap/color_legend.ts | 207 ++- .../app/plugins/panel/heatmap/color_scale.ts | 35 +- .../plugins/panel/heatmap/display_editor.ts | 9 +- .../app/plugins/panel/heatmap/heatmap_ctrl.ts | 150 ++- .../panel/heatmap/heatmap_data_converter.ts | 58 +- .../plugins/panel/heatmap/heatmap_tooltip.ts | 113 +- public/app/plugins/panel/heatmap/module.ts | 8 +- public/app/plugins/panel/heatmap/rendering.ts | 377 ++++-- .../panel/heatmap/specs/heatmap_ctrl_specs.ts | 68 +- .../specs/heatmap_data_converter.jest.ts | 293 +++-- .../panel/heatmap/specs/renderer_specs.ts | 363 +++--- public/app/plugins/panel/pluginlist/module.ts | 55 +- public/app/plugins/panel/singlestat/module.ts | 371 +++--- .../singlestat/specs/singlestat_panel_spec.ts | 66 +- .../singlestat/specs/singlestat_specs.ts | 430 ++++--- .../app/plugins/panel/table/column_options.ts | 78 +- public/app/plugins/panel/table/editor.ts | 51 +- public/app/plugins/panel/table/module.ts | 169 ++- public/app/plugins/panel/table/renderer.ts | 85 +- .../panel/table/specs/renderer.jest.ts | 197 +-- .../panel/table/specs/transformers.jest.ts | 369 +++--- .../app/plugins/panel/table/transformers.ts | 121 +- public/app/plugins/panel/text/module.ts | 51 +- public/app/plugins/panel/unknown/module.ts | 8 +- public/app/plugins/sdk.ts | 18 +- 355 files changed, 20624 insertions(+), 14931 deletions(-) diff --git a/public/app/app.ts b/public/app/app.ts index b76dceb4943..8ddacc4ed04 100644 --- a/public/app/app.ts +++ b/public/app/app.ts @@ -1,32 +1,32 @@ -import 'babel-polyfill'; -import 'file-saver'; -import 'lodash'; -import 'jquery'; -import 'angular'; -import 'angular-route'; -import 'angular-sanitize'; -import 'angular-native-dragdrop'; -import 'angular-bindonce'; -import 'react'; -import 'react-dom'; +import "babel-polyfill"; +import "file-saver"; +import "lodash"; +import "jquery"; +import "angular"; +import "angular-route"; +import "angular-sanitize"; +import "angular-native-dragdrop"; +import "angular-bindonce"; +import "react"; +import "react-dom"; -import 'vendor/bootstrap/bootstrap'; -import 'vendor/angular-ui/ui-bootstrap-tpls'; -import 'vendor/angular-other/angular-strap'; +import "vendor/bootstrap/bootstrap"; +import "vendor/angular-ui/ui-bootstrap-tpls"; +import "vendor/angular-other/angular-strap"; -import $ from 'jquery'; -import angular from 'angular'; -import config from 'app/core/config'; -import _ from 'lodash'; -import moment from 'moment'; +import $ from "jquery"; +import angular from "angular"; +import config from "app/core/config"; +import _ from "lodash"; +import moment from "moment"; // add move to lodash for backward compatabiltiy -_.move = function (array, fromIndex, toIndex) { +_.move = function(array, fromIndex, toIndex) { array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]); return array; }; -import {coreModule, registerAngularDirectives} from './core/core'; +import { coreModule, registerAngularDirectives } from "./core/core"; export class GrafanaApp { registerFunctions: any; @@ -50,58 +50,78 @@ export class GrafanaApp { } init() { - var app = angular.module('grafana', []); + var app = angular.module("grafana", []); moment.locale(config.bootData.user.locale); - app.config(($locationProvider, $controllerProvider, $compileProvider, $filterProvider, $httpProvider, $provide) => { - // pre assing bindings before constructor calls - $compileProvider.preAssignBindingsEnabled(true); + app.config( + ( + $locationProvider, + $controllerProvider, + $compileProvider, + $filterProvider, + $httpProvider, + $provide + ) => { + // pre assing bindings before constructor calls + $compileProvider.preAssignBindingsEnabled(true); - if (config.buildInfo.env !== 'development') { - $compileProvider.debugInfoEnabled(false); - } + if (config.buildInfo.env !== "development") { + $compileProvider.debugInfoEnabled(false); + } - $httpProvider.useApplyAsync(true); + $httpProvider.useApplyAsync(true); - this.registerFunctions.controller = $controllerProvider.register; - this.registerFunctions.directive = $compileProvider.directive; - this.registerFunctions.factory = $provide.factory; - this.registerFunctions.service = $provide.service; - this.registerFunctions.filter = $filterProvider.register; + this.registerFunctions.controller = $controllerProvider.register; + this.registerFunctions.directive = $compileProvider.directive; + this.registerFunctions.factory = $provide.factory; + this.registerFunctions.service = $provide.service; + this.registerFunctions.filter = $filterProvider.register; - $provide.decorator("$http", ["$delegate", "$templateCache", function($delegate, $templateCache) { - var get = $delegate.get; - $delegate.get = function(url, config) { - if (url.match(/\.html$/)) { - // some template's already exist in the cache - if (!$templateCache.get(url)) { - url += "?v=" + new Date().getTime(); - } + $provide.decorator("$http", [ + "$delegate", + "$templateCache", + function($delegate, $templateCache) { + var get = $delegate.get; + $delegate.get = function(url, config) { + if (url.match(/\.html$/)) { + // some template's already exist in the cache + if (!$templateCache.get(url)) { + url += "?v=" + new Date().getTime(); + } + } + return get(url, config); + }; + return $delegate; } - return get(url, config); - }; - return $delegate; - }]); - }); + ]); + } + ); this.ngModuleDependencies = [ - 'grafana.core', - 'ngRoute', - 'ngSanitize', - '$strap.directives', - 'ang-drag-drop', - 'grafana', - 'pasvaz.bindonce', - 'ui.bootstrap', - 'ui.bootstrap.tpls', - 'react' + "grafana.core", + "ngRoute", + "ngSanitize", + "$strap.directives", + "ang-drag-drop", + "grafana", + "pasvaz.bindonce", + "ui.bootstrap", + "ui.bootstrap.tpls", + "react" ]; - var module_types = ['controllers', 'directives', 'factories', 'services', 'filters', 'routes']; + var module_types = [ + "controllers", + "directives", + "factories", + "services", + "filters", + "routes" + ]; _.each(module_types, type => { - var moduleName = 'grafana.' + type; + var moduleName = "grafana." + type; this.useModule(angular.module(moduleName, [])); }); @@ -111,22 +131,24 @@ export class GrafanaApp { // register react angular wrappers registerAngularDirectives(); - var preBootRequires = [System.import('app/features/all')]; + var preBootRequires = [System.import("app/features/all")]; - Promise.all(preBootRequires).then(() => { - // disable tool tip animation - $.fn.tooltip.defaults.animation = false; - // bootstrap the app - angular.bootstrap(document, this.ngModuleDependencies).invoke(() => { - _.each(this.preBootModules, module => { - _.extend(module, this.registerFunctions); + Promise.all(preBootRequires) + .then(() => { + // disable tool tip animation + $.fn.tooltip.defaults.animation = false; + // bootstrap the app + angular.bootstrap(document, this.ngModuleDependencies).invoke(() => { + _.each(this.preBootModules, module => { + _.extend(module, this.registerFunctions); + }); + + this.preBootModules = null; }); - - this.preBootModules = null; + }) + .catch(function(err) { + console.log("Application boot failed:", err); }); - }).catch(function(err) { - console.log('Application boot failed:', err); - }); } } diff --git a/public/app/core/app_events.ts b/public/app/core/app_events.ts index b9a77a5f7b7..789e6e14209 100644 --- a/public/app/core/app_events.ts +++ b/public/app/core/app_events.ts @@ -1,4 +1,4 @@ -import {Emitter} from './utils/emitter'; +import { Emitter } from "./utils/emitter"; var appEvents = new Emitter(); export default appEvents; diff --git a/public/app/core/components/code_editor/code_editor.ts b/public/app/core/components/code_editor/code_editor.ts index 048d7beaa0b..c8646020892 100644 --- a/public/app/core/components/code_editor/code_editor.ts +++ b/public/app/core/components/code_editor/code_editor.ts @@ -26,20 +26,20 @@ * Ctrl-Enter (Command-Enter): run onChange() function */ -import coreModule from 'app/core/core_module'; -import config from 'app/core/config'; -import ace from 'brace'; -import './theme-grafana-dark'; -import 'brace/ext/language_tools'; -import 'brace/theme/textmate'; -import 'brace/mode/text'; -import 'brace/snippets/text'; -import 'brace/mode/sql'; -import 'brace/snippets/sql'; -import 'brace/mode/markdown'; -import 'brace/snippets/markdown'; -import 'brace/mode/json'; -import 'brace/snippets/json'; +import coreModule from "app/core/core_module"; +import config from "app/core/config"; +import ace from "brace"; +import "./theme-grafana-dark"; +import "brace/ext/language_tools"; +import "brace/theme/textmate"; +import "brace/mode/text"; +import "brace/snippets/text"; +import "brace/mode/sql"; +import "brace/snippets/sql"; +import "brace/mode/markdown"; +import "brace/snippets/markdown"; +import "brace/mode/json"; +import "brace/snippets/json"; const DEFAULT_THEME_DARK = "ace/theme/grafana-dark"; const DEFAULT_THEME_LIGHT = "ace/theme/textmate"; @@ -56,7 +56,9 @@ function link(scope, elem, attrs) { let maxLines = attrs.maxLines || DEFAULT_MAX_LINES; let showGutter = attrs.showGutter !== undefined; let tabSize = attrs.tabSize || DEFAULT_TAB_SIZE; - let behavioursEnabled = attrs.behavioursEnabled ? attrs.behavioursEnabled === 'true' : DEFAULT_BEHAVIOURS; + let behavioursEnabled = attrs.behavioursEnabled + ? attrs.behavioursEnabled === "true" + : DEFAULT_BEHAVIOURS; // Initialize editor let aceElem = elem.get(0); @@ -88,10 +90,10 @@ function link(scope, elem, attrs) { // Add classes elem.addClass("gf-code-editor"); let textarea = elem.find("textarea"); - textarea.addClass('gf-form-input'); + textarea.addClass("gf-form-input"); if (scope.codeEditorFocus) { - setTimeout(function () { + setTimeout(function() { textarea.focus(); var domEl = textarea[0]; if (domEl.setSelectionRange) { @@ -102,7 +104,7 @@ function link(scope, elem, attrs) { } // Event handlers - editorSession.on('change', (e) => { + editorSession.on("change", e => { scope.$apply(() => { let newValue = codeEditor.getValue(); scope.content = newValue; @@ -110,7 +112,7 @@ function link(scope, elem, attrs) { }); // Sync with outer scope - update editor content if model has been changed from outside of directive. - scope.$watch('content', (newValue, oldValue) => { + scope.$watch("content", (newValue, oldValue) => { let editorValue = codeEditor.getValue(); if (newValue !== editorValue && newValue !== oldValue) { scope.$$postDigest(function() { @@ -119,7 +121,7 @@ function link(scope, elem, attrs) { } }); - codeEditor.on('blur', () => { + codeEditor.on("blur", () => { scope.onChange(); }); @@ -129,8 +131,8 @@ function link(scope, elem, attrs) { // Keybindings codeEditor.commands.addCommand({ - name: 'executeQuery', - bindKey: {win: 'Ctrl-Enter', mac: 'Command-Enter'}, + name: "executeQuery", + bindKey: { win: "Ctrl-Enter", mac: "Command-Enter" }, exec: () => { scope.onChange(); } @@ -172,7 +174,7 @@ function link(scope, elem, attrs) { export function codeEditorDirective() { return { - restrict: 'E', + restrict: "E", template: editorTemplate, scope: { content: "=", @@ -185,4 +187,4 @@ export function codeEditorDirective() { }; } -coreModule.directive('codeEditor', codeEditorDirective); +coreModule.directive("codeEditor", codeEditorDirective); diff --git a/public/app/core/components/colorpicker/spectrum_picker.ts b/public/app/core/components/colorpicker/spectrum_picker.ts index 183cebffe2b..8b46bc3fdc9 100644 --- a/public/app/core/components/colorpicker/spectrum_picker.ts +++ b/public/app/core/components/colorpicker/spectrum_picker.ts @@ -3,22 +3,23 @@ * Allows remaining untouched in outdated plugins. * Technically, it's just a wrapper for react component with two-way data binding support. */ -import coreModule from '../../core_module'; +import coreModule from "../../core_module"; /** @ngInject */ export function spectrumPicker() { return { - restrict: 'E', - require: 'ngModel', + restrict: "E", + require: "ngModel", scope: true, replace: true, - template: '', + template: + '', link: function(scope, element, attrs, ngModel) { scope.ngModel = ngModel; - scope.onColorChange = (color) => { + scope.onColorChange = color => { ngModel.$setViewValue(color); }; } }; } -coreModule.directive('spectrumPicker', spectrumPicker); +coreModule.directive("spectrumPicker", spectrumPicker); diff --git a/public/app/core/components/dashboard_selector.ts b/public/app/core/components/dashboard_selector.ts index ac8b30e7733..b52227cc9a6 100644 --- a/public/app/core/components/dashboard_selector.ts +++ b/public/app/core/components/dashboard_selector.ts @@ -1,4 +1,4 @@ -import coreModule from 'app/core/core_module'; +import coreModule from "app/core/core_module"; var template = ` @@ -9,15 +9,14 @@ export class DashboardSelectorCtrl { options: any; /** @ngInject */ - constructor(private backendSrv) { - } + constructor(private backendSrv) {} $onInit() { - this.options = [{value: 0, text: 'Default'}]; + this.options = [{ value: 0, text: "Default" }]; - return this.backendSrv.search({starred: true}).then(res => { + return this.backendSrv.search({ starred: true }).then(res => { res.forEach(dash => { - this.options.push({value: dash.id, text: dash.title}); + this.options.push({ value: dash.id, text: dash.title }); }); }); } @@ -25,15 +24,15 @@ export class DashboardSelectorCtrl { export function dashboardSelector() { return { - restrict: 'E', + restrict: "E", controller: DashboardSelectorCtrl, bindToController: true, - controllerAs: 'ctrl', + controllerAs: "ctrl", template: template, scope: { - model: '=' + model: "=" } }; } -coreModule.directive('dashboardSelector', dashboardSelector); +coreModule.directive("dashboardSelector", dashboardSelector); diff --git a/public/app/core/components/form_dropdown/form_dropdown.ts b/public/app/core/components/form_dropdown/form_dropdown.ts index 364d61cfcdb..bdea18e6276 100644 --- a/public/app/core/components/form_dropdown/form_dropdown.ts +++ b/public/app/core/components/form_dropdown/form_dropdown.ts @@ -1,11 +1,15 @@ -import _ from 'lodash'; -import $ from 'jquery'; -import coreModule from '../../core_module'; +import _ from "lodash"; +import $ from "jquery"; +import coreModule from "../../core_module"; function typeaheadMatcher(item) { var str = this.query; - if (str[0] === '/') { str = str.substring(1); } - if (str[str.length - 1] === '/') { str = str.substring(0, str.length-1); } + if (str[0] === "/") { + str = str.substring(1); + } + if (str[str.length - 1] === "/") { + str = str.substring(0, str.length - 1); + } return item.toLowerCase().match(str.toLowerCase()); } @@ -28,9 +32,15 @@ export class FormDropdownCtrl { lookupText: boolean; /** @ngInject **/ - constructor(private $scope, $element, private $sce, private templateSrv, private $q) { - this.inputElement = $element.find('input').first(); - this.linkElement = $element.find('a').first(); + constructor( + private $scope, + $element, + private $sce, + private templateSrv, + private $q + ) { + this.inputElement = $element.find("input").first(); + this.linkElement = $element.find("a").first(); this.linkMode = true; this.cancelBlur = null; @@ -38,25 +48,26 @@ export class FormDropdownCtrl { $scope.$watch("ctrl.model", this.modelChanged.bind(this)); if (this.labelMode) { - this.cssClasses = 'gf-form-label ' + this.cssClass; + this.cssClasses = "gf-form-label " + this.cssClass; } else { - this.cssClasses = 'gf-form-input gf-form-input--dropdown ' + this.cssClass; + this.cssClasses = + "gf-form-input gf-form-input--dropdown " + this.cssClass; } - this.inputElement.attr('data-provide', 'typeahead'); + this.inputElement.attr("data-provide", "typeahead"); this.inputElement.typeahead({ source: this.typeaheadSource.bind(this), minLength: 0, items: 10000, updater: this.typeaheadUpdater.bind(this), - matcher: typeaheadMatcher, + matcher: typeaheadMatcher }); // modify typeahead lookup // this = typeahead - var typeahead = this.inputElement.data('typeahead'); - typeahead.lookup = function () { - this.query = this.$element.val() || ''; + var typeahead = this.inputElement.data("typeahead"); + typeahead.lookup = function() { + this.query = this.$element.val() || ""; var items = this.source(this.query, $.proxy(this.process, this)); return items ? this.process(items) : items; }; @@ -80,7 +91,7 @@ export class FormDropdownCtrl { } getOptionsInternal(query) { - var result = this.getOptions({$query: query}); + var result = this.getOptions({ $query: query }); if (this.isPromiseLike(result)) { return result; } @@ -88,7 +99,7 @@ export class FormDropdownCtrl { } isPromiseLike(obj) { - return obj && (typeof obj.then === 'function'); + return obj && typeof obj.then === "function"; } modelChanged() { @@ -98,7 +109,7 @@ export class FormDropdownCtrl { // if we have text use it if (this.lookupText) { this.getOptionsInternal("").then(options => { - var item = _.find(options, {value: this.model}); + var item = _.find(options, { value: this.model }); this.updateDisplay(item ? item.text : this.model); }); } else { @@ -140,7 +151,9 @@ export class FormDropdownCtrl { } switchToLink(fromClick) { - if (this.linkMode && !fromClick) { return; } + if (this.linkMode && !fromClick) { + return; + } clearTimeout(this.cancelBlur); this.cancelBlur = null; @@ -159,12 +172,12 @@ export class FormDropdownCtrl { updateValue(text) { text = _.unescape(text); - if (text === '' || this.text === text) { + if (text === "" || this.text === text) { return; } this.$scope.$apply(() => { - var option = _.find(this.optionCache, {text: text}); + var option = _.find(this.optionCache, { text: text }); if (option) { if (_.isObject(this.model)) { @@ -186,20 +199,24 @@ export class FormDropdownCtrl { // property is synced with outerscope this.$scope.$$postDigest(() => { this.$scope.$apply(() => { - this.onChange({$option: option}); + this.onChange({ $option: option }); }); }); - }); } updateDisplay(text) { this.text = text; - this.display = this.$sce.trustAsHtml(this.templateSrv.highlightVariablesAsHtml(text)); + this.display = this.$sce.trustAsHtml( + this.templateSrv.highlightVariablesAsHtml(text) + ); } open() { - this.inputElement.css('width', (Math.max(this.linkElement.width(), 80) + 16) + 'px'); + this.inputElement.css( + "width", + Math.max(this.linkElement.width(), 80) + 16 + "px" + ); this.inputElement.show(); this.inputElement.focus(); @@ -207,15 +224,15 @@ export class FormDropdownCtrl { this.linkElement.hide(); this.linkMode = false; - var typeahead = this.inputElement.data('typeahead'); + var typeahead = this.inputElement.data("typeahead"); if (typeahead) { - this.inputElement.val(''); + this.inputElement.val(""); typeahead.lookup(); } } } -const template = ` +const template = ` -import coreModule from 'app/core/core_module'; +import coreModule from "app/core/core_module"; const template = `
@@ -24,14 +24,14 @@ const template = ` export function gfPageDirective() { return { - restrict: 'E', + restrict: "E", template: template, scope: { - "model": "=", + model: "=" }, transclude: { - 'header': '?gfPageHeader', - 'body': 'gfPageBody', + header: "?gfPageHeader", + body: "gfPageBody" }, link: function(scope, elem, attrs) { console.log(scope); @@ -39,4 +39,4 @@ export function gfPageDirective() { }; } -coreModule.directive('gfPage', gfPageDirective); +coreModule.directive("gfPage", gfPageDirective); diff --git a/public/app/core/components/grafana_app.ts b/public/app/core/components/grafana_app.ts index 5db9b71f9e9..f8511d393e9 100644 --- a/public/app/core/components/grafana_app.ts +++ b/public/app/core/components/grafana_app.ts @@ -1,17 +1,23 @@ -import config from 'app/core/config'; -import _ from 'lodash'; -import $ from 'jquery'; +import config from "app/core/config"; +import _ from "lodash"; +import $ from "jquery"; -import coreModule from 'app/core/core_module'; -import {profiler} from 'app/core/profiler'; -import appEvents from 'app/core/app_events'; -import Drop from 'tether-drop'; +import coreModule from "app/core/core_module"; +import { profiler } from "app/core/profiler"; +import appEvents from "app/core/app_events"; +import Drop from "tether-drop"; export class GrafanaCtrl { - /** @ngInject */ - constructor($scope, alertSrv, utilSrv, $rootScope, $controller, contextSrv, globalEventSrv) { - + constructor( + $scope, + alertSrv, + utilSrv, + $rootScope, + $controller, + contextSrv, + globalEventSrv + ) { $scope.init = function() { $scope.contextSrv = contextSrv; @@ -28,19 +34,19 @@ export class GrafanaCtrl { $scope.initDashboard = function(dashboardData, viewScope) { $scope.appEvent("dashboard-fetch-end", dashboardData); - $controller('DashboardCtrl', { $scope: viewScope }).init(dashboardData); + $controller("DashboardCtrl", { $scope: viewScope }).init(dashboardData); }; $rootScope.onAppEvent = function(name, callback, localScope) { var unbind = $rootScope.$on(name, callback); var callerScope = this; if (callerScope.$id === 1 && !localScope) { - console.log('warning rootScope onAppEvent called without localscope'); + console.log("warning rootScope onAppEvent called without localscope"); } if (localScope) { callerScope = localScope; } - callerScope.$on('$destroy', unbind); + callerScope.$on("$destroy", unbind); }; $rootScope.appEvent = function(name, payload) { @@ -49,13 +55,62 @@ export class GrafanaCtrl { }; $rootScope.colors = [ - "#7EB26D","#EAB839","#6ED0E0","#EF843C","#E24D42","#1F78C1","#BA43A9","#705DA0", - "#508642","#CCA300","#447EBC","#C15C17","#890F02","#0A437C","#6D1F62","#584477", - "#B7DBAB","#F4D598","#70DBED","#F9BA8F","#F29191","#82B5D8","#E5A8E2","#AEA2E0", - "#629E51","#E5AC0E","#64B0C8","#E0752D","#BF1B00","#0A50A1","#962D82","#614D93", - "#9AC48A","#F2C96D","#65C5DB","#F9934E","#EA6460","#5195CE","#D683CE","#806EB7", - "#3F6833","#967302","#2F575E","#99440A","#58140C","#052B51","#511749","#3F2B5B", - "#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" + "#7EB26D", + "#EAB839", + "#6ED0E0", + "#EF843C", + "#E24D42", + "#1F78C1", + "#BA43A9", + "#705DA0", + "#508642", + "#CCA300", + "#447EBC", + "#C15C17", + "#890F02", + "#0A437C", + "#6D1F62", + "#584477", + "#B7DBAB", + "#F4D598", + "#70DBED", + "#F9BA8F", + "#F29191", + "#82B5D8", + "#E5A8E2", + "#AEA2E0", + "#629E51", + "#E5AC0E", + "#64B0C8", + "#E0752D", + "#BF1B00", + "#0A50A1", + "#962D82", + "#614D93", + "#9AC48A", + "#F2C96D", + "#65C5DB", + "#F9934E", + "#EA6460", + "#5195CE", + "#D683CE", + "#806EB7", + "#3F6833", + "#967302", + "#2F575E", + "#99440A", + "#58140C", + "#052B51", + "#511749", + "#3F2B5B", + "#E0F9D7", + "#FCEACA", + "#CFFAFF", + "#F9E2D2", + "#FCE2DE", + "#BADFF4", + "#F9D9F9", + "#DEDAF7" ]; $scope.init(); @@ -63,30 +118,35 @@ export class GrafanaCtrl { } /** @ngInject */ -export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScope) { +export function grafanaAppDirective( + playlistSrv, + contextSrv, + $timeout, + $rootScope +) { return { - restrict: 'E', + restrict: "E", controller: GrafanaCtrl, link: (scope, elem) => { var sidemenuOpen; - var body = $('body'); + var body = $("body"); // see https://github.com/zenorocha/clipboard.js/issues/155 $.fn.modal.Constructor.prototype.enforceFocus = function() {}; sidemenuOpen = scope.contextSrv.sidemenu; - body.toggleClass('sidemenu-open', sidemenuOpen); + body.toggleClass("sidemenu-open", sidemenuOpen); - appEvents.on('toggle-sidemenu', () => { - body.toggleClass('sidemenu-open'); + appEvents.on("toggle-sidemenu", () => { + body.toggleClass("sidemenu-open"); }); - appEvents.on('toggle-sidemenu-mobile', () => { - body.toggleClass('sidemenu-open--xs'); + appEvents.on("toggle-sidemenu-mobile", () => { + body.toggleClass("sidemenu-open--xs"); }); - appEvents.on('toggle-sidemenu-hidden', () => { - body.toggleClass('sidemenu-hidden'); + appEvents.on("toggle-sidemenu-hidden", () => { + body.toggleClass("sidemenu-hidden"); }); // tooltip removal fix @@ -105,13 +165,13 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop } // clear body class sidemenu states - body.removeClass('sidemenu-open--xs'); + body.removeClass("sidemenu-open--xs"); $("#tooltip, .tooltip").remove(); // check for kiosk url param if (data.params.kiosk) { - appEvents.emit('toggle-kiosk-mode'); + appEvents.emit("toggle-kiosk-mode"); } // close all drops @@ -121,8 +181,8 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop }); // handle kiosk mode - appEvents.on('toggle-kiosk-mode', () => { - body.toggleClass('page-kiosk-mode'); + appEvents.on("toggle-kiosk-mode", () => { + body.toggleClass("page-kiosk-mode"); }); // handle in active view state class @@ -136,17 +196,17 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop return; } // only go to activity low mode on dashboard page - if (!body.hasClass('page-dashboard')) { + if (!body.hasClass("page-dashboard")) { return; } - if ((new Date().getTime() - lastActivity) > inActiveTimeLimit) { + if (new Date().getTime() - lastActivity > inActiveTimeLimit) { activeUser = false; - body.addClass('user-activity-low'); + body.addClass("user-activity-low"); // hide sidemenu if (sidemenuOpen) { sidemenuHidden = true; - body.removeClass('sidemenu-open'); + body.removeClass("sidemenu-open"); $timeout(function() { $rootScope.$broadcast("render"); }, 100); @@ -158,12 +218,12 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop lastActivity = new Date().getTime(); if (!activeUser) { activeUser = true; - body.removeClass('user-activity-low'); + body.removeClass("user-activity-low"); // restore sidemenu if (sidemenuHidden) { sidemenuHidden = false; - body.addClass('sidemenu-open'); + body.addClass("sidemenu-open"); $timeout(function() { $rootScope.$broadcast("render"); }, 100); @@ -175,12 +235,12 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop body.mousemove(userActivityDetected); body.keydown(userActivityDetected); // treat tab change as activity - document.addEventListener('visibilitychange', userActivityDetected); + document.addEventListener("visibilitychange", userActivityDetected); // check every 2 seconds setInterval(checkForInActiveUser, 2000); - appEvents.on('toggle-view-mode', () => { + appEvents.on("toggle-view-mode", () => { lastActivity = 0; checkForInActiveUser(); }); @@ -194,7 +254,7 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop // for stuff that animates, slides out etc, clicking it needs to // hide it right away - var clickAutoHide = target.closest('[data-click-hide]'); + var clickAutoHide = target.closest("[data-click-hide]"); if (clickAutoHide.length) { var clickAutoHideParent = clickAutoHide.parent(); clickAutoHide.detach(); @@ -203,22 +263,28 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop }, 100); } - if (target.parents('.navbar-buttons--playlist').length === 0) { + if (target.parents(".navbar-buttons--playlist").length === 0) { playlistSrv.stop(); } // hide search - if (body.find('.search-container').length > 0) { - if (target.parents('.search-results-container, .search-field-wrapper').length === 0) { + if (body.find(".search-container").length > 0) { + if ( + target.parents(".search-results-container, .search-field-wrapper") + .length === 0 + ) { scope.$apply(function() { - scope.appEvent('hide-dash-search'); + scope.appEvent("hide-dash-search"); }); } } // hide popovers - var popover = elem.find('.popover'); - if (popover.length > 0 && target.parents('.graph-legend').length === 0) { + var popover = elem.find(".popover"); + if ( + popover.length > 0 && + target.parents(".graph-legend").length === 0 + ) { popover.hide(); } }); @@ -226,4 +292,4 @@ export function grafanaAppDirective(playlistSrv, contextSrv, $timeout, $rootScop }; } -coreModule.directive('grafanaApp', grafanaAppDirective); +coreModule.directive("grafanaApp", grafanaAppDirective); diff --git a/public/app/core/components/help/help.ts b/public/app/core/components/help/help.ts index bf84b43b5f9..b59ebaaedf6 100644 --- a/public/app/core/components/help/help.ts +++ b/public/app/core/components/help/help.ts @@ -1,7 +1,7 @@ /// -import coreModule from '../../core_module'; -import appEvents from 'app/core/app_events'; +import coreModule from "../../core_module"; +import appEvents from "app/core/app_events"; export class HelpCtrl { tabIndex: any; @@ -11,58 +11,64 @@ export class HelpCtrl { constructor() { this.tabIndex = 0; this.shortcuts = { - 'Global': [ - {keys: ['g', 'h'], description: 'Go to Home Dashboard'}, - {keys: ['g', 'p'], description: 'Go to Profile'}, - {keys: ['s', 'o'], description: 'Open search'}, - {keys: ['s', 's'], description: 'Open search with starred filter'}, - {keys: ['s', 't'], description: 'Open search in tags view'}, - {keys: ['esc'], description: 'Exit edit/setting views'}, + Global: [ + { keys: ["g", "h"], description: "Go to Home Dashboard" }, + { keys: ["g", "p"], description: "Go to Profile" }, + { keys: ["s", "o"], description: "Open search" }, + { keys: ["s", "s"], description: "Open search with starred filter" }, + { keys: ["s", "t"], description: "Open search in tags view" }, + { keys: ["esc"], description: "Exit edit/setting views" } ], - 'Dashboard': [ - {keys: ['mod+s'], description: 'Save dashboard'}, - {keys: ['mod+h'], description: 'Hide row controls'}, - {keys: ['d', 'r'], description: 'Refresh all panels'}, - {keys: ['d', 's'], description: 'Dashboard settings'}, - {keys: ['d', 'v'], description: 'Toggle in-active / view mode'}, - {keys: ['d', 'k'], description: 'Toggle kiosk mode (hides top nav)'}, - {keys: ['d', 'E'], description: 'Expand all rows'}, - {keys: ['d', 'C'], description: 'Collapse all rows'}, - {keys: ['mod+o'], description: 'Toggle shared graph crosshair'}, + Dashboard: [ + { keys: ["mod+s"], description: "Save dashboard" }, + { keys: ["mod+h"], description: "Hide row controls" }, + { keys: ["d", "r"], description: "Refresh all panels" }, + { keys: ["d", "s"], description: "Dashboard settings" }, + { keys: ["d", "v"], description: "Toggle in-active / view mode" }, + { keys: ["d", "k"], description: "Toggle kiosk mode (hides top nav)" }, + { keys: ["d", "E"], description: "Expand all rows" }, + { keys: ["d", "C"], description: "Collapse all rows" }, + { keys: ["mod+o"], description: "Toggle shared graph crosshair" } ], - 'Focused Panel': [ - {keys: ['e'], description: 'Toggle panel edit view'}, - {keys: ['v'], description: 'Toggle panel fullscreen view'}, - {keys: ['p', 's'], description: 'Open Panel Share Modal'}, - {keys: ['p', 'r'], description: 'Remove Panel'}, + "Focused Panel": [ + { keys: ["e"], description: "Toggle panel edit view" }, + { keys: ["v"], description: "Toggle panel fullscreen view" }, + { keys: ["p", "s"], description: "Open Panel Share Modal" }, + { keys: ["p", "r"], description: "Remove Panel" } ], - 'Focused Row': [ - {keys: ['r', 'c'], description: 'Collapse Row'}, - {keys: ['r', 'r'], description: 'Remove Row'}, - ], - 'Time Range': [ - {keys: ['t', 'z'], description: 'Zoom out time range'}, - {keys: ['t', ''], description: 'Move time range back'}, - {keys: ['t', ''], description: 'Move time range forward'}, + "Focused Row": [ + { keys: ["r", "c"], description: "Collapse Row" }, + { keys: ["r", "r"], description: "Remove Row" } ], + "Time Range": [ + { keys: ["t", "z"], description: "Zoom out time range" }, + { + keys: ["t", ''], + description: "Move time range back" + }, + { + keys: ["t", ''], + description: "Move time range forward" + } + ] }; } dismiss() { - appEvents.emit('hide-modal'); + appEvents.emit("hide-modal"); } } export function helpModal() { return { - restrict: 'E', - templateUrl: 'public/app/core/components/help/help.html', + restrict: "E", + templateUrl: "public/app/core/components/help/help.html", controller: HelpCtrl, bindToController: true, transclude: true, - controllerAs: 'ctrl', - scope: {}, + controllerAs: "ctrl", + scope: {} }; } -coreModule.directive('helpModal', helpModal); +coreModule.directive("helpModal", helpModal); diff --git a/public/app/core/components/info_popover.ts b/public/app/core/components/info_popover.ts index 954e84a3baa..cac25b28b9d 100644 --- a/public/app/core/components/info_popover.ts +++ b/public/app/core/components/info_popover.ts @@ -1,35 +1,35 @@ /// -import _ from 'lodash'; -import coreModule from 'app/core/core_module'; -import Drop from 'tether-drop'; +import _ from "lodash"; +import coreModule from "app/core/core_module"; +import Drop from "tether-drop"; export function infoPopover() { return { - restrict: 'E', + restrict: "E", template: '', transclude: true, link: function(scope, elem, attrs, ctrl, transclude) { - var offset = attrs.offset || '0 -10px'; - var position = attrs.position || 'right middle'; - var classes = 'drop-help drop-hide-out-of-bounds'; - var openOn = 'hover'; + var offset = attrs.offset || "0 -10px"; + var position = attrs.position || "right middle"; + var classes = "drop-help drop-hide-out-of-bounds"; + var openOn = "hover"; - elem.addClass('gf-form-help-icon'); + elem.addClass("gf-form-help-icon"); if (attrs.wide) { - classes += ' drop-wide'; + classes += " drop-wide"; } if (attrs.mode) { - elem.addClass('gf-form-help-icon--' + attrs.mode); + elem.addClass("gf-form-help-icon--" + attrs.mode); } transclude(function(clone, newScope) { var content = document.createElement("div"); - content.className = 'markdown-html'; + content.className = "markdown-html"; - _.each(clone, (node) => { + _.each(clone, node => { content.appendChild(node); }); @@ -43,23 +43,22 @@ export function infoPopover() { tetherOptions: { offset: offset, constraints: [ - { - to: 'window', - attachment: 'together', - pin: true - } - ], + { + to: "window", + attachment: "together", + pin: true + } + ] } }); - var unbind = scope.$on('$destroy', function() { + var unbind = scope.$on("$destroy", function() { drop.destroy(); unbind(); }); - }); } }; } -coreModule.directive('infoPopover', infoPopover); +coreModule.directive("infoPopover", infoPopover); diff --git a/public/app/core/components/json_explorer/helpers.ts b/public/app/core/components/json_explorer/helpers.ts index 7c4429d7c76..c50fc5a0146 100644 --- a/public/app/core/components/json_explorer/helpers.ts +++ b/public/app/core/components/json_explorer/helpers.ts @@ -5,7 +5,7 @@ * Escapes `"` charachters from string */ function escapeString(str: string): string { - return str.replace('"', '\"'); + return str.replace('"', '"'); } /* @@ -13,7 +13,7 @@ function escapeString(str: string): string { */ export function isObject(value: any): boolean { var type = typeof value; - return !!value && (type === 'object'); + return !!value && type === "object"; } /* @@ -23,21 +23,21 @@ export function isObject(value: any): boolean { */ export function getObjectName(object: Object): string { if (object === undefined) { - return ''; + return ""; } if (object === null) { - return 'Object'; + return "Object"; } - if (typeof object === 'object' && !object.constructor) { - return 'Object'; + if (typeof object === "object" && !object.constructor) { + return "Object"; } const funcNameRegex = /function ([^(]*)/; - const results = (funcNameRegex).exec((object).constructor.toString()); + const results = funcNameRegex.exec(object.constructor.toString()); if (results && results.length > 1) { return results[1]; } else { - return ''; + return ""; } } @@ -45,27 +45,33 @@ export function getObjectName(object: Object): string { * Gets type of an object. Returns "null" for null objects */ export function getType(object: Object): string { - if (object === null) { return 'null'; } + if (object === null) { + return "null"; + } return typeof object; } /* * Generates inline preview for a JavaScript object based on a value */ -export function getValuePreview (object: Object, value: string): string { +export function getValuePreview(object: Object, value: string): string { var type = getType(object); - if (type === 'null' || type === 'undefined') { return type; } + if (type === "null" || type === "undefined") { + return type; + } - if (type === 'string') { + if (type === "string") { value = '"' + escapeString(value) + '"'; } - if (type === 'function') { - + if (type === "function") { // Remove content of the function - return object.toString() - .replace(/[\r\n]/g, '') - .replace(/\{.*\}/, '') + '{…}'; + return ( + object + .toString() + .replace(/[\r\n]/g, "") + .replace(/\{.*\}/, "") + "{…}" + ); } return value; } @@ -74,11 +80,11 @@ export function getValuePreview (object: Object, value: string): string { * Generates inline preview for a JavaScript object */ export function getPreview(object: string): string { - let value = ''; + let value = ""; if (isObject(object)) { value = getObjectName(object); if (Array.isArray(object)) { - value += '[' + object.length + ']'; + value += "[" + object.length + "]"; } } else { value = getValuePreview(object, object); @@ -97,7 +103,11 @@ export function cssClass(className: string): string { * Creates a new DOM element wiht given type and class * TODO: move me to helpers */ -export function createElement(type: string, className?: string, content?: Element|string): Element { +export function createElement( + type: string, + className?: string, + content?: Element | string +): Element { const el = document.createElement(type); if (className) { el.classList.add(cssClass(className)); diff --git a/public/app/core/components/json_explorer/json_explorer.ts b/public/app/core/components/json_explorer/json_explorer.ts index a7079477abc..01c0099c178 100644 --- a/public/app/core/components/json_explorer/json_explorer.ts +++ b/public/app/core/components/json_explorer/json_explorer.ts @@ -8,9 +8,9 @@ import { getValuePreview, cssClass, createElement -} from './helpers'; +} from "./helpers"; -import _ from 'lodash'; +import _ from "lodash"; const DATE_STRING_REGEX = /(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/; const PARTIAL_DATE_REGEX = /\d{2}:\d{2}:\d{2} GMT-\d{4}/; @@ -19,7 +19,12 @@ const JSON_DATE_REGEX = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/; // When toggleing, don't animated removal or addition of more than a few items const MAX_ANIMATED_TOGGLE_ITEMS = 10; -const requestAnimationFrame = window.requestAnimationFrame || function(cb: ()=>void) { cb(); return 0; }; +const requestAnimationFrame = + window.requestAnimationFrame || + function(cb: () => void) { + cb(); + return 0; + }; export interface JsonExplorerConfig { animateOpen?: boolean; @@ -33,15 +38,13 @@ const _defaultConfig: JsonExplorerConfig = { theme: null }; - /** * @class JsonExplorer * * JsonExplorer allows you to render JSON objects in HTML with a * **collapsible** navigation. -*/ + */ export class JsonExplorer { - // Hold the open state after the toggler is used private _isOpen: boolean = null; @@ -77,9 +80,13 @@ export class JsonExplorer { * * @param {string} [key=undefined] The key that this object in it's parent * context - */ - constructor(public json: any, private open = 1, private config: JsonExplorerConfig = _defaultConfig, private key?: string) { - } + */ + constructor( + public json: any, + private open = 1, + private config: JsonExplorerConfig = _defaultConfig, + private key?: string + ) {} /* * is formatter open? @@ -103,17 +110,19 @@ export class JsonExplorer { * is this a date string? */ private get isDate(): boolean { - return (this.type === 'string') && + return ( + this.type === "string" && (DATE_STRING_REGEX.test(this.json) || - JSON_DATE_REGEX.test(this.json) || - PARTIAL_DATE_REGEX.test(this.json)); + JSON_DATE_REGEX.test(this.json) || + PARTIAL_DATE_REGEX.test(this.json)) + ); } /* * is this a URL string? */ private get isUrl(): boolean { - return this.type === 'string' && (this.json.indexOf('http') === 0); + return this.type === "string" && this.json.indexOf("http") === 0; } /* @@ -142,7 +151,9 @@ export class JsonExplorer { * is this an empty object or array? */ private get isEmpty(): boolean { - return this.isEmptyObject || (this.keys && !this.keys.length && this.isArray); + return ( + this.isEmptyObject || (this.keys && !this.keys.length && this.isArray) + ); } /* @@ -150,7 +161,7 @@ export class JsonExplorer { * This means that the formatter was called as a sub formatter of a parent formatter */ private get hasKey(): boolean { - return typeof this.key !== 'undefined'; + return typeof this.key !== "undefined"; } /* @@ -174,7 +185,7 @@ export class JsonExplorer { */ private get keys(): string[] { if (this.isObject) { - return Object.keys(this.json).map((key)=> key ? key : '""'); + return Object.keys(this.json).map(key => (key ? key : '""')); } else { return []; } @@ -183,7 +194,7 @@ export class JsonExplorer { /** * Toggles `isOpen` state * - */ + */ toggleOpen() { this.isOpen = !this.isOpen; @@ -193,58 +204,65 @@ export class JsonExplorer { } else { this.removeChildren(this.config.animateClose); } - this.element.classList.toggle(cssClass('open')); + this.element.classList.toggle(cssClass("open")); } } /** - * Open all children up to a certain depth. - * Allows actions such as expand all/collapse all - * - */ + * Open all children up to a certain depth. + * Allows actions such as expand all/collapse all + * + */ openAtDepth(depth = 1) { if (depth < 0) { return; } this.open = depth; - this.isOpen = (depth !== 0); + this.isOpen = depth !== 0; if (this.element) { this.removeChildren(false); if (depth === 0) { - this.element.classList.remove(cssClass('open')); + this.element.classList.remove(cssClass("open")); } else { this.appendChildren(this.config.animateOpen); - this.element.classList.add(cssClass('open')); + this.element.classList.add(cssClass("open")); } } } isNumberArray() { - return (this.json.length > 0 && this.json.length < 4) && - (_.isNumber(this.json[0]) || _.isNumber(this.json[1])); + return ( + this.json.length > 0 && + this.json.length < 4 && + (_.isNumber(this.json[0]) || _.isNumber(this.json[1])) + ); } renderArray() { - const arrayWrapperSpan = createElement('span'); - arrayWrapperSpan.appendChild(createElement('span', 'bracket', '[')); + const arrayWrapperSpan = createElement("span"); + arrayWrapperSpan.appendChild(createElement("span", "bracket", "[")); // some pretty handling of number arrays if (this.isNumberArray()) { this.json.forEach((val, index) => { if (index > 0) { - arrayWrapperSpan.appendChild(createElement('span', 'array-comma', ',')); + arrayWrapperSpan.appendChild( + createElement("span", "array-comma", ",") + ); } - arrayWrapperSpan.appendChild(createElement('span', 'number', val)); + arrayWrapperSpan.appendChild(createElement("span", "number", val)); }); this.skipChildren = true; } else { - arrayWrapperSpan.appendChild(createElement('span', 'number', (this.json.length))); + arrayWrapperSpan.appendChild( + createElement("span", "number", this.json.length) + ); } - arrayWrapperSpan.appendChild(createElement('span', 'bracket', ']')); + arrayWrapperSpan.appendChild(createElement("span", "bracket", "]")); return arrayWrapperSpan; } @@ -255,11 +273,11 @@ export class JsonExplorer { */ render(skipRoot = false): HTMLDivElement { // construct the root element and assign it to this.element - this.element = createElement('div', 'row'); + this.element = createElement("div", "row"); // construct the toggler link - const togglerLink = createElement('a', 'toggler-link'); - const togglerIcon = createElement('span', 'toggler'); + const togglerLink = createElement("a", "toggler-link"); + const togglerIcon = createElement("span", "toggler"); // if this is an object we need a wrapper span (toggler) if (this.isObject) { @@ -268,19 +286,23 @@ export class JsonExplorer { // if this is child of a parent formatter we need to append the key if (this.hasKey) { - togglerLink.appendChild(createElement('span', 'key', `${this.key}:`)); + togglerLink.appendChild(createElement("span", "key", `${this.key}:`)); } // Value for objects and arrays if (this.isObject) { // construct the value holder element - const value = createElement('span', 'value'); + const value = createElement("span", "value"); // we need a wrapper span for objects - const objectWrapperSpan = createElement('span'); + const objectWrapperSpan = createElement("span"); // get constructor name and append it to wrapper span - var constructorName = createElement('span', 'constructor-name', this.constructorName); + var constructorName = createElement( + "span", + "constructor-name", + this.constructorName + ); objectWrapperSpan.appendChild(constructorName); // if it's an array append the array specific elements like brackets and length @@ -294,18 +316,17 @@ export class JsonExplorer { togglerLink.appendChild(value); // Primitive values } else { - // make a value holder element - const value = this.isUrl ? createElement('a') : createElement('span'); + const value = this.isUrl ? createElement("a") : createElement("span"); // add type and other type related CSS classes value.classList.add(cssClass(this.type)); if (this.isDate) { - value.classList.add(cssClass('date')); + value.classList.add(cssClass("date")); } if (this.isUrl) { - value.classList.add(cssClass('url')); - value.setAttribute('href', this.json); + value.classList.add(cssClass("url")); + value.setAttribute("href", this.json); } // Append value content to value element @@ -317,17 +338,17 @@ export class JsonExplorer { } // construct a children element - const children = createElement('div', 'children'); + const children = createElement("div", "children"); // set CSS classes for children if (this.isObject) { - children.classList.add(cssClass('object')); + children.classList.add(cssClass("object")); } if (this.isArray) { - children.classList.add(cssClass('array')); + children.classList.add(cssClass("array")); } if (this.isEmpty) { - children.classList.add(cssClass('empty')); + children.classList.add(cssClass("empty")); } // set CSS classes for root element @@ -335,7 +356,7 @@ export class JsonExplorer { this.element.classList.add(cssClass(this.config.theme)); } if (this.isOpen) { - this.element.classList.add(cssClass('open')); + this.element.classList.add(cssClass("open")); } // append toggler and children elements to root element @@ -357,7 +378,7 @@ export class JsonExplorer { // add event listener for toggling if (this.isObject) { - togglerLink.addEventListener('click', this.toggleOpen.bind(this)); + togglerLink.addEventListener("click", this.toggleOpen.bind(this)); } return this.element as HTMLDivElement; @@ -366,17 +387,24 @@ export class JsonExplorer { /** * Appends all the children to children element * Animated option is used when user triggers this via a click - */ + */ appendChildren(animated = false) { - const children = this.element.querySelector(`div.${cssClass('children')}`); + const children = this.element.querySelector(`div.${cssClass("children")}`); - if (!children || this.isEmpty) { return; } + if (!children || this.isEmpty) { + return; + } if (animated) { let index = 0; - const addAChild = ()=> { + const addAChild = () => { const key = this.keys[index]; - const formatter = new JsonExplorer(this.json[key], this.open - 1, this.config, key); + const formatter = new JsonExplorer( + this.json[key], + this.open - 1, + this.config, + key + ); children.appendChild(formatter.render()); index += 1; @@ -391,10 +419,14 @@ export class JsonExplorer { }; requestAnimationFrame(addAChild); - } else { this.keys.forEach(key => { - const formatter = new JsonExplorer(this.json[key], this.open - 1, this.config, key); + const formatter = new JsonExplorer( + this.json[key], + this.open - 1, + this.config, + key + ); children.appendChild(formatter.render()); }); } @@ -403,13 +435,15 @@ export class JsonExplorer { /** * Removes all the children from children element * Animated option is used when user triggers this via a click - */ + */ removeChildren(animated = false) { - const childrenElement = this.element.querySelector(`div.${cssClass('children')}`) as HTMLDivElement; + const childrenElement = this.element.querySelector( + `div.${cssClass("children")}` + ) as HTMLDivElement; if (animated) { let childrenRemoved = 0; - const removeAChild = ()=> { + const removeAChild = () => { if (childrenElement && childrenElement.children.length) { childrenElement.removeChild(childrenElement.children[0]); childrenRemoved += 1; @@ -423,7 +457,7 @@ export class JsonExplorer { requestAnimationFrame(removeAChild); } else { if (childrenElement) { - childrenElement.innerHTML = ''; + childrenElement.innerHTML = ""; } } } diff --git a/public/app/core/components/jsontree/jsontree.ts b/public/app/core/components/jsontree/jsontree.ts index 52fb64e1c87..6fac66d32f8 100644 --- a/public/app/core/components/jsontree/jsontree.ts +++ b/public/app/core/components/jsontree/jsontree.ts @@ -1,22 +1,23 @@ -import coreModule from 'app/core/core_module'; -import {JsonExplorer} from '../json_explorer/json_explorer'; +import coreModule from "app/core/core_module"; +import { JsonExplorer } from "../json_explorer/json_explorer"; -coreModule.directive('jsonTree', [function jsonTreeDirective() { - return{ - restrict: 'E', - scope: { - object: '=', - startExpanded: '@', - rootName: '@', - }, - link: function(scope, elem) { +coreModule.directive("jsonTree", [ + function jsonTreeDirective() { + return { + restrict: "E", + scope: { + object: "=", + startExpanded: "@", + rootName: "@" + }, + link: function(scope, elem) { + var jsonExp = new JsonExplorer(scope.object, 3, { + animateOpen: true + }); - var jsonExp = new JsonExplorer(scope.object, 3, { - animateOpen: true - }); - - const html = jsonExp.render(true); - elem.html(html); - } - }; -}]); + const html = jsonExp.render(true); + elem.html(html); + } + }; + } +]); diff --git a/public/app/core/components/layout_selector/layout_selector.ts b/public/app/core/components/layout_selector/layout_selector.ts index 98f806cd63e..d5dd105ddb9 100644 --- a/public/app/core/components/layout_selector/layout_selector.ts +++ b/public/app/core/components/layout_selector/layout_selector.ts @@ -1,5 +1,5 @@ -import store from 'app/core/store'; -import coreModule from 'app/core/core_module'; +import store from "app/core/store"; +import coreModule from "app/core/core_module"; var template = `
@@ -17,53 +17,56 @@ export class LayoutSelectorCtrl { /** @ngInject **/ constructor(private $rootScope) { - this.mode = store.get('grafana.list.layout.mode') || 'grid'; + this.mode = store.get("grafana.list.layout.mode") || "grid"; } listView() { - this.mode = 'list'; - store.set('grafana.list.layout.mode', 'list'); - this.$rootScope.appEvent('layout-mode-changed', 'list'); + this.mode = "list"; + store.set("grafana.list.layout.mode", "list"); + this.$rootScope.appEvent("layout-mode-changed", "list"); } gridView() { - this.mode = 'grid'; - store.set('grafana.list.layout.mode', 'grid'); - this.$rootScope.appEvent('layout-mode-changed', 'grid'); + this.mode = "grid"; + store.set("grafana.list.layout.mode", "grid"); + this.$rootScope.appEvent("layout-mode-changed", "grid"); } - } /** @ngInject **/ export function layoutSelector() { return { - restrict: 'E', + restrict: "E", controller: LayoutSelectorCtrl, bindToController: true, - controllerAs: 'ctrl', + controllerAs: "ctrl", scope: {}, - template: template, + template: template }; } /** @ngInject **/ export function layoutMode($rootScope) { return { - restrict: 'A', + restrict: "A", scope: {}, link: function(scope, elem) { - var layout = store.get('grafana.list.layout.mode') || 'grid'; - var className = 'card-list-layout-' + layout; + var layout = store.get("grafana.list.layout.mode") || "grid"; + var className = "card-list-layout-" + layout; elem.addClass(className); - $rootScope.onAppEvent('layout-mode-changed', (evt, newLayout) => { - elem.removeClass(className); - className = 'card-list-layout-' + newLayout; - elem.addClass(className); - }, scope); + $rootScope.onAppEvent( + "layout-mode-changed", + (evt, newLayout) => { + elem.removeClass(className); + className = "card-list-layout-" + newLayout; + elem.addClass(className); + }, + scope + ); } }; } -coreModule.directive('layoutSelector', layoutSelector); -coreModule.directive('layoutMode', layoutMode); +coreModule.directive("layoutSelector", layoutSelector); +coreModule.directive("layoutMode", layoutMode); diff --git a/public/app/core/components/manage_dashboards/manage_dashboards.ts b/public/app/core/components/manage_dashboards/manage_dashboards.ts index 92f01d99716..5c53e2ece4b 100644 --- a/public/app/core/components/manage_dashboards/manage_dashboards.ts +++ b/public/app/core/components/manage_dashboards/manage_dashboards.ts @@ -1,7 +1,7 @@ -import _ from 'lodash'; -import coreModule from 'app/core/core_module'; -import appEvents from 'app/core/app_events'; -import { SearchSrv } from 'app/core/services/search_srv'; +import _ from "lodash"; +import coreModule from "app/core/core_module"; +import appEvents from "app/core/app_events"; +import { SearchSrv } from "app/core/services/search_srv"; export class ManageDashboardsCtrl { public sections: any[]; @@ -13,13 +13,24 @@ export class ManageDashboardsCtrl { canMove = false; hasFilters = false; selectAllChecked = false; - starredFilterOptions = [{ text: 'Filter by Starred', disabled: true }, { text: 'Yes' }, { text: 'No' }]; + starredFilterOptions = [ + { text: "Filter by Starred", disabled: true }, + { text: "Yes" }, + { text: "No" } + ]; selectedStarredFilter: any; folderId?: number; /** @ngInject */ constructor(private backendSrv, navModelSrv, private searchSrv: SearchSrv) { - this.query = { query: '', mode: 'tree', tag: [], starred: false, skipRecent: true, skipStarred: true }; + this.query = { + query: "", + mode: "tree", + tag: [], + starred: false, + skipRecent: true, + skipStarred: true + }; if (this.folderId) { this.query.folderIds = [this.folderId]; @@ -33,7 +44,7 @@ export class ManageDashboardsCtrl { } getDashboards() { - return this.searchSrv.search(this.query).then((result) => { + return this.searchSrv.search(this.query).then(result => { return this.initDashboardList(result); }); } @@ -42,7 +53,10 @@ export class ManageDashboardsCtrl { this.canMove = false; this.canDelete = false; this.selectAllChecked = false; - this.hasFilters = this.query.query.length > 0 || this.query.tag.length > 0 || this.query.starred; + this.hasFilters = + this.query.query.length > 0 || + this.query.tag.length > 0 || + this.query.starred; if (!result) { this.sections = []; @@ -87,7 +101,7 @@ export class ManageDashboardsCtrl { selectedDashboards.folders.push(section.slug); } else { const selected = _.filter(section.items, { checked: true }); - selectedDashboards.dashboards.push(..._.map(selected, 'slug')); + selectedDashboards.dashboards.push(..._.map(selected, "slug")); } } @@ -108,24 +122,30 @@ export class ManageDashboardsCtrl { const data = this.getFoldersAndDashboardsToDelete(); const folderCount = data.folders.length; const dashCount = data.dashboards.length; - let text = 'Do you want to delete the '; + let text = "Do you want to delete the "; let text2; if (folderCount > 0 && dashCount > 0) { - text += `selected folder${folderCount === 1 ? '' : 's'} and dashboard${dashCount === 1 ? '' : 's'}?`; - text2 = `All dashboards of the selected folder${folderCount === 1 ? '' : 's'} will also be deleted`; + text += `selected folder${folderCount === 1 ? "" : "s"} and dashboard${ + dashCount === 1 ? "" : "s" + }?`; + text2 = `All dashboards of the selected folder${ + folderCount === 1 ? "" : "s" + } will also be deleted`; } else if (folderCount > 0) { - text += `selected folder${folderCount === 1 ? '' : 's'} and all its dashboards?`; + text += `selected folder${ + folderCount === 1 ? "" : "s" + } and all its dashboards?`; } else { - text += `selected dashboard${dashCount === 1 ? '' : 's'}?`; + text += `selected dashboard${dashCount === 1 ? "" : "s"}?`; } - appEvents.emit('confirm-modal', { - title: 'Delete', + appEvents.emit("confirm-modal", { + title: "Delete", text: text, text2: text2, - icon: 'fa-trash', - yesText: 'Delete', + icon: "fa-trash", + yesText: "Delete", onConfirm: () => { const foldersAndDashboards = data.folders.concat(data.dashboards); this.deleteFoldersAndDashboards(foldersAndDashboards); @@ -145,28 +165,36 @@ export class ManageDashboardsCtrl { let msg; if (folderCount > 0 && dashCount > 0) { - header = `Folder${folderCount === 1 ? '' : 's'} And Dashboard${dashCount === 1 ? '' : 's'} Deleted`; - msg = `${folderCount} folder${folderCount === 1 ? '' : 's'} `; - msg += `and ${dashCount} dashboard${dashCount === 1 ? '' : 's'} has been deleted`; + header = `Folder${folderCount === 1 ? "" : "s"} And Dashboard${ + dashCount === 1 ? "" : "s" + } Deleted`; + msg = `${folderCount} folder${folderCount === 1 ? "" : "s"} `; + msg += `and ${dashCount} dashboard${ + dashCount === 1 ? "" : "s" + } has been deleted`; } else if (folderCount > 0) { - header = `Folder${folderCount === 1 ? '' : 's'} Deleted`; + header = `Folder${folderCount === 1 ? "" : "s"} Deleted`; if (folderCount === 1) { msg = `${folders[0].dashboard.title} has been deleted`; } else { - msg = `${folderCount} folder${folderCount === 1 ? '' : 's'} has been deleted`; + msg = `${folderCount} folder${ + folderCount === 1 ? "" : "s" + } has been deleted`; } } else if (dashCount > 0) { - header = `Dashboard${dashCount === 1 ? '' : 's'} Deleted`; + header = `Dashboard${dashCount === 1 ? "" : "s"} Deleted`; if (dashCount === 1) { msg = `${dashboards[0].dashboard.title} has been deleted`; } else { - msg = `${dashCount} dashboard${dashCount === 1 ? '' : 's'} has been deleted`; + msg = `${dashCount} dashboard${ + dashCount === 1 ? "" : "s" + } has been deleted`; } } - appEvents.emit('alert-success', [header, msg]); + appEvents.emit("alert-success", [header, msg]); } this.getDashboards(); @@ -178,7 +206,7 @@ export class ManageDashboardsCtrl { for (const section of this.sections) { const selected = _.filter(section.items, { checked: true }); - selectedDashboards.push(..._.map(selected, 'slug')); + selectedDashboards.push(..._.map(selected, "slug")); } return selectedDashboards; @@ -187,19 +215,25 @@ export class ManageDashboardsCtrl { moveTo() { const selectedDashboards = this.getDashboardsToMove(); - const template = '' + - '`'; - appEvents.emit('show-modal', { + "`"; + appEvents.emit("show-modal", { templateHtml: template, - modalClass: 'modal--narrow', - model: { dashboards: selectedDashboards, afterSave: this.getDashboards.bind(this) } + modalClass: "modal--narrow", + model: { + dashboards: selectedDashboards, + afterSave: this.getDashboards.bind(this) + } }); } getTags() { - return this.searchSrv.getDashboardTags().then((results) => { - this.tagFilterOptions = [{ term: 'Filter By Tag', disabled: true }].concat(results); + return this.searchSrv.getDashboardTags().then(results => { + this.tagFilterOptions = [ + { term: "Filter By Tag", disabled: true } + ].concat(results); this.selectedTagFilter = this.tagFilterOptions[0]; }); } @@ -237,7 +271,7 @@ export class ManageDashboardsCtrl { } onStarredFilterChange() { - this.query.starred = this.selectedStarredFilter.text === 'Yes'; + this.query.starred = this.selectedStarredFilter.text === "Yes"; this.selectedStarredFilter = this.starredFilterOptions[0]; return this.getDashboards(); } @@ -248,7 +282,7 @@ export class ManageDashboardsCtrl { section.checked = this.selectAllChecked; } - section.items = _.map(section.items, (item) => { + section.items = _.map(section.items, item => { item.checked = this.selectAllChecked; return item; }); @@ -258,7 +292,7 @@ export class ManageDashboardsCtrl { } clearFilters() { - this.query.query = ''; + this.query.query = ""; this.query.tag = []; this.query.starred = false; this.getDashboards(); @@ -267,15 +301,16 @@ export class ManageDashboardsCtrl { export function manageDashboardsDirective() { return { - restrict: 'E', - templateUrl: 'public/app/core/components/manage_dashboards/manage_dashboards.html', + restrict: "E", + templateUrl: + "public/app/core/components/manage_dashboards/manage_dashboards.html", controller: ManageDashboardsCtrl, bindToController: true, - controllerAs: 'ctrl', + controllerAs: "ctrl", scope: { - folderId: '=' + folderId: "=" } }; } -coreModule.directive('manageDashboards', manageDashboardsDirective); +coreModule.directive("manageDashboards", manageDashboardsDirective); diff --git a/public/app/core/components/navbar/navbar.ts b/public/app/core/components/navbar/navbar.ts index 3fc266dccb3..63534db01eb 100644 --- a/public/app/core/components/navbar/navbar.ts +++ b/public/app/core/components/navbar/navbar.ts @@ -1,6 +1,6 @@ -import coreModule from '../../core_module'; -import {NavModel} from '../../nav_model_srv'; -import appEvents from 'app/core/app_events'; +import coreModule from "../../core_module"; +import { NavModel } from "../../nav_model_srv"; +import appEvents from "app/core/app_events"; export class NavbarCtrl { model: NavModel; @@ -9,7 +9,7 @@ export class NavbarCtrl { constructor() {} showSearch() { - appEvents.emit('show-dash-search'); + appEvents.emit("show-dash-search"); } navItemClicked(navItem, evt) { @@ -22,22 +22,21 @@ export class NavbarCtrl { export function navbarDirective() { return { - restrict: 'E', - templateUrl: 'public/app/core/components/navbar/navbar.html', + restrict: "E", + templateUrl: "public/app/core/components/navbar/navbar.html", controller: NavbarCtrl, bindToController: true, - controllerAs: 'ctrl', + controllerAs: "ctrl", scope: { - model: "=", + model: "=" }, - link: function(scope, elem) { - } + link: function(scope, elem) {} }; } export function pageH1() { return { - restrict: 'E', + restrict: "E", template: `

@@ -46,11 +45,10 @@ export function pageH1() {

`, scope: { - model: "=", + model: "=" } }; } - -coreModule.directive('pageH1', pageH1); -coreModule.directive('navbar', navbarDirective); +coreModule.directive("pageH1", pageH1); +coreModule.directive("navbar", navbarDirective); diff --git a/public/app/core/components/org_switcher.ts b/public/app/core/components/org_switcher.ts index 68e91bb8dcb..f3792f48c73 100644 --- a/public/app/core/components/org_switcher.ts +++ b/public/app/core/components/org_switcher.ts @@ -1,7 +1,7 @@ /// -import coreModule from 'app/core/core_module'; -import {contextSrv} from 'app/core/services/context_srv'; +import coreModule from "app/core/core_module"; +import { contextSrv } from "app/core/services/context_srv"; const template = `