Changed testDatasource() method for new api.
This commit is contained in:
@@ -4,6 +4,7 @@ define([
|
|||||||
'app/core/utils/datemath',
|
'app/core/utils/datemath',
|
||||||
'./directives',
|
'./directives',
|
||||||
'./zabbixAPIWrapper',
|
'./zabbixAPIWrapper',
|
||||||
|
'./zabbixAPIService',
|
||||||
'./utils',
|
'./utils',
|
||||||
'./helperFunctions',
|
'./helperFunctions',
|
||||||
'./zabbixCacheSrv',
|
'./zabbixCacheSrv',
|
||||||
@@ -13,7 +14,8 @@ function (angular, _, dateMath) {
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
function ZabbixAPIDatasource(instanceSettings, $q, backendSrv, templateSrv, alertSrv, ZabbixAPI, Utils, zabbixHelperSrv, ZabbixCache) {
|
function ZabbixAPIDatasource(instanceSettings, $q, backendSrv, templateSrv, alertSrv,
|
||||||
|
ZabbixAPI, Utils, zabbixHelperSrv, ZabbixCache, ZabbixAPIService) {
|
||||||
|
|
||||||
// General data source settings
|
// General data source settings
|
||||||
this.name = instanceSettings.name;
|
this.name = instanceSettings.name;
|
||||||
@@ -43,27 +45,36 @@ function (angular, _, dateMath) {
|
|||||||
*/
|
*/
|
||||||
this.testDatasource = function() {
|
this.testDatasource = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
return this.zabbixAPI.getZabbixAPIVersion().then(function (apiVersion) {
|
return this.zabbixAPI.getVersion().then(function (version) {
|
||||||
return self.zabbixAPI.performZabbixAPILogin().then(function (auth) {
|
return self.zabbixAPI.login().then(function (auth) {
|
||||||
if (auth) {
|
if (auth) {
|
||||||
return {
|
return {
|
||||||
status: "success",
|
status: "success",
|
||||||
title: "Success",
|
title: "Success",
|
||||||
message: "Zabbix API version: " + apiVersion
|
message: "Zabbix API version: " + version
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "Invalid user name or password",
|
title: "Invalid user name or password",
|
||||||
message: "Zabbix API version: " + apiVersion
|
message: "Zabbix API version: " + version
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}, function(error) {
|
||||||
|
console.log(error);
|
||||||
|
return {
|
||||||
|
status: "error",
|
||||||
|
title: "Connection failed",
|
||||||
|
message: error
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}, function(error) {
|
},
|
||||||
|
function(error) {
|
||||||
|
console.log(error);
|
||||||
return {
|
return {
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "Connection failed",
|
title: "Connection failed",
|
||||||
message: "Could not connect to " + error.config.url
|
message: "Could not connect to given url"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user