added vfs.ListProviders() and using it in template fsconfig.html (added a new ListFSProviders template function for that)

This commit is contained in:
Manuel Reithuber 2021-06-19 14:06:56 +02:00 committed by Nicola Murino
parent 88b10da596
commit fd4c388b23
3 changed files with 34 additions and 24 deletions

View file

@ -252,20 +252,23 @@ func loadAdminTemplates(templatesPath string) {
filepath.Join(templatesPath, templateAdminDir, templateSetup),
}
usersTmpl := utils.LoadTemplate(nil, usersPaths...)
userTmpl := utils.LoadTemplate(nil, userPaths...)
adminsTmpl := utils.LoadTemplate(nil, adminsPaths...)
adminTmpl := utils.LoadTemplate(nil, adminPaths...)
connectionsTmpl := utils.LoadTemplate(nil, connectionsPaths...)
messageTmpl := utils.LoadTemplate(nil, messagePath...)
foldersTmpl := utils.LoadTemplate(nil, foldersPath...)
folderTmpl := utils.LoadTemplate(nil, folderPath...)
statusTmpl := utils.LoadTemplate(nil, statusPath...)
loginTmpl := utils.LoadTemplate(nil, loginPath...)
changePwdTmpl := utils.LoadTemplate(nil, changePwdPaths...)
maintenanceTmpl := utils.LoadTemplate(nil, maintenancePath...)
defenderTmpl := utils.LoadTemplate(nil, defenderPath...)
setupTmpl := utils.LoadTemplate(nil, setupPath...)
rootTpl := template.New("").Funcs(template.FuncMap{
"ListFSProviders": vfs.ListProviders,
})
usersTmpl := utils.LoadTemplate(rootTpl, usersPaths...)
userTmpl := utils.LoadTemplate(rootTpl, userPaths...)
adminsTmpl := utils.LoadTemplate(rootTpl, adminsPaths...)
adminTmpl := utils.LoadTemplate(rootTpl, adminPaths...)
connectionsTmpl := utils.LoadTemplate(rootTpl, connectionsPaths...)
messageTmpl := utils.LoadTemplate(rootTpl, messagePath...)
foldersTmpl := utils.LoadTemplate(rootTpl, foldersPath...)
folderTmpl := utils.LoadTemplate(rootTpl, folderPath...)
statusTmpl := utils.LoadTemplate(rootTpl, statusPath...)
loginTmpl := utils.LoadTemplate(rootTpl, loginPath...)
changePwdTmpl := utils.LoadTemplate(rootTpl, changePwdPaths...)
maintenanceTmpl := utils.LoadTemplate(rootTpl, maintenancePath...)
defenderTmpl := utils.LoadTemplate(rootTpl, defenderPath...)
setupTmpl := utils.LoadTemplate(rootTpl, setupPath...)
adminTemplates[templateUsers] = usersTmpl
adminTemplates[templateUser] = userTmpl

View file

@ -6,12 +6,9 @@
<div class="col-sm-10">
<select class="form-control" id="idFilesystem" name="fs_provider"
onchange="onFilesystemChanged(this.value)">
<option value="0" {{if eq .Provider 0 }}selected{{end}}>Local</option>
<option value="4" {{if eq .Provider 4 }}selected{{end}}>Local encrypted</option>
<option value="1" {{if eq .Provider 1 }}selected{{end}}>AWS S3 (Compatible)</option>
<option value="2" {{if eq .Provider 2 }}selected{{end}}>Google Cloud Storage</option>
<option value="3" {{if eq .Provider 3 }}selected{{end}}>Azure Blob Storage</option>
<option value="5" {{if eq .Provider 5 }}selected{{end}}>SFTP</option>
{{ range ListFSProviders }}
<option value="{{.}}" {{if eq . $.Provider }}selected{{end}}>{{.ShortInfo}}</option>
{{end}}
</select>
</div>
</div>

View file

@ -68,19 +68,29 @@ func (p FilesystemProvider) ShortInfo() string {
case LocalFilesystemProvider:
return "Local"
case S3FilesystemProvider:
return "S3"
return "AWS S3 (Compatible)"
case GCSFilesystemProvider:
return "GCS"
return "Google Cloud Storage"
case AzureBlobFilesystemProvider:
return "AzBlob"
return "Azure Blob Storage"
case CryptedFilesystemProvider:
return "Encrypted"
return "Local encrypted"
case SFTPFilesystemProvider:
return "SFTP"
}
return ""
}
// ListProviders returns a list of available FilesystemProviders
func ListProviders() []FilesystemProvider {
// TODO this should ultimately be dynamic (i.e. each provider registers itself)
return []FilesystemProvider{
LocalFilesystemProvider, S3FilesystemProvider,
GCSFilesystemProvider, AzureBlobFilesystemProvider,
CryptedFilesystemProvider, SFTPFilesystemProvider,
}
}
// ValidatorHelper implements methods we need for Filesystem.ValidateConfig.
// It is implemented by vfs.Folder and dataprovider.User
type ValidatorHelper interface {