Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 277bdcb

Browse files
DanCechutkarshcmu
authored andcommitted
clean up whitespace, use 2-space indent
1 parent 283709a commit 277bdcb

26 files changed

+2604
-2680
lines changed

src/commands.js

Lines changed: 139 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -23,159 +23,159 @@ var s3;
2323
var dashlist;
2424

2525
function Commands() {
26-
config = new Config();
27-
if (config.statusCheck()) {
28-
components = new Components(config.getProperty('config'));
29-
grafana = new Grafana(config.getProperty('config'), components);
30-
s3 = new S3(config.getProperty('config'), components);
31-
}
32-
gnet = new GNet(components);
33-
dashlist = new Dashlist();
26+
config = new Config();
27+
if (config.statusCheck()) {
28+
components = new Components(config.getProperty('config'));
29+
grafana = new Grafana(config.getProperty('config'), components);
30+
s3 = new S3(config.getProperty('config'), components);
31+
}
32+
gnet = new GNet(components);
33+
dashlist = new Dashlist();
3434
}
3535

3636
// Creates an entity in wizzy or Grafana
3737
Commands.prototype.instructions = function() {
3838

39-
/* Key points before editing the cases:
40-
1. process.argv[0] - reserverd for `node`
41-
2. process.argv[1] - reserverd for `wizzy` or `index.js`
42-
*/
39+
/* Key points before editing the cases:
40+
1. process.argv[0] - reserverd for `node`
41+
2. process.argv[1] - reserverd for `wizzy` or `index.js`
42+
*/
4343

44-
var commands = _.drop(process.argv, 2);
45-
var command = commands[0];
44+
var commands = _.drop(process.argv, 2);
45+
var command = commands[0];
4646

47-
switch(command) {
48-
case 'version':
49-
console.log('0.6.0');
50-
break;
51-
case 'help':
52-
help.showHelp();
53-
break;
54-
case 'init':
55-
config.initialize();
56-
break;
57-
case 'status':
58-
status();
59-
break;
60-
case 'conf':
61-
config.showProperty('config');
62-
break;
63-
case 'set':
64-
config.addProperty(_.drop(commands,1));
65-
break;
66-
case 'unset':
67-
config.removeProperty(_.drop(commands,1));
68-
break;
69-
case 'import':
70-
grafana.import(_.drop(commands));
71-
break;
72-
case 'export':
73-
grafana.export(_.drop(commands));
74-
break;
75-
case 'create':
76-
if (commands[1] === 'dash-list') {
77-
dashlist.createList(_.drop(commands, 2));
78-
} else {
79-
grafana.create(_.drop(commands));
80-
}
81-
break;
82-
case 'delete':
83-
if (commands[1] === 'dash-list') {
84-
dashlist.deleteList(_.drop(commands, 2));
85-
} else {
86-
grafana.delete(_.drop(commands));
87-
}
88-
break;
89-
case 'show':
90-
if (commands[1] === 'dash-list') {
91-
dashlist.showList(_.drop(commands, 2));
92-
} else {
93-
grafana.show(_.drop(commands));
94-
}
95-
break;
96-
case 'list':
97-
if (commands[1] === 'gnet') {
98-
gnet.list(_.drop(commands,2));
99-
} else if (commands[1] === 'panels') {
100-
components.list(_.drop(commands, 1));
101-
} else {
102-
grafana.list(_.drop(commands));
103-
}
104-
break;
105-
case 'clip':
106-
grafana.clip(_.drop(commands));
107-
break;
108-
case 'summarize':
109-
components.summarize(_.drop(commands));
110-
break;
111-
case 'change':
47+
switch(command) {
48+
case 'version':
49+
console.log('0.6.0');
50+
break;
51+
case 'help':
52+
help.showHelp();
53+
break;
54+
case 'init':
55+
config.initialize();
56+
break;
57+
case 'status':
58+
status();
59+
break;
60+
case 'conf':
61+
config.showProperty('config');
62+
break;
63+
case 'set':
64+
config.addProperty(_.drop(commands,1));
65+
break;
66+
case 'unset':
67+
config.removeProperty(_.drop(commands,1));
68+
break;
69+
case 'import':
70+
grafana.import(_.drop(commands));
71+
break;
72+
case 'export':
73+
grafana.export(_.drop(commands));
74+
break;
75+
case 'create':
76+
if (commands[1] === 'dash-list') {
77+
dashlist.createList(_.drop(commands, 2));
78+
} else {
79+
grafana.create(_.drop(commands));
80+
}
81+
break;
82+
case 'delete':
83+
if (commands[1] === 'dash-list') {
84+
dashlist.deleteList(_.drop(commands, 2));
85+
} else {
86+
grafana.delete(_.drop(commands));
87+
}
88+
break;
89+
case 'show':
90+
if (commands[1] === 'dash-list') {
91+
dashlist.showList(_.drop(commands, 2));
92+
} else {
93+
grafana.show(_.drop(commands));
94+
}
95+
break;
96+
case 'list':
97+
if (commands[1] === 'gnet') {
98+
gnet.list(_.drop(commands,2));
99+
} else if (commands[1] === 'panels') {
100+
components.list(_.drop(commands, 1));
101+
} else {
102+
grafana.list(_.drop(commands));
103+
}
104+
break;
105+
case 'clip':
106+
grafana.clip(_.drop(commands));
107+
break;
108+
case 'summarize':
109+
components.summarize(_.drop(commands));
110+
break;
111+
case 'change':
112112
components.change(_.drop(commands));
113113
break;
114-
case 'move':
115-
components.moveCopyOrRemove(commands);
116-
break;
117-
case 'copy':
118-
components.moveCopyOrRemove(commands);
119-
break;
120-
case 'remove':
121-
if (commands[1] === 'from-dash-list') {
122-
dashlist.removeDashboard(_.drop(commands, 2));
123-
} else {
124-
components.moveCopyOrRemove(commands);
125-
}
126-
break;
127-
case 'extract':
128-
components.extract(_.drop(commands));
129-
break;
130-
case 'insert':
131-
components.insert(_.drop(commands));
132-
break;
133-
case 'download':
134-
if (commands[1] === 'from-gnet') {
135-
gnet.download(_.drop(commands, 2));
136-
} else if (commands[1] === 'from-s3') {
137-
s3.download(_.drop(commands, 2));
138-
}
139-
break;
140-
case 'upload':
141-
if (commands[1] === 'to-s3') {
142-
s3.upload(_.drop(commands, 2));
143-
}
144-
break;
145-
case 'add':
146-
if (commands[1] === 'to-dash-list') {
147-
dashlist.addDashboard(_.drop(commands, 2));
148-
}
149-
break;
150-
case 'clear':
151-
if (commands[1] === 'dash-list') {
152-
dashlist.clearList(_.drop(commands, 2));
153-
}
154-
break;
155-
case 'switch':
156-
grafana.switch(_.drop(commands));
157-
break;
158-
default:
159-
logger.showError('Unsupported command called.');
160-
help.showHelp();
161-
}
114+
case 'move':
115+
components.moveCopyOrRemove(commands);
116+
break;
117+
case 'copy':
118+
components.moveCopyOrRemove(commands);
119+
break;
120+
case 'remove':
121+
if (commands[1] === 'from-dash-list') {
122+
dashlist.removeDashboard(_.drop(commands, 2));
123+
} else {
124+
components.moveCopyOrRemove(commands);
125+
}
126+
break;
127+
case 'extract':
128+
components.extract(_.drop(commands));
129+
break;
130+
case 'insert':
131+
components.insert(_.drop(commands));
132+
break;
133+
case 'download':
134+
if (commands[1] === 'from-gnet') {
135+
gnet.download(_.drop(commands, 2));
136+
} else if (commands[1] === 'from-s3') {
137+
s3.download(_.drop(commands, 2));
138+
}
139+
break;
140+
case 'upload':
141+
if (commands[1] === 'to-s3') {
142+
s3.upload(_.drop(commands, 2));
143+
}
144+
break;
145+
case 'add':
146+
if (commands[1] === 'to-dash-list') {
147+
dashlist.addDashboard(_.drop(commands, 2));
148+
}
149+
break;
150+
case 'clear':
151+
if (commands[1] === 'dash-list') {
152+
dashlist.clearList(_.drop(commands, 2));
153+
}
154+
break;
155+
case 'switch':
156+
grafana.switch(_.drop(commands));
157+
break;
158+
default:
159+
logger.showError('Unsupported command called.');
160+
help.showHelp();
161+
}
162162
};
163163

