mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-09-18 16:42:16 +02:00
refactor: migrate the frontend from AngularJS to Vue 3
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
export const createQuotaService = function (http) {
|
||||
function decorate(q) {
|
||||
q = q || { used: 0, total: 0 };
|
||||
q.unlimited = !q.total;
|
||||
q.percent = q.unlimited ? 0 : Math.min(100, (q.used * 100) / q.total);
|
||||
q.level = q.unlimited
|
||||
? "unlimited"
|
||||
: q.percent >= 95
|
||||
? "danger"
|
||||
: q.percent >= 80
|
||||
? "warn"
|
||||
: "ok";
|
||||
return q;
|
||||
}
|
||||
return {
|
||||
decorate: decorate,
|
||||
load: function () {
|
||||
return http.get("/api/user/quota").then((res) => {
|
||||
const quota = res.data || {};
|
||||
quota.storage = decorate(quota.storage);
|
||||
quota.file = decorate(quota.file);
|
||||
quota.repository = decorate(quota.repository);
|
||||
return quota;
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user