Skip to content

Commit

Permalink
Merge pull request #87 from dergelm/globalbrightness
Browse files Browse the repository at this point in the history
Globalbrightness
  • Loading branch information
versx authored Jul 15, 2021
2 parents 04a472f + a0adb37 commit 48f02f8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ router.post('/devices/mass_action', async (req, res) => {
logger('dcm').info('Received restart by config mass action');
endpoint = 'restart';
break;
case 'brightness':
logger('dcm').info('Received brightness mass action');
endpoint = 'brightness?value=0';
break;
default:
res.send('Error Occurred');
}
Expand Down Expand Up @@ -740,6 +744,7 @@ router.get('/utilities/clear_device_ips', async (req, res) => {

const get = async (uuid, url) => {
const isScreen = url.includes('/screen');
const isBrightness = url.includes('/brightness');
if (isScreen) {
const screenshotFile = path.resolve(__dirname, '../../screenshots/' + uuid + '.png');
const fileStream = fs.createWriteStream(screenshotFile);
Expand All @@ -749,6 +754,14 @@ const get = async (uuid, url) => {
logger('dcm').error(`Failed to get screenshot for ${uuid} at ${url}. Are you sure the device is up? ${err.code}`);
})
.pipe(fileStream);
} else if (isBrightness) {
request.post(url, (err) => {
if (err) {
logger('dcm').error(`Error: ${err}`);
}
}).on('error', (err) => {
logger('dcm').error(`Error occurred: ${err}`);
});
} else {
request.get(url, (err) => {
if (err) {
Expand Down
1 change: 1 addition & 0 deletions src/views/devices.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<h6 class="dropdown-header">Device Actions</h6>
<button type='button' class="dropdown-item" onclick='sendMassAction("screenshot")'>{{Get All Screenshots}}</button>
<button type='button' class="dropdown-item" onclick='sendMassAction("restart")'>{{Restart All Devices}}</button>
<button type='button' class="dropdown-item" onclick='sendMassAction("brightness")'>{{Dimm All Devices}}</button>
</div>
</div>
<div class="btn-group" role="group" style="float: left;">
Expand Down
1 change: 1 addition & 0 deletions static/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@
"Clear Device IP Addresses": "Clear Device IP Addresses",
"Model": "Model",
"Exclude From Reboots": "Exclude From Reboots",
"Dimm All Devices": "Dimm All Devices",
"Brightness": "Helligkeit"
}
1 change: 1 addition & 0 deletions static/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,6 @@
"Clear Device IP Addresses": "Clear Device IP Addresses",
"Model": "Model",
"Exclude From Reboots": "Exclude From Reboots",
"Dimm All Devices": "Dimm All Devices",
"Brightness": "Brightness"
}
1 change: 1 addition & 0 deletions static/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,6 @@
"Clear Device IP Addresses": "Clear Device IP Addresses",
"Model": "Model",
"Exclude From Reboots": "Exclude From Reboots",
"Dimm All Devices": "Dimm All Devices",
"Brightness": "Brightness"
}

0 comments on commit 48f02f8

Please sign in to comment.