webui: minor improvements

This commit is contained in:
Nicola Murino 2021-03-27 22:23:01 +01:00
parent 5cd27ce529
commit 2a89a8f664
No known key found for this signature in database
GPG key ID: 2F1FB59433D5A8CB
4 changed files with 41 additions and 20 deletions

View file

@ -931,7 +931,7 @@ func (u *User) GetInfoString() string {
case vfs.GCSFilesystemProvider:
result += "Storage: GCS "
case vfs.AzureBlobFilesystemProvider:
result += "Storage: Azure "
result += "Storage: AzBlob "
case vfs.CryptedFilesystemProvider:
result += "Storage: Encrypted "
case vfs.SFTPFilesystemProvider:

View file

@ -28,7 +28,7 @@
<thead>
<tr>
<th>Name</th>
<th>Path</th>
<th>Storage</th>
<th>Quota</th>
<th>Used by</th>
</tr>
@ -37,7 +37,7 @@
{{range .Folders}}
<tr>
<td>{{.Name}}</td>
<td>{{.MappedPath}}</td>
<td>{{.GetStorageDescrition}}</td>
<td>{{.GetQuotaSummary}}</td>
<td>{{.GetUsersAsString}}</td>
</tr>
@ -123,16 +123,18 @@ function deleteAction() {
$(document).ready(function () {
$.fn.dataTable.ext.buttons.add = {
text: 'Add',
text: '<i class="fas fa-plus"></i>',
name: 'add',
titleAttr: "Add",
action: function (e, dt, node, config) {
window.location.href = '{{.FolderURL}}';
}
};
$.fn.dataTable.ext.buttons.edit = {
text: 'Edit',
text: '<i class="fas fa-pen"></i>',
name: 'edit',
titleAttr: "Edit",
action: function (e, dt, node, config) {
var folderName = table.row({ selected: true }).data()[0];
var path = '{{.FolderURL}}' + "/" + fixedEncodeURIComponent(folderName);
@ -157,8 +159,9 @@ function deleteAction() {
};
$.fn.dataTable.ext.buttons.delete = {
text: 'Delete',
text: '<i class="fas fa-trash"></i>',
name: 'delete',
titleAttr: "Delete",
action: function (e, dt, node, config) {
$('#deleteModal').modal('show');
},
@ -212,15 +215,12 @@ function deleteAction() {
};
var table = $('#dataTable').DataTable({
dom: "<'row'<'col-sm-12'B>>" +
"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
select: true,
stateSave: true,
stateDuration: 3600,
buttons: [],
"scrollX": false,
"scrollY": "50vh",
"order": [[0, 'asc']]
});
@ -244,6 +244,8 @@ function deleteAction() {
table.button().add(0,'add');
{{end}}
table.buttons().container().appendTo('#dataTable_wrapper .col-md-6:eq(0)');
table.on('select deselect', function () {
var selectedRows = table.rows({ selected: true }).count();
{{if .LoggedAdmin.HasPermission "del_users"}}

View file

@ -31,7 +31,6 @@
<th>Username</th>
<th>Status</th>
<th>Expiration</th>
<th>Permissions</th>
<th>Bandwidth</th>
<th>Quota</th>
<th>Other</th>
@ -44,7 +43,6 @@
<td>{{.Username}}</td>
<td>{{if eq .Status 1 }}Active{{else}}Inactive{{end}}</td>
<td>{{.GetExpirationDateAsString}}</td>
<td>{{.GetPermissionsAsString}}</td>
<td>{{.GetBandwidthAsString}}</td>
<td>{{.GetQuotaSummary}}</td>
<td>{{.GetInfoString}}</td>
@ -131,16 +129,18 @@
$(document).ready(function () {
$.fn.dataTable.ext.buttons.add = {
text: 'Add',
text: '<i class="fas fa-plus"></i>',
name: 'add',
titleAttr: "Add",
action: function (e, dt, node, config) {
window.location.href = '{{.UserURL}}';
}
};
$.fn.dataTable.ext.buttons.edit = {
text: 'Edit',
text: '<i class="fas fa-pen"></i>',
name: 'edit',
titleAttr: "Edit",
action: function (e, dt, node, config) {
var username = dt.row({ selected: true }).data()[1];
var path = '{{.UserURL}}' + "/" + fixedEncodeURIComponent(username);
@ -150,7 +150,7 @@
};
$.fn.dataTable.ext.buttons.clone = {
text: 'Clone',
text: '<i class="fas fa-clone"></i>',
name: 'clone',
action: function (e, dt, node, config) {
var username = dt.row({ selected: true }).data()[1];
@ -176,8 +176,9 @@
};
$.fn.dataTable.ext.buttons.delete = {
text: 'Delete',
text: '<i class="fas fa-trash"></i>',
name: 'delete',
titleAttr: "Delete",
action: function (e, dt, node, config) {
/*console.log("delete clicked, num row selected: " + dt.rows({ selected: true }).count());
var data = dt.rows({ selected: true }).data();
@ -236,10 +237,6 @@
};
var table = $('#dataTable').DataTable({
dom: "<'row'<'col-sm-12'B>>" +
"<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
select: true,
stateSave: true,
stateDuration: 3600,
@ -252,6 +249,7 @@
},
],
"scrollX": false,
"scrollY": "50vh",
"order": [[1, 'asc']]
});
@ -279,6 +277,7 @@
table.button().add(0,'add');
{{end}}
table.buttons().container().appendTo('#dataTable_wrapper .col-md-6:eq(0)');
table.on('select deselect', function () {
var selectedRows = table.rows({ selected: true }).count();

View file

@ -74,6 +74,26 @@ func (v *BaseVirtualFolder) GetQuotaSummary() string {
return result
}
// GetStorageDescrition returns the storage description
func (v *BaseVirtualFolder) GetStorageDescrition() string {
switch v.FsConfig.Provider {
case LocalFilesystemProvider:
return fmt.Sprintf("Local: %v", v.MappedPath)
case S3FilesystemProvider:
return fmt.Sprintf("S3: %v", v.FsConfig.S3Config.Bucket)
case GCSFilesystemProvider:
return fmt.Sprintf("GCS: %v", v.FsConfig.GCSConfig.Bucket)
case AzureBlobFilesystemProvider:
return fmt.Sprintf("AzBlob: %v", v.FsConfig.AzBlobConfig.Container)
case CryptedFilesystemProvider:
return fmt.Sprintf("Encrypted: %v", v.MappedPath)
case SFTPFilesystemProvider:
return fmt.Sprintf("SFTP: %v", v.FsConfig.SFTPConfig.Endpoint)
default:
return ""
}
}
// IsLocalOrLocalCrypted returns true if the folder provider is local or local encrypted
func (v *BaseVirtualFolder) IsLocalOrLocalCrypted() bool {
return v.FsConfig.Provider == LocalFilesystemProvider || v.FsConfig.Provider == CryptedFilesystemProvider