2 <div id=
"upload-container" class=
"cbi-value cbi-value-last">
3 <label class=
"cbi-value-title" for=
"archive"><%:Upload%
></label>
4 <div class=
"cbi-value-field">
5 <input type=
"file" name=
"upload_archive" accept=
"application/x-tar" id=
"upload_archive" />
8 <label class=
"cbi-value-title" for=
"path"><%:Path%
></label>
9 <div class=
"cbi-value-field">
10 <input type=
"text" class=
"cbi-input-text" name=
"path" value=
"/tmp/" id=
"path" />
13 <div class=
"cbi-value-field">
14 <input type=
"button"" class="cbi-button cbi-button-action important
" id="upload
" name="upload
" value="<%:Upload%
>" />
15 <input type="button
"" class=
"cbi-button cbi-button-action important" id=
"download" name=
"download" value=
"<%:Download%>" />
18 <script type=
"text/javascript">
19 let btnUpload = document.getElementById('upload')
20 btnUpload.onclick = function (e) {
21 let uploadArchive = document.getElementById('upload_archive')
22 let uploadPath = document.getElementById('path').value
23 if (!uploadArchive.value || !uploadPath) {
24 docker_status_message('warning',
"<%:Please input the PATH and select the file !%>")
25 document.getElementById('docker_apply_overlay').addEventListener(
"click", (e)=
>{
26 docker_status_message()
30 let fileName = uploadArchive.files[
0].name
31 let formData = new FormData()
32 formData.append('upload-filename', fileName)
33 formData.append('upload-path', uploadPath)
34 formData.append('upload-archive', uploadArchive.files[
0])
35 let xhr = new XMLHttpRequest()
36 xhr.open(
"POST", '<%=luci.dispatcher.build_url(
"admin/docker/container_put_archive")%
>/<%=self.container%
>', true)
37 xhr.onload = function() {
38 if (xhr.status ==
200) {
39 uploadArchive.value = ''
40 docker_status_message('notice',
"<%:Upload Success%>")
43 docker_status_message('warning',
"<%:Upload Error%>:" + xhr.statusText)
45 document.getElementById('docker_apply_overlay').addEventListener(
"click", (e)=
>{
46 docker_status_message()
51 let btnDownload = document.getElementById('download')
52 btnDownload.onclick = function (e) {
53 let downloadPath = document.getElementById('path').value
55 docker_status_message('warning',
"<%:Please input the PATH !%>")
56 document.getElementById('docker_apply_overlay').addEventListener(
"click", (e)=
>{
57 docker_status_message()
61 window.open('<%=luci.dispatcher.build_url(
"admin/docker/container_get_archive")%
>?id=<%=self.container%
>&path=' + encodeURIComponent(downloadPath))