webui: minor improvements

This commit is contained in:
Nicola Murino
2021-03-27 22:23:01 +01:00
parent 5cd27ce529
commit 2a89a8f664
4 changed files with 41 additions and 20 deletions

View File

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

View File

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

View File

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

View File

@@ -74,6 +74,26 @@ func (v *BaseVirtualFolder) GetQuotaSummary() string {
return result 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 // IsLocalOrLocalCrypted returns true if the folder provider is local or local encrypted
func (v *BaseVirtualFolder) IsLocalOrLocalCrypted() bool { func (v *BaseVirtualFolder) IsLocalOrLocalCrypted() bool {
return v.FsConfig.Provider == LocalFilesystemProvider || v.FsConfig.Provider == CryptedFilesystemProvider return v.FsConfig.Provider == LocalFilesystemProvider || v.FsConfig.Provider == CryptedFilesystemProvider