-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/xcjs/blur-monitor
- Loading branch information
Showing
496 changed files
with
41,772 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*jslint node: true */ | ||
|
||
'use strict'; | ||
|
||
var assets = require('../services/assets'); | ||
|
||
module.exports = getRoutes(); | ||
|
||
function getRoutes() { | ||
var routes = []; | ||
|
||
routes.push({ | ||
method: 'GET', | ||
path: '/api/assets/apps', | ||
handler: function (request, reply) { | ||
return reply(assets.getAssets('apps')); | ||
} | ||
}); | ||
|
||
routes.push({ | ||
method: 'GET', | ||
path: '/api/assets/distros', | ||
handler: function (request, reply) { | ||
return reply(assets.getAssets('distros')); | ||
} | ||
}); | ||
|
||
return routes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/*jslint node: true */ | ||
|
||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var env = require('../util/environment'); | ||
|
||
module.exports = { | ||
getAssets: getAssets | ||
}; | ||
|
||
function getAssets(type) { | ||
var assetPath = Array.isArray(env.staticRoot) ? | ||
path.join('./', env.staticRoot[1], 'assets/img/app') : | ||
path.join('./', env.staticRoot, 'assets/img/app'); | ||
|
||
switch(type) { | ||
case 'apps': { | ||
return listDirectory(path.join(assetPath, type)); | ||
break; | ||
} | ||
|
||
case 'distros': { | ||
return listDirectory(path.join(assetPath, type)); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
function listDirectory(path) { | ||
var promise = new Promise(function (resolve, reject) { | ||
fs.readdir(path, function(err, assets) { | ||
if(!err) { | ||
var assets = assets.map(function(asset) { | ||
return(asset.substr(0, asset.lastIndexOf('.'))); | ||
}); | ||
|
||
resolve(assets); | ||
} else { | ||
console.error(err); | ||
reject(err); | ||
} | ||
}); | ||
}); | ||
|
||
return promise; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*jslint node: true */ | ||
/*jslint esversion: 6 */ | ||
|
||
'use strict'; | ||
|
||
var shell = require('./shell'); | ||
|
||
module.exports = { | ||
getRelease: getRelease(), | ||
parse: parseRelease | ||
}; | ||
|
||
function getRelease() { | ||
return shell.spawn('cat', ['/etc/lsb-release']); | ||
} | ||
|
||
function parseRelease(stdout) { | ||
var lines = stdout.toString().split(/\n/g); | ||
var lsbRelease = {}; | ||
|
||
lines.forEach(function(line) { | ||
var key = line.substr(0, line.indexOf('=')); | ||
var value = line.substr(line.indexOf('=') + 1, line.length -1); | ||
|
||
if(key && value) { | ||
while(value.indexOf('"') > -1) { | ||
value = value.replace('"', ''); | ||
} | ||
|
||
lsbRelease[key] = value; | ||
} | ||
}); | ||
|
||
return lsbRelease; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*jslint node: true */ | ||
/*jslint esversion: 6 */ | ||
|
||
'use strict'; | ||
|
||
var childProcess = require('child_process'); | ||
|
||
var exec = childProcess.exec; | ||
var spawn = childProcess.spawn; | ||
|
||
module.exports = { | ||
exec: execWrapper, | ||
spawn: spawnWrapper | ||
}; | ||
|
||
function execWrapper(command) { | ||
var promise = new Promise(function(resolve, reject) { | ||
exec(command, function(error, stdout, stderr) { | ||
if (error) { | ||
reject('Command "' + command + '" failed. Please check for earlier errors'); | ||
return; | ||
} | ||
|
||
if(stderr) { | ||
console.error(stderr); | ||
} | ||
|
||
resolve(stdout); | ||
}); | ||
}); | ||
|
||
return promise; | ||
} | ||
|
||
function spawnWrapper(command, args) { | ||
var process = spawn(command, args); | ||
|
||
var promise = new Promise(function(resolve, reject) { | ||
process.stdout.setEncoding("utf8"); | ||
|
||
process.stdout.on('data', function(stdout) { | ||
resolve(stdout); | ||
}); | ||
|
||
process.stderr.on('data', function(stderr) { | ||
console.error(stderr); | ||
}); | ||
|
||
process.on('close', function(code) { | ||
if (code !== 0) { | ||
reject('Command "' + command + '" failed. Please check for earlier errors'); | ||
} | ||
}); | ||
}); | ||
|
||
return promise; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
angular.module('BlurMonitor.assets', [ | ||
'ngResource' | ||
]); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular.module('BlurMonitor.assets').service('AssetsResource', | ||
['$resource', AssetsResource]); | ||
|
||
function AssetsResource($resource) { | ||
var AppAssets = $resource('/api/assets/apps'); | ||
var DistroAssets = $resource('/api/assets/distros'); | ||
|
||
this.getApps = AppAssets.query; | ||
this.getDistros = DistroAssets.query; | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.