OpenROV /
openrov-cockpit
| 1 | var PREFERENCES = 'plugins:software-update'; |
||
| 2 | function softwareUpdate(name, deps) { |
||
| 3 | deps.logger.debug('Software update plugin started.'); |
||
| 4 | var preferences = getPreferences(deps.config); |
||
| 5 | showSerialScript = __dirname + '/scripts/' + (process.env.USE_MOCK === 'true' ? 'mock-' : '') + 'showserial.sh'; |
||
| 6 | deps.app.get('system-plugin/software-update/config', function (req, res) { |
||
| 7 | res.send(preferences); |
||
| 8 | }); |
||
| 9 | deps.app.get('system-plugin/software-update/config/dashboardUrl', function (req, res) { |
||
| 10 | res.send({ url: deps.config.dashboardURL }); |
||
| 11 | }); |
||
| 12 | deps.app.get('system-plugin/software-update/config/showAlerts', function (req, res) { |
||
| 13 | res.send(preferences.showAlerts); |
||
| 14 | }); |
||
| 15 | deps.app.post('system-plugin/software-update/config/showAlerts', function (req, res) { |
||
| 16 | preferences.showAlerts = req.body; |
||
| 17 | deps.config.preferences.set(PREFERENCES, preferences); |
||
| 18 | deps.config.savePreferences(); |
||
| 19 | res.status(200); |
||
| 20 | res.send(preferences.showAlerts); |
||
| 21 | }); |
||
| 22 | |||
| 23 | deps.globalEventLoop.on("plugin.updateManager.status",function(status){ |
||
| 24 | deps.cockpit.emit("plugin.updateManager.status",status) |
||
|
0 ignored issues
–
show
|
|||
| 25 | }) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 26 | |||
| 27 | deps.globalEventLoop.on("plugin.updateManager.log",function(log){ |
||
| 28 | deps.cockpit.emit("plugin.updateManager.log",log) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 29 | }) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 30 | |||
| 31 | deps.globalEventLoop.on("plugin.updateManager.error",function(error){ |
||
| 32 | deps.cockpit.emit("plugin.updateManager.error",error) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 33 | }) |
||
|
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: Loading history...
|
|||
| 34 | |||
| 35 | deps.cockpit.on("mcu.UpdateFirmware",function(){ |
||
| 36 | deps.globalEventLoop.emit("mcu.UpdateFirmware"); |
||
| 37 | }); |
||
| 38 | |||
| 39 | deps.cockpit.on("mcu.RebuildMCUFirmware",function(){ |
||
| 40 | deps.globalEventLoop.emit("mcu.RebuildMCUFirmware"); |
||
| 41 | }); |
||
| 42 | |||
| 43 | deps.cockpit.on("mcu.FlashESCs",function(){ |
||
| 44 | deps.globalEventLoop.emit("mcu.FlashESCs"); |
||
| 45 | }); |
||
| 46 | |||
| 47 | deps.cockpit.on("mcu.ResetMCU",function(){ |
||
| 48 | deps.globalEventLoop.emit("mcu.ResetMCU"); |
||
| 49 | }); |
||
| 50 | |||
| 51 | |||
| 52 | } |
||
| 53 | function getPreferences(config) { |
||
| 54 | var preferences = config.preferences.get(PREFERENCES); |
||
| 55 | if (preferences === undefined) { |
||
| 56 | preferences = { showAlerts: { showAlerts: true } }; |
||
| 57 | config.preferences.set(PREFERENCES, preferences); |
||
| 58 | } |
||
| 59 | return preferences; |
||
| 60 | } |
||
| 61 | module.exports = function (name, deps) { |
||
| 62 | return new softwareUpdate(name, deps); |
||
| 63 | }; |
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.
Further Readings: