@ -161,7 +161,6 @@ class GraphCtrl extends MetricsPanelCtrl {
// because of https://github.com/hastic/hastic-grafana-app/issues/162
// because of https://github.com/hastic/hastic-grafana-app/issues/162
this . events . on ( 'init-edit-mode' , this . onInitEditMode . bind ( this ) ) ;
this . events . on ( 'init-edit-mode' , this . onInitEditMode . bind ( this ) ) ;
const grafanaUrlRegex = /^(.+)\/d/ ;
const grafanaUrlRegex = /^(.+)\/d/ ;
const parsedUrl = window . location . href . match ( grafanaUrlRegex ) ;
const parsedUrl = window . location . href . match ( grafanaUrlRegex ) ;
if ( parsedUrl !== null ) {
if ( parsedUrl !== null ) {
@ -171,6 +170,7 @@ class GraphCtrl extends MetricsPanelCtrl {
}
}
this . _panelId = ` ${ this . dashboard . uid } / ${ this . panel . id } ` ;
this . _panelId = ` ${ this . dashboard . uid } / ${ this . panel . id } ` ;
this . _datasources = { } ;
}
}
rebindKeys() {
rebindKeys() {
@ -201,6 +201,9 @@ class GraphCtrl extends MetricsPanelCtrl {
const hasticDatasourceId = this . panel . hasticDatasource ;
const hasticDatasourceId = this . panel . hasticDatasource ;
if ( hasticDatasourceId !== undefined && hasticDatasourceId !== null ) {
if ( hasticDatasourceId !== undefined && hasticDatasourceId !== null ) {
const hasticDatasource = _ . find ( this . _hasticDatasources , { id : hasticDatasourceId } ) ;
const hasticDatasource = _ . find ( this . _hasticDatasources , { id : hasticDatasourceId } ) ;
if ( hasticDatasource === undefined ) {
return undefined ;
}
let url = hasticDatasource . url ;
let url = hasticDatasource . url ;
if ( hasticDatasource . access === 'proxy' ) {
if ( hasticDatasource . access === 'proxy' ) {
url = ` api/datasources/proxy/ ${ hasticDatasource . id } ` ;
url = ` api/datasources/proxy/ ${ hasticDatasource . id } ` ;
@ -247,8 +250,6 @@ class GraphCtrl extends MetricsPanelCtrl {
}
}
async link ( scope , elem , attrs , ctrl ) {
async link ( scope , elem , attrs , ctrl ) {
this . _datasources = { } ;
this . $graphElem = $ ( elem [ 0 ] ) . find ( '#graphPanel' ) ;
this . $graphElem = $ ( elem [ 0 ] ) . find ( '#graphPanel' ) ;
this . $legendElem = $ ( elem [ 0 ] ) . find ( '#graphLegend' ) ;
this . $legendElem = $ ( elem [ 0 ] ) . find ( '#graphLegend' ) ;
@ -314,7 +315,7 @@ class GraphCtrl extends MetricsPanelCtrl {
this . processor = new DataProcessor ( this . panel ) ;
this . processor = new DataProcessor ( this . panel ) ;
await this . _fetchHasticDatasources ( ) ;
await this . _fetchHasticDatasources ( ) ;
le t hasticDatasource = this . hasticDatasource ;
cons t hasticDatasource = this . getHasticDatasource ( ) ;
if ( hasticDatasource === undefined ) {
if ( hasticDatasource === undefined ) {
delete this . analyticService ;
delete this . analyticService ;
} else {
} else {
@ -638,7 +639,7 @@ class GraphCtrl extends MetricsPanelCtrl {
this . refresh ( ) ;
this . refresh ( ) ;
const datasource = await this . _getDatasourceRequest ( ) ;
const datasource = await this . _getDatasourceRequest ( ) ;
const metric = new MetricExpanded ( this . panel . datasource , this . panel . targets ) ;
const metric = new MetricExpanded ( this . panel . datasource , this . panel . targets ) ;
await this . analyticsController . toggleUnitType LabelingMode ( id , metric , datasource ) ;
await this . analyticsController . toggleAnalytic UnitLabelingMode ( id , metric , datasource ) ;
this . $scope . $digest ( ) ;
this . $scope . $digest ( ) ;
this . render ( ) ;
this . render ( ) ;
}
}
@ -681,7 +682,7 @@ class GraphCtrl extends MetricsPanelCtrl {
grafanaUrl : window.location.host ,
grafanaUrl : window.location.host ,
datasourceName : datasource === undefined ? 'unknown' : datasource . name ,
datasourceName : datasource === undefined ? 'unknown' : datasource . name ,
datasourceType : datasource === undefined ? 'unknown' : datasource . type ,
datasourceType : datasource === undefined ? 'unknown' : datasource . type ,
hasticDatasourceName : datasource === undefined ? 'unknown' : hasticDatasource . name ,
hasticDatasourceName : hasticDatasource === undefined || datasource === undefined ? 'unknown' : hasticDatasource . name ,
hasticDatasourceUrl : hasticDatasource === undefined ? 'unknown' : hasticDatasource . url
hasticDatasourceUrl : hasticDatasource === undefined ? 'unknown' : hasticDatasource . url
} ;
} ;
}
}