2022-07-17 18:16:00 +00:00
|
|
|
<!--
|
2023-11-04 09:54:52 +00:00
|
|
|
Copyright (C) 2023 Nicola Murino
|
2022-07-17 18:16:00 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
This WebUI uses the KeenThemes Mega Bundle, a proprietary theme:
|
2022-07-17 18:16:00 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
https://keenthemes.com/products/templates-mega-bundle
|
2022-07-17 18:16:00 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
KeenThemes HTML/CSS/JS components are allowed for use only within the
|
|
|
|
SFTPGo product and restricted to be used in a resealable HTML template
|
|
|
|
that can compete with KeenThemes products anyhow.
|
|
|
|
|
|
|
|
This WebUI is allowed for use only within the SFTPGo product and
|
|
|
|
therefore cannot be used in derivative works/products without an
|
|
|
|
explicit grant from the SFTPGo Team (support@sftpgo.com).
|
2022-07-17 18:16:00 +00:00
|
|
|
-->
|
2021-11-06 13:13:20 +00:00
|
|
|
{{template "base" .}}
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- define "page_body"}}
|
|
|
|
<div class="card shadow-sm">
|
|
|
|
<div class="card-header bg-light">
|
2023-12-26 07:59:52 +00:00
|
|
|
<h3 {{if .IsAdd}}data-i18n="title.add_share"{{else}}data-i18n="title.update_share"{{end}} class="card-title section-title"></h3>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- template "errmsg" .Error}}
|
2021-11-06 13:13:20 +00:00
|
|
|
<form id="share_form" action="{{.CurrentURL}}" method="POST" autocomplete="off">
|
|
|
|
<div class="form-group row">
|
2023-12-13 17:03:42 +00:00
|
|
|
<label for="name" data-i18n="general.name" class="col-md-3 col-form-label">Name</label>
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="col-md-9">
|
2023-12-13 17:03:42 +00:00
|
|
|
<input id="name" type="text" class="form-control" placeholder="" name="name" value="{{.Share.Name}}"
|
2024-01-09 18:54:08 +00:00
|
|
|
maxlength="255" autocomplete="off" required {{if not .IsAdd}}readonly{{end}} />
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="form-group row mt-10">
|
2023-12-13 17:03:42 +00:00
|
|
|
<label for="scope" data-i18n="share.scope" class="col-md-3 col-form-label">Scope</label>
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="col-md-9">
|
2024-01-09 18:54:08 +00:00
|
|
|
<select id="scope" name="scope" class="form-select" data-control="i18n-select2" data-hide-search="true" aria-describedby="scopeHelp">
|
2023-12-10 15:40:13 +00:00
|
|
|
<option data-i18n="share.scope_read" value="1" {{if eq .Share.Scope 1 }}selected{{end}}>Read</option>
|
|
|
|
<option data-i18n="share.scope_write" value="2" {{if eq .Share.Scope 2 }}selected{{end}}>Write</option>
|
|
|
|
<option data-i18n="share.scope_read_write" value="3" {{if eq .Share.Scope 3 }}selected{{end}}>Read/Write</option>
|
2021-11-06 13:13:20 +00:00
|
|
|
</select>
|
2024-01-09 18:54:08 +00:00
|
|
|
<div id="scopeHelp" data-i18n="share.scope_help" class="form-text">
|
2023-12-10 15:40:13 +00:00
|
|
|
For scope "Write" and "Read/Write" you have to define one path and it must be a directory
|
2023-11-04 09:54:52 +00:00
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2024-01-09 18:54:08 +00:00
|
|
|
<div class="card mt-10">
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="card-header bg-light">
|
2023-12-26 07:59:52 +00:00
|
|
|
<h3 data-i18n="share.paths" class="card-title section-title-inner">Paths</h3>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
2023-11-04 09:54:52 +00:00
|
|
|
<div id="paths">
|
|
|
|
<div class="form-group">
|
|
|
|
<div data-repeater-list="paths">
|
|
|
|
{{- range $idx, $val := .Share.Paths}}
|
|
|
|
<div data-repeater-item>
|
|
|
|
<div class="form-group row">
|
2024-01-09 18:54:08 +00:00
|
|
|
<div class="col-md-9 mt-3 mt-md-8">
|
|
|
|
<input data-i18n="[placeholder]share.path_help" type="text" class="form-control"
|
2023-11-04 09:54:52 +00:00
|
|
|
name="path" value="{{$val}}" />
|
|
|
|
</div>
|
2024-01-09 18:54:08 +00:00
|
|
|
<div class="col-md-3 mt-3 mt-md-8">
|
2024-01-01 19:09:15 +00:00
|
|
|
<a href="#" data-repeater-delete
|
2024-01-09 18:54:08 +00:00
|
|
|
class="btn btn-light-danger">
|
2023-11-04 09:54:52 +00:00
|
|
|
<i class="ki-duotone ki-trash fs-5">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
<span class="path3"></span>
|
|
|
|
<span class="path4"></span>
|
|
|
|
<span class="path5"></span>
|
|
|
|
</i>
|
2024-01-01 19:09:15 +00:00
|
|
|
<span data-i18n="general.delete">Delete</span>
|
2023-11-04 09:54:52 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- else}}
|
|
|
|
<div data-repeater-item>
|
|
|
|
<div class="form-group row">
|
2024-01-09 18:54:08 +00:00
|
|
|
<div class="col-md-9 mt-3 mt-md-8">
|
|
|
|
<input data-i18n="[placeholder]share.path_help" type="text" class="form-control"
|
2023-11-04 09:54:52 +00:00
|
|
|
name="path" value="" />
|
|
|
|
</div>
|
2024-01-09 18:54:08 +00:00
|
|
|
<div class="col-md-3 mt-3 mt-md-8">
|
2024-01-01 19:09:15 +00:00
|
|
|
<a href="#" data-repeater-delete
|
2024-01-09 18:54:08 +00:00
|
|
|
class="btn btn-light-danger">
|
2023-11-04 09:54:52 +00:00
|
|
|
<i class="ki-duotone ki-trash fs-5">
|
|
|
|
<span class="path1"></span>
|
|
|
|
<span class="path2"></span>
|
|
|
|
<span class="path3"></span>
|
|
|
|
<span class="path4"></span>
|
|
|
|
<span class="path5"></span>
|
|
|
|
</i>
|
2024-01-01 19:09:15 +00:00
|
|
|
<span data-i18n="general.delete">Delete</span>
|
2023-11-04 09:54:52 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- end}}
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="form-group mt-5">
|
2024-01-01 19:09:15 +00:00
|
|
|
<a href="#" data-repeater-create class="btn btn-light-primary">
|
2023-11-04 09:54:52 +00:00
|
|
|
<i class="ki-duotone ki-plus fs-3"></i>
|
2024-01-01 19:09:15 +00:00
|
|
|
<span data-i18n="general.add">Add</span>
|
2023-11-04 09:54:52 +00:00
|
|
|
</a>
|
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="form-group row mt-10">
|
2023-12-13 17:03:42 +00:00
|
|
|
<label for="password" data-i18n="login.password" class="col-md-3 col-form-label">Password</label>
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="col-md-9">
|
2024-01-21 16:39:08 +00:00
|
|
|
<input id="password" type="password" class="form-control" name="password" autocomplete="new-password"
|
2024-01-09 18:54:08 +00:00
|
|
|
placeholder="" spellcheck="false" value="{{.Share.Password}}" aria-describedby="passwordHelp" />
|
|
|
|
<div id="passwordHelp" data-i18n="share.password_help" class="form-text">
|
2021-11-06 13:13:20 +00:00
|
|
|
If set the share will be password-protected
|
2023-11-04 09:54:52 +00:00
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="form-group row mt-10">
|
2024-01-09 18:54:08 +00:00
|
|
|
<label for="id_expiration" data-i18n="general.expiration" class="col-md-3 col-form-label">Expiration</label>
|
2023-11-22 19:14:49 +00:00
|
|
|
<div class="col-md-9 d-flex">
|
2024-01-09 18:54:08 +00:00
|
|
|
<input data-i18n="[placeholder]general.expiration_help" id="id_expiration" class="form-control" placeholder="Pick an expiration date" />
|
2023-11-22 19:14:49 +00:00
|
|
|
<button class="btn btn-icon btn-light-danger ms-2 d-none" id="id_expiration_clear">
|
2023-12-26 07:59:52 +00:00
|
|
|
<i class="ki-solid ki-cross fs-1"></i>
|
2023-11-22 19:14:49 +00:00
|
|
|
</button>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="form-group row mt-10">
|
2023-12-13 17:03:42 +00:00
|
|
|
<label for="max_tokens" data-i18n="share.max_tokens" class="col-md-3 col-form-label">Max tokens</label>
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="col-md-9">
|
2024-01-09 18:54:08 +00:00
|
|
|
<input id="max_tokens" type="number" min="0" class="form-control" name="max_tokens" value="{{.Share.MaxTokens}}" aria-describedby="max_tokens_help" />
|
|
|
|
<div id="max_tokens_help" data-i18n="share.max_tokens_help" class="form-text">
|
2021-11-06 13:13:20 +00:00
|
|
|
Maximum number of times this share can be accessed. 0 means no limit
|
2023-11-04 09:54:52 +00:00
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="form-group row mt-10">
|
2023-12-13 17:03:42 +00:00
|
|
|
<label for="allowed_ip" data-i18n="general.allowed_ip_mask" class="col-md-3 col-form-label">Allowed IP/Mask</label>
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="col-md-9">
|
2024-01-09 18:54:08 +00:00
|
|
|
<textarea id="allowed_ip" class="form-control" name="allowed_ip" rows="3" aria-describedby="allowed_ip_help"
|
2023-11-04 09:54:52 +00:00
|
|
|
placeholder="">{{.Share.GetAllowedFromAsString}}</textarea>
|
2024-01-09 18:54:08 +00:00
|
|
|
<div id="allowed_ip_help" data-i18n="general.ip_mask_help" class="form-text">
|
2021-11-06 13:13:20 +00:00
|
|
|
Comma separated IP/Mask in CIDR format, for example "192.168.1.0/24,10.8.0.100/32"
|
2023-11-04 09:54:52 +00:00
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="form-group row mt-10">
|
2023-12-13 17:03:42 +00:00
|
|
|
<label for="description" data-i18n="general.description" class="col-md-3 col-form-label">Description</label>
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="col-md-9">
|
2023-12-13 17:03:42 +00:00
|
|
|
<textarea id="description" class="form-control" name="description" rows="3"
|
2023-11-04 09:54:52 +00:00
|
|
|
placeholder="">{{.Share.Description}}</textarea>
|
2021-11-06 13:13:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
<div class="d-flex justify-content-end mt-12">
|
|
|
|
<input type="hidden" name="expiration_date" id="hidden_start_datetime" value="">
|
|
|
|
<input type="hidden" name="_form_token" value="{{.CSRFToken}}">
|
|
|
|
<button type="submit" id="form_submit" class="btn btn-primary px-10">
|
2023-12-10 15:40:13 +00:00
|
|
|
<span data-i18n="general.submit" class="indicator-label">
|
2023-11-04 09:54:52 +00:00
|
|
|
Submit
|
|
|
|
</span>
|
2023-12-10 15:40:13 +00:00
|
|
|
<span data-i18n="general.wait" class="indicator-progress">
|
|
|
|
Please wait...
|
|
|
|
<span class="spinner-border spinner-border-sm align-middle ms-2"></span>
|
2023-11-04 09:54:52 +00:00
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
2021-11-06 13:13:20 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- end}}
|
2021-11-06 13:13:20 +00:00
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- define "extra_js"}}
|
2023-11-21 15:24:43 +00:00
|
|
|
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/plugins/custom/formrepeater/formrepeater.bundle.js"></script>
|
2023-12-13 17:03:42 +00:00
|
|
|
<script {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}} src="{{.StaticURL}}/assets/plugins/custom/flatpickr/l10n/it.js"></script>
|
2023-11-15 17:48:16 +00:00
|
|
|
<script type="text/javascript" {{- if .CSPNonce}} nonce="{{.CSPNonce}}"{{- end}}>
|
2023-12-10 15:40:13 +00:00
|
|
|
$(document).on("i18nshow", function(){
|
2023-11-16 17:55:14 +00:00
|
|
|
initRepeater('#paths');
|
|
|
|
initRepeaterItems();
|
2023-11-04 09:54:52 +00:00
|
|
|
|
2023-11-22 19:14:49 +00:00
|
|
|
const picker = $('#id_expiration').flatpickr({
|
|
|
|
enableTime: false,
|
|
|
|
time_24hr: true,
|
2023-12-10 15:40:13 +00:00
|
|
|
formatDate: (date, format, locale) => {
|
|
|
|
return $.t('general.datetime', {
|
|
|
|
val: new Date(date),
|
|
|
|
formatParams: {
|
|
|
|
val: { year: 'numeric', month: 'numeric', day: 'numeric' },
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2023-11-22 19:14:49 +00:00
|
|
|
defaultHour: 23,
|
|
|
|
defaultMinute: 59,
|
2023-12-26 07:59:52 +00:00
|
|
|
locale: i18next.resolvedLanguage,
|
2023-11-22 19:14:49 +00:00
|
|
|
onChange: function(selectedDates, dateStr, instance) {
|
|
|
|
if (selectedDates.length > 0){
|
|
|
|
$('#id_expiration_clear').removeClass("d-none");
|
|
|
|
} else {
|
|
|
|
$('#id_expiration_clear').addClass("d-none");
|
|
|
|
}
|
2023-11-04 09:54:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
//{{ if gt .Share.ExpiresAt 0 }}
|
2023-11-22 19:14:49 +00:00
|
|
|
let input_dt = moment('{{.Share.ExpiresAt }}', 'x').format('YYYY-MM-DD');
|
|
|
|
picker.setDate(input_dt, true);
|
2023-11-04 09:54:52 +00:00
|
|
|
//{{ end }}
|
|
|
|
|
2023-11-22 19:14:49 +00:00
|
|
|
$('#id_expiration_clear').on("click", function(e){
|
|
|
|
e.preventDefault();
|
|
|
|
picker.clear();
|
|
|
|
});
|
|
|
|
|
2023-11-04 09:54:52 +00:00
|
|
|
$("#share_form").submit(function (event) {
|
2023-11-22 19:14:49 +00:00
|
|
|
$('#hidden_start_datetime').val("");
|
|
|
|
let dt = picker.selectedDates;
|
|
|
|
if (dt.length > 0) {
|
|
|
|
let d = dt[0];
|
2023-11-04 09:54:52 +00:00
|
|
|
if (d) {
|
|
|
|
let dateString = moment.utc(d).format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
$('#hidden_start_datetime').val(dateString);
|
|
|
|
}
|
2021-11-06 13:13:20 +00:00
|
|
|
}
|
2023-11-04 09:54:52 +00:00
|
|
|
let submitButton = document.querySelector('#form_submit');
|
|
|
|
submitButton.setAttribute('data-kt-indicator', 'on');
|
|
|
|
submitButton.disabled = true;
|
|
|
|
});
|
2021-11-06 13:13:20 +00:00
|
|
|
});
|
|
|
|
</script>
|
2023-11-04 09:54:52 +00:00
|
|
|
{{- end}}
|