From 288eede638aa4994399e23e0dad9e29ce1ffaf04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 8 Jun 2022 10:34:58 +0200 Subject: [PATCH] Angular: Adds back two angular directives that are still used by remaining angular bits and plugins (#50380) --- public/app/angular/bsTooltip.ts | 59 +++++ public/app/angular/bsTypeahead.ts | 63 +++++ public/app/angular/index.ts | 2 + .../datasource/mssql/partials/config.html | 224 +++++++++--------- 4 files changed, 237 insertions(+), 111 deletions(-) create mode 100644 public/app/angular/bsTooltip.ts create mode 100644 public/app/angular/bsTypeahead.ts diff --git a/public/app/angular/bsTooltip.ts b/public/app/angular/bsTooltip.ts new file mode 100644 index 00000000000..38bb09b769c --- /dev/null +++ b/public/app/angular/bsTooltip.ts @@ -0,0 +1,59 @@ +import angular from 'angular'; +import $ from 'jquery'; + +import coreModule from './core_module'; + +coreModule.directive('bsTooltip', [ + '$parse', + '$compile', + function ($parse: any, $compile: any) { + return { + restrict: 'A', + scope: true, + link: function postLink(scope: any, element: any, attrs: any) { + var getter = $parse(attrs.bsTooltip), + value = getter(scope); + scope.$watch(attrs.bsTooltip, function (newValue: any, oldValue: any) { + if (newValue !== oldValue) { + value = newValue; + } + }); + // Grafana change, always hide other tooltips + if (true) { + element.on('show', function (ev: any) { + $('.tooltip.in').each(function () { + var $this = $(this), + tooltip = $this.data('tooltip'); + if (tooltip && !tooltip.$element.is(element)) { + $this.tooltip('hide'); + } + }); + }); + } + element.tooltip({ + title: function () { + return angular.isFunction(value) ? value.apply(null, arguments) : value; + }, + html: true, + container: 'body', // Grafana change + }); + var tooltip = element.data('tooltip'); + tooltip.show = function () { + var r = $.fn.tooltip.Constructor.prototype.show.apply(this, arguments); + this.tip().data('tooltip', this); + return r; + }; + scope._tooltip = function (event: any) { + element.tooltip(event); + }; + scope.hide = function () { + element.tooltip('hide'); + }; + scope.show = function () { + element.tooltip('show'); + }; + scope.dismiss = scope.hide; + }, + }; + }, +]); diff --git a/public/app/angular/bsTypeahead.ts b/public/app/angular/bsTypeahead.ts new file mode 100644 index 00000000000..515f82994ba --- /dev/null +++ b/public/app/angular/bsTypeahead.ts @@ -0,0 +1,63 @@ +import angular from 'angular'; +import $ from 'jquery'; +import { isFunction } from 'lodash'; + +import coreModule from './core_module'; + +coreModule.directive('bsTypeahead', [ + '$parse', + function ($parse: any) { + return { + restrict: 'A', + require: '?ngModel', + link: function postLink(scope: any, element: any, attrs: any, controller: any) { + var getter = $parse(attrs.bsTypeahead), + value = getter(scope); + scope.$watch(attrs.bsTypeahead, function (newValue: any, oldValue: any) { + if (newValue !== oldValue) { + value = newValue; + } + }); + element.attr('data-provide', 'typeahead'); + element.typeahead({ + source: function () { + return angular.isFunction(value) ? value.apply(null, arguments) : value; + }, + minLength: attrs.minLength || 1, + items: attrs.item, + updater: function (value: any) { + if (controller) { + scope.$apply(function () { + controller.$setViewValue(value); + }); + } + scope.$emit('typeahead-updated', value); + return value; + }, + }); + var typeahead = element.dat('typeahead'); + typeahead.lookup = function (ev: any) { + var items; + this.query = this.$element.val() || ''; + if (this.query.length < this.options.minLength) { + return this.shown ? this.hide() : this; + } + items = isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source; + return items ? this.process(items) : this; + }; + if (!!attrs.matchAll) { + typeahead.matcher = function () { + return true; + }; + } + if (attrs.minLength === '0') { + setTimeout(function () { + element.on('focus', function () { + element.val().length === 0 && setTimeout(element.typeahead.bind(element, 'lookup'), 200); + }); + }); + } + }, + }; + }, +]); diff --git a/public/app/angular/index.ts b/public/app/angular/index.ts index ada6fe8f6a5..3fbf6ae93f2 100644 --- a/public/app/angular/index.ts +++ b/public/app/angular/index.ts @@ -14,6 +14,8 @@ import './dropdown_typeahead'; import './autofill_event_fix'; import './metric_segment'; import './misc'; +import './bsTooltip'; +import './bsTypeahead'; import './ng_model_on_blur'; import './tags'; import './rebuild_on_change'; diff --git a/public/app/plugins/datasource/mssql/partials/config.html b/public/app/plugins/datasource/mssql/partials/config.html index 6d3cb01e3d5..680ba4dd75b 100644 --- a/public/app/plugins/datasource/mssql/partials/config.html +++ b/public/app/plugins/datasource/mssql/partials/config.html @@ -1,46 +1,45 @@ -

MS SQL connection

-
- Host - -
+
+ Host + +
-
- Database - -
+
+ Database + +
-
- -
- - -
    -
  • SQL Server Authentication This is the default mechanism to connect to MS SQL Server. Enter the SQL Server Authentication login or the Windows Authentication login in the DOMAIN\User format.
  • -
  • Windows Authentication Windows Integrated Security - single sign on for users who are already logged onto Windows and have enabled this option for MS SQL Server.
  • -
-
-
-
-
-
- User - -
-
- -
-
+
+ +
+ + +
    +
  • SQL Server Authentication This is the default mechanism to connect to MS SQL Server. Enter the SQL + Server Authentication login or the Windows Authentication login in the DOMAIN\User format.
  • +
  • Windows Authentication Windows Integrated Security - single sign on for users who are already + logged onto Windows and have enabled this option for MS SQL Server.
  • +
+
+
+
+
+
+ User + +
+
+ +
+
@@ -48,33 +47,37 @@
-
- -
- - - Determines whether or to which extent a secure SSL TCP/IP connection will be negotiated with the server. -
    -
  • disable - Data sent between client and server is not encrypted.
  • -
  • false - Data sent between client and server is not encrypted beyond the login packet. (default)
  • -
  • true - Data sent between client and server is encrypted.
  • -
- If you're using an older version of Microsoft SQL Server like 2008 and 2008R2 you may need to disable encryption to be able to connect. -
-
-
+
+ +
+ + + Determines whether or to which extent a secure SSL TCP/IP connection will be negotiated with the server. +
    +
  • disable - Data sent between client and server is not encrypted.
  • +
  • false - Data sent between client and server is not encrypted beyond the login packet. (default) +
  • +
  • true - Data sent between client and server is encrypted.
  • +
+ If you're using an older version of Microsoft SQL Server like 2008 and 2008R2 you may need to disable encryption + to be able to connect. +
+
+
+ tooltip="Skip verifying Server Certificate for TLS/SSL. If this is enabled, any certificate presented by the server and any host name in that certificate will be accepted. In this mode, TLS is susceptible to man-in-the-middle attacks. This should be used only for testing." + checked="ctrl.current.jsonData.tlsSkipVerify" switch-class="max-width-8" on-change="ctrl.onEncryptChange()"> +
TLS/SSL Root Certificate + placeholder="TLS/SSL root certificate file"> Path to file containing the public key certificate of the CA that signed the SQL Server certificate. Needed when the server certificate is self signed. @@ -84,7 +87,7 @@
Hostname in server certificate + placeholder="Common Name (CN) in server certificate"> Specifies the Common Name (CN) in the server certificate. Default is the server host. @@ -95,65 +98,64 @@

Connection limits

-
- Max open - - - The maximum number of open connections to the database. If Max idle connections is greater than 0 and the - Max open connections is less than Max idle connections, then Max idle connections will be - reduced to match the Max open connections limit. If set to 0, there is no limit on the number of open - connections. - -
-
- Max idle - - - The maximum number of connections in the idle connection pool. If Max open connections is greater than 0 but - less than the Max idle connections, then the Max idle connections will be reduced to match the - Max open connections limit. If set to 0, no idle connections are retained. - -
-
- Max lifetime - - - The maximum amount of time in seconds a connection may be reused. If set to 0, connections are reused forever. - -
+
+ Max open + + + The maximum number of open connections to the database. If Max idle connections is greater than 0 and the + Max open connections is less than Max idle connections, then Max idle connections will be + reduced to match the Max open connections limit. If set to 0, there is no limit on the number of open + connections. + +
+
+ Max idle + + + The maximum number of connections in the idle connection pool. If Max open connections is greater than 0 + but + less than the Max idle connections, then the Max idle connections will be reduced to match the + Max open connections limit. If set to 0, no idle connections are retained. + +
+
+ Max lifetime + + + The maximum amount of time in seconds a connection may be reused. If set to 0, connections are reused forever. + +

MS SQL details

-
-
- Min time interval - - - A lower limit for the auto group by time interval. Recommended to be set to write frequency, - for example 1m if your data is written every minute. - -
-
+
+
+ Min time interval + + + A lower limit for the auto group by time interval. Recommended to be set to write frequency, + for example 1m if your data is written every minute. + +
+
-
-
User Permission
-

- The database user should only be granted SELECT permissions on the specified database and tables you want to query. - Grafana does not validate that queries are safe so queries can contain any SQL statement. For example, statements - like USE otherdb; and DROP TABLE user; would be executed. To protect against this we - highly recommmend you create a specific MS SQL user with restricted permissions. -

-
+
+
User Permission
+

+ The database user should only be granted SELECT permissions on the specified database and tables you want to + query. + Grafana does not validate that queries are safe so queries can contain any SQL statement. For example, statements + like USE otherdb; and DROP TABLE user; would be executed. To protect against this we + highly recommmend you create a specific MS SQL user with restricted permissions. +

+
-