frontend/js/common/component/script/call_service.js
Paulus Schoutsen faf576d43d Add script editor (#393)
* Add script editor

* Cleanup
2017-08-15 22:09:43 -07:00

53 lines
1.1 KiB
JavaScript

import { h, Component } from 'preact';
import JSONTextArea from '../json_textarea';
import { onChangeEvent } from '../../util/event';
export default class CallServiceAction extends Component {
constructor() {
super();
this.onChange = onChangeEvent.bind(this, 'action');
this.serviceDataChanged = this.serviceDataChanged.bind(this);
}
serviceDataChanged(data) {
this.props.onChange(this.props.index, {
...this.props.action,
data,
});
}
render({ action }) {
const { alias, service, data } = action;
return (
<div>
<paper-input
label="Alias"
name="alias"
value={alias}
onChange={this.onChange}
/>
<paper-input
label="Service"
name="service"
value={service}
onChange={this.onChange}
/>
<JSONTextArea
label="Service Data"
value={data}
onChange={this.serviceDataChanged}
/>
</div>
);
}
}
CallServiceAction.configKey = 'service';
CallServiceAction.defaultConfig = {
alias: '',
service: '',
data: {}
};