+50
@@ -0,0 +1,50 @@
|
||||
System.register([], function (_export) {
|
||||
"use strict";
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
|
||||
function Datasource(instanceSettings, backendSrv) {
|
||||
this.url = instanceSettings.url;
|
||||
|
||||
// this.testDatasource = function() {
|
||||
// return backendSrv.datasourceRequest({
|
||||
// method: 'GET',
|
||||
// url: this.url + '/api/v4/search'
|
||||
// });
|
||||
// }
|
||||
//
|
||||
this.testDatasource = function() {
|
||||
return backendSrv.datasourceRequest({
|
||||
method: 'GET',
|
||||
url: this.url + '/tokenTest'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ConfigCtrl() {
|
||||
|
||||
}
|
||||
|
||||
ConfigCtrl.template = `
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-13">TenantId </label>
|
||||
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.jsonData.tenantId'></input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-13">ClientId </label>
|
||||
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.jsonData.clientId'></input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-13">Client secret</label>
|
||||
<input type="text" class="gf-form-input max-width-18" ng-model='ctrl.current.secureJsonData.clientSecret'></input>
|
||||
</div>
|
||||
`;
|
||||
|
||||
_export('Datasource', Datasource);
|
||||
_export('ConfigCtrl', ConfigCtrl);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "Test Datasource",
|
||||
"id": "test-ds",
|
||||
|
||||
"routes": [
|
||||
{
|
||||
"path": "tokenTest",
|
||||
"method": "*",
|
||||
"url": "https://management.azure.com",
|
||||
"tokenAuth": {
|
||||
"url": "https://login.microsoftonline.com/{{.JsonData.tenantId}}/oauth2/token",
|
||||
"params": {
|
||||
"grant_type": "client_credentials",
|
||||
"client_id": "{{.JsonData.clientId}}",
|
||||
"client_secret": "{{.SecureJsonData.clientSecret}}",
|
||||
"resource": "https://management.azure.com/"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "api/v4/",
|
||||
"method": "*",
|
||||
"url": "http://localhost:3333",
|
||||
"headers": [
|
||||
{"name": "X-CH-Auth-API-Token", "content": "test {{.SecureJsonData.token}}"},
|
||||
{"name": "X-CH-Auth-Email", "content": "test {{.JsonData.email}}"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user