Files
cloudron-box/src/progress.js
T
Johannes Zellner 182f978f27 Replace isUpdating with a more generic progress API
/api/v1/cloudron/progress -> 200
  {
    update: null | { percent: 13, message: 'foobar' },
    backup: null | { percent: 37, message: 'great' }
  }

the start splash server also serves up that API endpoint,
by serving up the /progress.json file

Fixes #185
2015-02-15 19:47:11 +01:00

43 lines
830 B
JavaScript

/* jslint node: true */
'use strict';
var assert = require('assert');
exports = module.exports = {
set: set,
clear: clear,
get: get,
UPDATE: 'update',
BACKUP: 'backup'
};
// if progress.update or progress.backup are object, they will contain 'percent' and 'message' properties
// otherwise no such operation is currently ongoing
var progress = {
update: null,
backup: null
};
function set(tag, percent, message) {
assert(tag === exports.UPDATE || tag === exports.BACKUP);
assert(typeof percent === 'number');
assert(typeof message === 'string');
progress[tag] = {
percent: percent,
message: message
};
}
function clear(tag) {
assert(tag === exports.UPDATE || tag === exports.BACKUP);
progress[tag] = null;
}
function get() {
return progress;
}