Quota changes

- nicer error message
- add quota for group directories with separate default
- support for more decimal places in human file size
- add some help_text to default quota
This commit is contained in:
nathan 2022-11-23 13:53:47 -07:00
parent b31ce0922d
commit 3402ed645a
6 changed files with 71 additions and 30 deletions

View File

@ -28,19 +28,24 @@
<column/> <column/>
</columns> </columns>
<rows> <rows>
<row class="dialogHeader"> <row class="dialogHeader">
<description value="Group name" for="account_lid"/> <description value="Group name" for="account_lid"/>
<textbox id="account_lid" size="40" maxlength="64" class="et2_fullWidth" needed="true" onchange="app.admin.changeGroup"/> <textbox id="account_lid" size="40" maxlength="64" class="et2_fullWidth" needed="true"
</row> onchange="app.admin.changeGroup"/>
<row> </row>
<description value="Description" for="account_description"/> <row>
<textbox id="account_description" size="40" maxlength="64" class="et2_fullWidth"/> <description value="Description" for="account_description"/>
</row> <textbox id="account_description" size="40" maxlength="64" class="et2_fullWidth"/>
<row disabled="!@mailAllowed"> </row>
<description value="EMail"/> <row disabled="!@mailAllowed">
<url-email id="account_email" size="40" maxlength="64" class="et2_fullWidth"/> <description value="EMail"/>
</row> <url-email id="account_email" size="40" maxlength="64" class="et2_fullWidth"/>
</rows> </row>
<row>
<description value="Filesystem quota" disabled="!@epl"/>
<textbox id="quota" readonly="true" blur="@default_quota"/>
</row>
</rows>
</grid> </grid>
<tabbox id="tabs" class="et2_nowrap" span="all" width="100%" tab_height="250px"> <tabbox id="tabs" class="et2_nowrap" span="all" width="100%" tab_height="250px">
<tabs> <tabs>

View File

