Re: [vhffs-dev] Add improved disk quota

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Hello Aaron,

On Sun, May 10, 2020 at 12:12:04PM +0000, Aaron Dewes wrote:
> Hello,
> 
> I'm currently trying to improve the design of vhffs. I made a little
> improvement which displays the disk quota as gradient, which is a new
> feature in CSS3. This also includes a fallback for older browsers, so if
> linear-gradient is not available, disk quota is displayed as in the
> current version. I also made little changes by removing/adding tabs and
> newlines in the css file.
> 
> You can find the diff attached.

Great, thank you, sorry for the delay, I've been very busy lately.
Anyway, some comments below ! :)


> diff --git a/vhffs-panel/templates/group/index.tt b/vhffs-panel/templates/group/index.tt
> index 3b9669e1..e8625fe1 100644
> --- a/vhffs-panel/templates/group/index.tt
> +++ b/vhffs-panel/templates/group/index.tt
> @@ -9,7 +9,7 @@
>  [% IF use_quota %]
>      <p>[% 'Quota (used/total): %d/%dMB' | i18n | pretty_print(p.get_quota_used, p.get_quota) | html %] &#8212;
>      <span class="quota">
> 
> - <span class="quota-used" style="width:[% (p.get_quota_used / 
> p.get_quota * 100) | format('%d') %]%" title="[% (p.get_quota_used / 
> p.get_quota * 100) | format('%.2f') %]%"></span>
> 
> + <span class="quota-used" style="width:[% (p.get_quota_used / 
> p.get_quota * 100) | format('%d') %]%" title="[% (p.get_quota_used / 
> p.get_quota * 100) | format('%.2f') %]%"></span><span 
> class="quota-unused" style="width:[% (100 - p.get_quota / 
> p.get_quota_used * 100) | format('%d') %]%" title="[% (100 - 
> p.get_quota / p.get_quota_used * 100) | format('%.2f') %]%"></span>

Maths are wrong here. Remaining part should be "100 - p.get_quota_used / 
p.get_quota * 100". (i.e. 1 - used/total).

(And there is an obvious divide by zero if p.get_quota_used returns 0, 
which is very likely to happen).


The unused part does not seem to work for me even after fixing the 
remaining width CSS value, the gradient is always displayed in full 
length whatever the value of used quota. I will let you look :)


Sylvain

Attachment: signature.asc
Description: Digital signature



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/