snappymail/dev/Stores/User/Quota.js
djmaze e7180a86ce Made eslint using 'browser' environment and added globals, because RainLoop is used in browsers.
This also allowed to remove all webpack 'externals' overhead.
2020-08-12 00:25:36 +02:00

28 lines
560 B
JavaScript

import ko from 'ko';
import { Magics } from 'Common/Enums';
class QuotaUserStore {
constructor() {
this.quota = ko.observable(0);
this.usage = ko.observable(0);
this.percentage = ko.computed(() => {
const quota = this.quota(),
usage = this.usage();
return 0 < quota ? Math.ceil((usage / quota) * 100) : 0;
});
}
/**
* @param {number} quota
* @param {number} usage
*/
populateData(quota, usage) {
this.quota(quota * Magics.BitLength1024);
this.usage(usage * Magics.BitLength1024);
}
}
export default new QuotaUserStore();