Browse Source

Up device manager constructor

pull/4695/head
Artur Arseniev 4 years ago
parent
commit
c916997129
  1. 4
      src/device_manager/config/config.ts
  2. 8
      src/device_manager/index.ts
  3. 2
      src/device_manager/view/DevicesView.ts

4
src/device_manager/config/config.ts

@ -1,3 +1,5 @@
import { DeviceProperties } from '../model/Device';
export interface DeviceManagerConfig {
/**
* The device `id` to select on start, if not indicated, the first available from `devices` will be used.
@ -20,7 +22,7 @@ export interface DeviceManagerConfig {
* ...
* ]
*/
devices?: Array<object>; // TODO
devices?: DeviceProperties[];
}
const config: DeviceManagerConfig = {

8
src/device_manager/index.ts

@ -76,15 +76,9 @@ export default class DeviceManager extends ItemManagerModule<
constructor(em: EditorModel) {
super(em, 'DeviceManager', new Devices(em.config.deviceManager?.devices || []), events, defaults);
// this.c = { ...defaults, ...config };
// const { em } = this.c;
this.devices = this.all;
// this.c.devices.forEach(dv => this.add(dv));
// this.em = em;
// this.all = this.devices;
this.config.devices?.forEach(device => this.add(device, { silent: true }));
this.select(this.config.default || this.devices.at(0));
// this.__initListen();
em.on(chnSel, this._onSelect, this);
return this;
}

2
src/device_manager/view/DevicesView.ts

@ -86,7 +86,7 @@ export default class DevicesView extends View {
const { collection, em } = this;
let result = '';
collection.each(device => {
collection.forEach(device => {
const { name, id } = device.attributes;
const label = (em && em.t && em.t(`deviceManager.devices.${id}`)) || name;
result += `<option value="${id || name}">${label}</option>`;

Loading…
Cancel
Save