@ -1112,10 +1112,19 @@ class Vfs extends Vfs\Base
*/ */
static function hsize($size) static function hsize($size)
{ {
if ($size < 1024) return $size; if($size < 1024)
if ($size < 1024*1024) return sprintf('%3.1fk',(float)$size/1024); {
if ($size < 1024*1024*1024) return sprintf('%3.1fM',(float)$size/(1024*1024)); return $size;
return sprintf('%3.1fG',(float)$size/(1024*1024*1024)); }
if($size < 1024 * 1024)
{
return sprintf('%3.2Gk', (float)$size / 1024);
}
if($size < 1024 * 1024 * 1024)
{
return sprintf('%3.4GM', (float)$size / (1024 * 1024));
}
return sprintf('%3.4GG', (float)$size / (1024 * 1024 * 1024));
} }
/** /**
@ -1133,22 +1142,24 @@ class Vfs extends Vfs\Base
preg_match('#([0-9.]+)[\s]*([a-z]+)#i', $val, $matches); preg_match('#([0-9.]+)[\s]*([a-z]+)#i', $val, $matches);
$last = ''; $last = '';
if(isset($matches[2])){ if(isset($matches[2]))
{
$last = $matches[2]; $last = $matches[2];
} }
if(isset($matches[1])){ if(isset($matches[1]))
$val = (int) $matches[1]; {
$val = (float)$matches[1];
} }
switch (strtolower($last)) switch(strtolower($last))
{ {
case 'g': case 'g':
case 'gb': case 'gb':
$val *= 1024; $val *= 1024;
case 'm': case 'm':
case 'mb': case 'mb':
$val *= 1024; $val *= 1024;
case 'k': case 'k':
case 'kb': case 'kb':
$val *= 1024; $val *= 1024;

View File

@ -1790,14 +1790,34 @@ class filemanager_ui
$tmp_path = ini_get('upload_tmp_dir') . '/' . basename($tmp_name); $tmp_path = ini_get('upload_tmp_dir') . '/' . basename($tmp_name);
} }
if (Vfs::copy_uploaded($tmp_path, $path, $props, false)) try
{ {
++$arr['files']; if(Vfs::copy_uploaded($tmp_path, $path, $props, false))
$uploaded[] = $data['name']; {
++$arr['files'];
$uploaded[] = $data['name'];
}
else
{
++$arr['errs'];
}
} }
else catch (\EGroupware\Stylite\Vfs\QuotaExceededException $e)
{ {
// File was touched but not written. Might need to delete it
$stat = Vfs::stat($path);
if($stat && $stat['size'] == 0)
{
Vfs::unlink($path);
}
// Send error
++$arr['errs']; ++$arr['errs'];
++$script_error;
$arr['msg'] = $e->getMessage();
$arr['msg'] .= "\n" . lang("You can either delete some files or get in touch with your administrator to get more space");
// No point continuing
break;
} }
} }
} }

View File

@ -544,7 +544,7 @@ export class filemanagerAPP extends EgwApp
{ {
if(this.egw.pushAvailable()) if(this.egw.pushAvailable())
{ {
this.egw.message(_data.msg); this.egw.message(_data.msg, _data.errs > 0 ? "error" : "success");
} }
else else
{ {

View File

@ -241,6 +241,7 @@ properties saved. filemanager en Properties saved.
protocol to use filemanager en Protocol to use protocol to use filemanager en Protocol to use
protocols filemanager en Protocols protocols filemanager en Protocols
quick jump to filemanager en Quick jump to quick jump to filemanager en Quick jump to
quota exceeded filemanager en Quota exceeded
read & write access filemanager en Read & write access read & write access filemanager en Read & write access
read access only filemanager en Read access only read access only filemanager en Read access only
readonly share link filemanager en Readonly Share link readonly share link filemanager en Readonly Share link
@ -328,6 +329,7 @@ writable share link filemanager en Writable Share link
wrong username or password! filemanager en Wrong username or password! wrong username or password! filemanager en Wrong username or password!
you are not allowed to finally delete older versions and deleted files! filemanager en You are NOT allowed to finally delete older versions and deleted files! you are not allowed to finally delete older versions and deleted files! filemanager en You are NOT allowed to finally delete older versions and deleted files!
you are not allowed to upload a script! filemanager en You are NOT allowed to upload a script! you are not allowed to upload a script! filemanager en You are NOT allowed to upload a script!
you can either delete some files or get in touch with your administrator to get more space filemanager en You can either delete some files or get in touch with your administrator to get more space
you can only grant additional rights, you can not take rights away! filemanager en You can only grant additional rights, you can NOT take rights away! you can only grant additional rights, you can not take rights away! filemanager en You can only grant additional rights, you can NOT take rights away!
you can use regular upload [+] button to upload files. filemanager en You can use regular upload [+] button to upload files. you can use regular upload [+] button to upload files. filemanager en You can use regular upload [+] button to upload files.
you do not have access to %1 filemanager en You do not have access to %1 you do not have access to %1 filemanager en You do not have access to %1

View File

@ -4,7 +4,9 @@
<overlay> <overlay>
<template id="filemanager.quota" template="" lang="" group="0" version="1.9.004"> <template id="filemanager.quota" template="" lang="" group="0" version="1.9.004">
<vbox> <vbox>
<textbox label="Home quota" id="quota" blur="(EPL Only)" disabled="true"/> <textbox label="User home quota" id="quota" blur="(EPL Only)" disabled="true"/>
<textbox label="Group home quota" id="group_quota" blur="(EPL Only)" disabled="true"
help-text="Enter a file size, e.g. 100K, 200M or 2G"/>
<button label="Recalculate" id="button[recalculate]" statustext="Recalculate directory sizes"/> <button label="Recalculate" id="button[recalculate]" statustext="Recalculate directory sizes"/>
<hbox span="2" class="dialogFooterToolbar"> <hbox span="2" class="dialogFooterToolbar">
@ -14,7 +16,8 @@
</hbox> </hbox>
</vbox> </vbox>
<styles> <styles>
#filemanager-quota_quota::part(form-control-input) { #filemanager-quota_quota::part(form-control-input),
#filemanager-quota_group_quota::part(form-control-input){
max-width: 15ex; max-width: 15ex;
} }