Comparing version 0.7.22-181 to 0.7.23-182
@@ -10,2 +10,3 @@ // Misc common functions.. | ||
var alias = require("./alias"); | ||
var moment = require("moment"); | ||
@@ -164,2 +165,26 @@ // Common API call to FeedHenry | ||
exports.createTableForNotifications = function(notifications) { | ||
var maxId=24, maxUser=25, maxTS = 20, maxType = 18, maxMessage = 25; | ||
for(var i=0;i<notifications.length;i++){ | ||
var noti = notifications[i].fields; | ||
if(strlen(noti.eventType) > maxType) maxType = strlen(noti.eventType); | ||
if(strlen(noti.message) > maxMessage) maxMessage = strlen(noti.message); | ||
if(strlen(noti.updatedBy) > maxUser) maxUser = strlen(noti.updatedBy); | ||
} | ||
if(maxType > exports.maxTableCell) maxType = exports.maxTableCell; | ||
if(maxMessage > exports.maxTableCell) maxMessage = exports.maxTableCell; | ||
var table = new Table({ | ||
head:['Guid', 'When', 'Updated By', 'Notification Type', 'Detail'], | ||
colWidths: [maxId+2, maxTS+2, maxUser+2, maxType+2, maxMessage+2], | ||
style: exports.style() | ||
}); | ||
for(var p=0;p<notifications.length;p++){ | ||
var not = notifications[p].fields; | ||
table.push([ notifications[p].guid, moment(not.sysCreated, 'YYYY-MM-DD h:mm:ss:SSS').fromNow(), not.updatedBy, not.eventType, not.message]); | ||
} | ||
return table; | ||
} | ||
function bytesToSize(bytes) { | ||
@@ -166,0 +191,0 @@ var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; |
@@ -118,2 +118,3 @@ process.title = "fhc"; | ||
,'restart' | ||
,'notifications' | ||
] | ||
@@ -135,3 +136,2 @@ , fhcList = fhc.fhcList = [ | ||
,'appinit' | ||
,'notifications' | ||
] | ||
@@ -138,0 +138,0 @@ , fullList = fhc.fullList = cmdList.concat(aliasNames).concat(fhcList).filter(function (c) { |
module.exports = notifications; | ||
notifications.usage = "fhc notifications <app-id> <email-address-to-notify>"; | ||
notifications.usage = "fhc notifications [list] <app-guid>" | ||
+ "\nfhc notifications auditlog <app-guid>" | ||
+ "\nfhc notifications dismiss <app-guid> <notification-guid> [<notification-guid>]"; | ||
var fhc = require("./fhc"); | ||
var common = require("./common"); | ||
var update = require("./update"); | ||
var fhreq = require("./utils/request"); | ||
var ini = require('./utils/ini'); | ||
// Main update entry point | ||
function notifications (args, cb) { | ||
if (args.length !== 2) return cb(notifications.usage); | ||
var appId = fhc.appId(args[0]); | ||
var name = 'notification_email'; | ||
var value = args[1]; | ||
return update.doUpdate(appId, name, value, cb); | ||
if (args.length === 0) return cb(notifications.usage); | ||
if (args.length === 1){ | ||
return doList(fhc.appId(args[0]), cb); | ||
} else { | ||
var act = args[0]; | ||
if(act === "list"){ | ||
return doList(fhc.appId(args[1]), cb); | ||
} else if(act === "auditlog"){ | ||
return doAuditLog(fhc.appId(args[1]), cb); | ||
} else if(act === "dismiss"){ | ||
return doDismiss(fhc.appId(args[1]), args.slice(1), cb); | ||
} else { | ||
return cb(notifications.usage); | ||
} | ||
} | ||
}; | ||
function doList(appId, cb){ | ||
return listEventLogs(appId, false, cb); | ||
} | ||
function doAuditLog(appId, cb){ | ||
return listEventLogs(appId, true, cb); | ||
} | ||
function listEventLogs(appId, audit, cb){ | ||
if(!appId){ | ||
return cb("No app guid specified. Usage: " + notifications.usage); | ||
} | ||
var uri = "box/srv/1.1/app/eventlog/listEvents"; | ||
var payload = {appGuid: appId, eventGroup:"NOTIFICATION"}; | ||
if(audit){ | ||
payload.audit = true; | ||
} | ||
common.doApiCall(fhreq.getFeedHenryUrl(), uri, payload, "Error getting event logs for app: ", function(err, data) { | ||
if(err) return cb(err); | ||
if(ini.get('table') === true && data.list) { | ||
notifications.table = common.createTableForNotifications(data.list); | ||
} | ||
return cb(undefined, data); | ||
}); | ||
} | ||
function doDismiss(appId, notificationGuids, cb){ | ||
if(!appId){ | ||
return cb("No app guid specified. Usage: " + notifications.usage); | ||
} | ||
var uri = "box/srv/1.1/app/eventlog/dismissEvents"; | ||
var payload = {appGuid: appId, eventGuids: notificationGuids}; | ||
common.doApiCall(fhreq.getFeedHenryUrl(), uri, payload, "Error dismissing event logs for app: ", function(err, data){ | ||
if(err) return cb(err); | ||
return cb(undefined, data); | ||
}); | ||
} | ||
// bash completion | ||
@@ -19,0 +69,0 @@ notifications.completion = function (opts, cb) { |
@@ -5,3 +5,3 @@ { | ||
"keywords" : [ "cli", "feedhenry" ], | ||
"version": "0.7.22-181", | ||
"version": "0.7.23-182", | ||
"preferGlobal" : true, | ||
@@ -28,2 +28,3 @@ "homepage" : "http://git.io/fh-fhc", | ||
"cheerio" : "*", | ||
"moment": "*", | ||
"cli-table" : "git://github.com/LearnBoost/cli-table.git#703ab71" | ||
@@ -30,0 +31,0 @@ }, |
@@ -1,1 +0,1 @@ | ||
0.7.22-181 | ||
0.7.23-182 |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
375058
149
9644
9
6
+ Addedmoment@*
+ Addedmoment@2.30.1(transitive)