164164
// Shows wizzy status
165165
function status() {
166166

167-
var setupProblem = config.statusCheck(true);
168-
if (setupProblem) {
169-
var setupGit = localfs.checkExists('.git', '.git directory', true);
170-
if(setupGit) {
171-
logger.showResult('wizzy setup complete.');
172-
}
173-
else {
174-
logger.showResult('wizzy setup complete without Git.');
175-
}
176-
} else {
177-
logger.showError('wizzy setup incomplete.');
178-
}
167+
var setupProblem = config.statusCheck(true);
168+
if (setupProblem) {
169+
var setupGit = localfs.checkExists('.git', '.git directory', true);
170+
if (setupGit) {
171+
logger.showResult('wizzy setup complete.');
172+
}
173+
else {
174+
logger.showResult('wizzy setup complete without Git.');
175+
}
176+
} else {
177+
logger.showError('wizzy setup incomplete.');
178+
}
179179

180180
}
181181

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ program.command('*').action(commands.instructions);
1313
// If there is no argument also, we will show help
1414
program.parse(process.argv);
1515
if (process.argv.length < 3) {
16-
commands.help();
16+
commands.help();
1717
}

src/local/alerts.js

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,47 @@ function Alerts() {}
1414

1515
// summarize the alerts
1616
Alerts.prototype.summarize = function() {
17+
var self = this;
1718

18-
var self = this;
19+
var table = new Table({
20+
head: ['Alert Name'],
21+
colWidths: [30]
22+
});
1923

20-
var table = new Table({
21-
head: ['Alert Name'],
22-
colWidths: [30]
23-
});
24+
var dsFiles = localfs.readFilesFromDir(alertDir);
2425

25-
var dsFiles = localfs.readFilesFromDir(alertDir);
26-
27-
_.each(dsFiles, function(dsFile) {
28-
var ds = self.read(localfs.getFileName(dsFile));
29-
table.push([ds.name]);
30-
});
31-
32-
logger.showOutput(table.toString());
33-
logger.showResult('Total alerts: ' + dsFiles.length);
26+
_.each(dsFiles, function(dsFile) {
27+
var ds = self.read(localfs.getFileName(dsFile));
28+
table.push([ds.name]);
29+
});
3430

31+
logger.showOutput(table.toString());
32+
logger.showResult('Total alerts: ' + dsFiles.length);
3533
};
3634

