Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderEnum(obj) {
let smartName = Utils.getSmartNameFromObj(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
// convert old format
if (smartName && typeof smartName === 'object') {
smartName = smartName[I18n.getLanguage()] || smartName.en || '';
}
let name = Utils.getObjectNameFromObj(obj);
return (<div style="{{background:">
<span style="{{opacity:">{smartName || null}{smartName ? (<span> ({name})</span>) : name}</span>
<span style="{{opacity:">{obj._id}</span>
</div>);
}
onEdit(id) {
const obj = this.state.funcs.find(e => e._id === id) || this.state.rooms.find(e => e._id === id);
let smartName = Utils.getSmartNameFromObj(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
if (typeof smartName === 'object' && smartName) {
smartName = smartName[I18n.getLanguage()] || smartName.en;
}
smartName = smartName || Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()});
this.setState({editId: id, editedSmartName: smartName});
}
renderEditDialog() {
if (this.state.editId) {
const obj = this.state.funcs.find(e => e._id === this.state.editId) || this.state.rooms.find(e => e._id === this.state.editId);
return (<dialog open="{true}"> this.handleOk()}
aria-labelledby="message-dialog-title"
aria-describedby="message-dialog-description"
>
{this.props.title || I18n.t('Smart name for %s', Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()}))}
this.setState({editedSmartName: e.target.value})}
value={this.state.editedSmartName}
helperText={I18n.t('You can enter several names divided by comma')}
margin="normal"
/>
<button> this.changeSmartName()} color="primary" autoFocus>{I18n.t('Ok')}</button>
<button> this.setState({editId: ''})}>{I18n.t('Cancel')}</button>
</dialog>)
} else {
.then(obj => {
if (obj) {
const name = Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()});
Utils.updateSmartName(obj, (name || I18n.t('Device name')).replace(/[-_.]+/g, ' '), undefined, undefined, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
this.addChanged(obj._id);
this.waitForUpdateID = obj._id;
if (this.state.lastChanged !== obj._id) {
this.setState({lastChanged: obj._id});
this.timerChanged && clearTimeout(this.timerChanged);
this.timerChanged = setTimeout(() => {
this.setState({lastChanged: ''});
this.timerChanged = null;
}, 30000);
}
this.props.socket.setObject(obj._id, obj)
.then(() => this.informInstance(obj._id))
.catch(err => this.setState({message: err}));
if (enums.find(obj =>
this.state.editId !== obj._id && (
this.state.editedSmartName === Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()}) ||
this.state.editedSmartName === Utils.getSmartNameFromObj(obj, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon)))) {
this.setState({message: I18n.t('Duplicate name')});
.then(obj => {
let smartName = device.additionalApplianceDetails.friendlyNames ? device.additionalApplianceDetails.friendlyNames : device.friendlyName;
if (typeof smartName === 'object' && smartName) {
smartName = smartName[I18n.getLanguage()] || smartName.en;
}
this.editedSmartName = smartName;
let editedSmartType = null;
if (!device.additionalApplianceDetails.group) {
editedSmartType = device.additionalApplianceDetails.smartType;
}
this.setState({editId: id, editedSmartType, editedSmartName: smartName, editObjectName: Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()})});
});
return true;
.then(obj => {
if (obj) {
const name = Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()});
Utils.updateSmartName(obj, (name || I18n.t('Device name')).replace(/[-_.]+/g, ' '), undefined, undefined, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
this.addChanged(obj._id);
this.waitForUpdateID = obj._id;
if (this.state.lastChanged !== obj._id) {
this.setState({lastChanged: obj._id});
this.timerChanged && clearTimeout(this.timerChanged);
this.timerChanged = setTimeout(() => {
this.setState({lastChanged: ''});
this.timerChanged = null;
}, 30000);
}
this.props.socket.setObject(obj._id, obj)
.then(() => this.informInstance(obj._id))
.catch(err => this.setState({message: err}));
.then(obj => {
let smartName = device.common.smartName ? device.common.smartName : device._id;
if (typeof smartName === 'object' && smartName) {
smartName = smartName[I18n.getLanguage()] || smartName.en;
}
this.editedSmartName = smartName;
this.setState({editId: id, editedSmartName: smartName, editObjectName: Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()})});
});
return true;
.then(obj => {
if (obj) {
const name = Utils.getObjectNameFromObj(obj, null, {language: I18n.getLanguage()});
Utils.updateSmartName(obj, (name || I18n.t('Device name')).replace(/[-_.]+/g, ' '), undefined, undefined, this.props.adapterName + '.' + this.props.instance, this.props.native.noCommon);
this.addChanged(obj._id);
this.waitForUpdateID = obj._id;
if (this.state.lastChanged !== obj._id) {
this.setState({lastChanged: obj._id});
this.timerChanged && clearTimeout(this.timerChanged);
this.timerChanged = setTimeout(() => {
this.setState({lastChanged: ''});
this.timerChanged = null;
}, 30000);
}
obj.common.smartName.ghType="action.devices.types.LIGHT"
this.props.socket.setObject(obj._id, obj)
.then(() => {
this.informInstance(obj._id);