WebClient: make the keep alive interval configurable

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2025-01-22 19:41:31 +01:00
parent 6ab0f22d2d
commit 61aef41bee
2 changed files with 6 additions and 2 deletions

View File

@@ -145,6 +145,7 @@ type filesPage struct {
Error *util.I18nError
Paths []dirMapping
QuotaUsage *userQuotaUsage
KeepAliveInterval int
}
type shareLoginPage struct {
@@ -781,6 +782,7 @@ func (s *httpdServer) renderSharedFilesPage(w http.ResponseWriter, r *http.Reque
CanCopy: false,
Paths: getDirMapping(dirName, currentURL),
QuotaUsage: newUserQuotaUsage(&dataprovider.User{}),
KeepAliveInterval: int(cookieRefreshThreshold / time.Millisecond),
}
renderClientTemplate(w, templateClientFiles, data)
}
@@ -837,6 +839,7 @@ func (s *httpdServer) renderFilesPage(w http.ResponseWriter, r *http.Request, di
ShareUploadBaseURL: "",
Paths: getDirMapping(dirName, webClientFilesPath),
QuotaUsage: newUserQuotaUsage(user),
KeepAliveInterval: int(cookieRefreshThreshold / time.Millisecond),
}
renderClientTemplate(w, templateClientFiles, data)
}

View File

@@ -263,6 +263,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
"mscgen", "mscin", "msc", "xu", "msgenny", "wat", "wast", "env"];
const supportedEditFilenames = ["readme", "dockerfile", "pkgbuild"];
//{{- end}}
const keepAliveInterval = '{{.KeepAliveInterval}}';
function keepAlive() {
//{{- if not .ShareUploadBaseURL}}
axios.get('{{.PingURL}}',{
@@ -1974,7 +1975,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
function uploadFiles(files) {
keepAlive();
let keepAliveTimer = setInterval(keepAlive, 300000);
let keepAliveTimer = setInterval(keepAlive, keepAliveInterval);
let has_errors = false;
let index = 0;
@@ -2189,7 +2190,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
$("#video_player").get(0).load();
$('#modal_video_player').modal('show');
keepAlive();
playerKeepAlive = setInterval(keepAlive, 300000);
playerKeepAlive = setInterval(keepAlive, keepAliveInterval);
}
$(document).on("i18nshow", function(){