Skip to content

Commit

Permalink
migrate to ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
jaumard committed Oct 16, 2021
1 parent 940ecf7 commit 20098fc
Show file tree
Hide file tree
Showing 10 changed files with 585 additions and 2,097 deletions.
Binary file removed assets/images/camera_ip.png
Binary file not shown.
1 change: 1 addition & 0 deletions assets/images/webcam.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 14 additions & 9 deletions config/devices.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import {createRequire} from 'module';

const require = createRequire(import.meta.url);
const template = require('../widgets/cam.json')

module.exports = [
export default [
{
image: 'camera_ip.png',
name: {
en: 'IP Camera MJPG',
fr: 'Caméra IP MJPG'
fr: 'Caméra IP MJPG',
},
description: {
en: 'Add an IP Camera with MJPG stream',
fr: 'Ajout d\'une caméra IP avec un flux MJPG'
fr: 'Ajout d\'une caméra IP avec un flux MJPG',
},
driver: 'cam',
type: 'camera',
type: 'webcam',
pairing: 'settings',
image: 'webcam.svg',
template: template,
imageOn: 'webcam.svg',
imageOff: 'webcam.svg',
settings: {
'type': 'column',
'crossAxisAlignment': 3,
Expand All @@ -28,15 +33,15 @@ module.exports = [
'textInputAction': 6,
'decoration': {
'labelText': 'Url*',
}
},
},
{
'type': 'text_field',
'id': 'login',
'textInputAction': 6,
'decoration': {
'labelText': 'Login',
}
},
},
{
'type': 'text_field',
Expand All @@ -45,9 +50,9 @@ module.exports = [
'textInputAction': 2,
'decoration': {
'labelText': 'Password',
}
},
},
],
},
}
},
]
9 changes: 7 additions & 2 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
exports.devices = require('./devices')
exports.infos = require('./infos')
import devices from './devices.js';
import infos from './infos.js';

export default {
'devices': devices,
'infos': infos,
};
8 changes: 4 additions & 4 deletions config/infos.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module.exports = {
export default {
name: {
en: 'IP Camera MJPG',
fr: 'Caméra IP MJPG'
fr: 'Caméra IP MJPG',
},
description: {
en: 'Add an IP Camera with MJPG stream',
fr: 'Ajout d\'une caméra IP avec un flux MJPG'
fr: 'Ajout d\'une caméra IP avec un flux MJPG',
},
image: 'camera_ip.png'
image: 'camera_ip.png',
}
6 changes: 2 additions & 4 deletions drivers/cam.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'
import {Driver} from 'lisa-plugin'

const Driver = require('lisa-plugin').Driver

module.exports = class CamDriver extends Driver {
export default class CamDriver extends Driver {

}
6 changes: 5 additions & 1 deletion drivers/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
exports.cam = require('./cam')
import cam from './cam.js'

export default {
'cam': cam
}
19 changes: 11 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict'
import {Plugin} from 'lisa-plugin'
import {createRequire} from 'module';
import config from './config/index.js'
import drivers from './drivers/index.js'

const Plugin = require('lisa-plugin')

module.exports = class MjpegCamPlugin extends Plugin {
const require = createRequire(import.meta.url);
const pkg = require('./package.json');

export default class MjpegCamPlugin extends Plugin {
/**
* Initialisation of your plugin
* Called once, when plugin is loaded
* @returns Promise
* @return Promise
*/
init() {
return super.init()
Expand All @@ -25,9 +28,9 @@ module.exports = class MjpegCamPlugin extends Plugin {

constructor(app) {
super(app, {
drivers: require('./drivers'),
config: require('./config'),
pkg: require('./package')
drivers: drivers,
config: config,
pkg: pkg,
})
}
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"type": "module",
"name": "lisa-plugin-cam-mjpeg",
"main": "index.js",
"version": "0.0.1",
"scripts": {
"test": "eslint . && mocha"
},
"eslintConfig": {
"extends": "trails"
"extends": "google"
},
"dependencies": {
"lisa-plugin": "^0.0.15"
"lisa-plugin": "^0.1.2"
},
"devDependencies": {
"eslint": "^6.4.0",
"eslint-config-trails": "^3.1.0",
"mocha": "^6.2.0"
"eslint": "^7.32.0",
"eslint-config-google": "^0.14.0",
"mocha": "^9.1.1"
}
}
Loading

0 comments on commit 20098fc

Please sign in to comment.