ice-frontend-react-mobx
Version:
ICE Frontend REACT+MobX
47 lines (40 loc) • 1.15 kB
JavaScript
import { observable, computed } from 'mobx';
export default class CatalogDevice {
_model = null;
manufacturer = null;
name = null;
type = null;
model = null;
maxPowerW = null;
batteryCapacityWh = 0;
isDumb = false;
store = null;
constructor (store) {
this.store = store;
}
get id () {
return this._model;
}
get toJson () {
return {
model: this._model,
manufacturer: this.manufacturer,
completeName: this.name,
deviceType: this.type,
deviceModel: this.model,
maxPowerW: this.maxPowerW,
batteryCapacityWh: this.batteryCapacityWh,
isDumb: this.isDumb
};
}
updateFromJson (json) {
this._model = json.model;
this.manufacturer = json.manufacturer;
this.name = json.completeName;
this.type = (json.deviceType === 'iceSwitch') ? 'iceswitch' : json.deviceType;
this.model = json.deviceModel;
this.maxPowerW = json.maxPowerW;
this.batteryCapacityWh = json.batteryCapacityWh;
this.isDumb = json.isDumb;
}
}