3735
// Saves a alert file under alerts directory on disk
3836
Alerts.prototype.save = function(id, alert, showResult) {
39-
localfs.createDirIfNotExists(alertDir, showResult);
40-
localfs.writeFile(getAlertFile(id), logger.stringify(alert, null, 2));
41-
if (showResult) {
42-
logger.showResult('Alert ' + id + ' saved successfully under alerts directory.');
43-
}
44-
37+
localfs.createDirIfNotExists(alertDir, showResult);
38+
localfs.writeFile(getAlertFile(id), logger.stringify(alert, null, 2));
39+
if (showResult) {
40+
logger.showResult('Alert ' + id + ' saved successfully under alerts directory.');
41+
}
4542
};
4643

4744
// reads alert json from file.
4845
Alerts.prototype.read = function(id) {
49-
50-
if (localfs.checkExists(getAlertFile(id))) {
51-
return JSON.parse(localfs.readFile(getAlertFile(id)));
52-
}
53-
else {
54-
logger.showError('Alert file ' + getAlertFile(id) + ' does not exist.');
55-
process.exit();
56-
}
57-
46+
if (localfs.checkExists(getAlertFile(id))) {
47+
return JSON.parse(localfs.readFile(getAlertFile(id)));
48+
}
49+
else {
50+
logger.showError('Alert file ' + getAlertFile(id) + ' does not exist.');
51+
process.exit();
52+
}
5853
};
5954

6055
// get a alert file name
6156
function getAlertFile(id) {
62-
return alertDir + '/' + id + '.json';
57+
return alertDir + '/' + id + '.json';
6358
}
6459

6560
module.exports = Alerts;

0 commit comments

Comments
 (0)