snappymail/dev/Stores/User/Quota.js

25 lines
470 B
JavaScript
Raw Normal View History

import ko from 'ko';
export const QuotaUserStore = new class {
constructor() {
this.quota = ko.observable(0);
this.usage = ko.observable(0);
2016-06-30 08:02:45 +08:00
this.percentage = ko.computed(() => {
2019-07-05 03:19:24 +08:00
const quota = this.quota(),
usage = this.usage();
2016-06-30 08:02:45 +08:00
return 0 < quota ? Math.ceil((usage / quota) * 100) : 0;
});
}
2016-06-30 08:02:45 +08:00
/**
* @param {number} quota
* @param {number} usage
*/
populateData(quota, usage) {
2020-08-14 04:58:41 +08:00
this.quota(quota * 1024);
this.usage(usage * 1024);
}
};