mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
listen for changes in angular land and propagate that back to react
This commit is contained in:
parent
2342f60a31
commit
7885453bcd
@ -1,3 +1,4 @@
|
||||
import _ from 'lodash';
|
||||
import React, { PureComponent } from 'react';
|
||||
import { DataSource, Plugin } from 'app/types/';
|
||||
import { getAngularLoader, AngularComponent } from 'app/core/services/AngularLoader';
|
||||
@ -23,13 +24,24 @@ export class PluginSettings extends PureComponent<Props> {
|
||||
const scopeProps = {
|
||||
ctrl: {
|
||||
datasourceMeta: dataSourceMeta,
|
||||
current: dataSource,
|
||||
current: _.cloneDeep(dataSource),
|
||||
},
|
||||
onModelChanged: this.onModelChanged,
|
||||
};
|
||||
|
||||
this.component = loader.load(this.element, scopeProps, template);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.component) {
|
||||
this.component.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
onModelChanged(dataSource: DataSource) {
|
||||
console.log(dataSource);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div ref={element => (this.element = element)} />;
|
||||
}
|
||||
|
@ -149,6 +149,14 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
|
||||
return { notFound: true };
|
||||
}
|
||||
|
||||
scope.$watch(
|
||||
'ctrl.current',
|
||||
() => {
|
||||
scope.onModelChanged(scope.ctrl.current);
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
return {
|
||||
baseUrl: dsMeta.baseUrl,
|
||||
name: 'ds-config-' + dsMeta.id,
|
||||
|
Loading…
Reference in New Issue
Block a user