forked from lair-framework/browser-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_service_to_specified_color.js
36 lines (34 loc) · 1.25 KB
/
change_service_to_specified_color.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var changeServicesToSpecifiedColor = function (lairService, lairColor) {
// Changes the status of a given service to the specified color
//
// Created by: Dan Kottmann
// Updated by: Ryan Dorey
// Usage: changeServicesToSpecifiedColor('dce-rpc', 'lair-orange');
// Colors available: lair-grey, lair-blue, lair-green, lair-orange, lair-red
// Requires client-side updates: true
var PROJECT_ID = Session.get('projectId');
var MODIFIED_BY = Meteor.user().emails[0].address;
if (lairColor !== 'lair-grey' && lairColor !== 'lair-blue' && lairColor !== 'lair-green' && lairColor !== 'lair-orange' && lairColor !== 'lair-red') {
console.log('Invalid color specified');
return;
}
var services = Ports.find({
'project_id': PROJECT_ID,
'service': lairService
}).fetch();
if (services.length < 1) {
console.log('No services found');
return;
}
services.forEach(function (port) {
Ports.update({
'_id': port._id
}, {
$set: {
'status': lairColor,
'last_modified_by': MODIFIED_BY
}
});
});
console.log('Total of ' + services.length + ' service(s) updated to ' + lairColor + '.');
};