diff options
Diffstat (limited to 'applications/luci-app-dockerman/luasrc/view/dockerman/container_file.htm')
-rw-r--r-- | applications/luci-app-dockerman/luasrc/view/dockerman/container_file.htm | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/applications/luci-app-dockerman/luasrc/view/dockerman/container_file.htm b/applications/luci-app-dockerman/luasrc/view/dockerman/container_file.htm new file mode 100644 index 000000000..c0778329f --- /dev/null +++ b/applications/luci-app-dockerman/luasrc/view/dockerman/container_file.htm @@ -0,0 +1,63 @@ + +<div id="upload-container" class="cbi-value cbi-value-last"> + <label class="cbi-value-title" for="archive"><%:Upload%></label> + <div class="cbi-value-field"> + <input type="file" name="upload_archive" accept="application/x-tar" id="upload_archive" /> + </div> + <br> + <label class="cbi-value-title" for="path"><%:Path%></label> + <div class="cbi-value-field"> + <input type="text" class="cbi-input-text" name="path" value="/tmp/" id="path" /> + </div> + <br> + <div class="cbi-value-field"> + <input type="button"" class="cbi-button cbi-button-action important" id="upload" name="upload" value="<%:Upload%>" /> + <input type="button"" class="cbi-button cbi-button-action important" id="download" name="download" value="<%:Download%>" /> + </div> +</div> +<script type="text/javascript"> + let btnUpload = document.getElementById('upload') + btnUpload.onclick = function (e) { + let uploadArchive = document.getElementById('upload_archive') + let uploadPath = document.getElementById('path').value + if (!uploadArchive.value || !uploadPath) { + docker_status_message('warning', "<%:Please input the PATH and select the file !%>") + document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{ + docker_status_message() + }) + return + } + let fileName = uploadArchive.files[0].name + let formData = new FormData() + formData.append('upload-filename', fileName) + formData.append('upload-path', uploadPath) + formData.append('upload-archive', uploadArchive.files[0]) + let xhr = new XMLHttpRequest() + xhr.open("POST", '<%=luci.dispatcher.build_url("admin/docker/container_put_archive")%>/<%=self.container%>', true) + xhr.onload = function() { + if (xhr.status == 200) { + uploadArchive.value = '' + docker_status_message('notice', "<%:Upload Success%>") + } + else { + docker_status_message('warning', "<%:Upload Error%>:" + xhr.statusText) + } + document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{ + docker_status_message() + }) + } + xhr.send(formData) + } + let btnDownload = document.getElementById('download') + btnDownload.onclick = function (e) { + let downloadPath = document.getElementById('path').value + if (!downloadPath) { + docker_status_message('warning', "<%:Please input the PATH !%>") + document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{ + docker_status_message() + }) + return + } + window.open('<%=luci.dispatcher.build_url("admin/docker/container_get_archive")%>?id=<%=self.container%>&path=' + encodeURIComponent(downloadPath)) + } +</script> |