Forráskód Böngészése

Issue 4577 (#5379)

* Add default-url property for datasource-http-settings directive.
This will allow to set default url for datasource.

* Fixed spelling.

* Use typeahead for url suggestion.
Alexander Zobnin 9 éve
szülő
commit
fdf46c6a10

+ 14 - 2
public/app/features/plugins/ds_edit_ctrl.ts

@@ -166,7 +166,19 @@ coreModule.controller('DataSourceEditCtrl', DataSourceEditCtrl);
 
 coreModule.directive('datasourceHttpSettings', function() {
   return {
-    scope: {current: "="},
-    templateUrl: 'public/app/features/plugins/partials/ds_http_settings.html'
+    scope: {
+      current: "=",
+      defaultUrl: "="
+    },
+    templateUrl: 'public/app/features/plugins/partials/ds_http_settings.html',
+    link: {
+      pre: function($scope, elem, attrs) {
+        $scope.suggestDefaultUrl = function() {
+          return [
+            $scope.defaultUrl
+          ];
+        };
+      }
+    }
   };
 });

+ 2 - 2
public/app/features/plugins/partials/ds_http_settings.html

@@ -6,7 +6,7 @@
 	<div class="gf-form-inline">
 		<div class="gf-form max-width-30">
 			<span class="gf-form-label width-7">Url</span>
-			<input class="gf-form-input" type="text" ng-model='current.url' placeholder="for example: http://localhost:8081" ng-pattern="/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/" required></input>
+			<input class="gf-form-input" type="text" ng-model='current.url' placeholder="for example: http://localhost:8081" bs-typeahead="suggestDefaultUrl" ng-pattern="/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/" required></input>
 			<info-popover mode="right-absolute">
 				<p>Specify a complete HTTP url (for example http://your_server:8080)</p>
 				<span ng-show="current.access === 'direct'">
@@ -57,7 +57,7 @@
 
 	<div class="gf-form" ng-if="current.basicAuth">
 		<span class="gf-form-label width-7">
-			Passord
+			Password
 		</span>
 		<input class="gf-form-input max-width-21" type="password" ng-model='current.basicAuthPassword' placeholder="password" required></input>
 	</div>

+ 1 - 1
public/app/plugins/datasource/graphite/partials/config.html

@@ -1,3 +1,3 @@
-<datasource-http-settings current="ctrl.current">
+<datasource-http-settings current="ctrl.current" default-url="'http://localhost:8081'">
 </datasource-http-settings>