luci-app-statistics: add missing ValuesPercentage option
[project/luci.git] / applications / luci-app-dockerman / luasrc / view / dockerman / container_file.htm
1
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" />
6 </div>
7 <br>
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" />
11 </div>
12 <br>
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%>" />
16 </div>
17 </div>
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()
27 })
28 return
29 }
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%>")
41 }
42 else {
43 docker_status_message('warning', "<%:Upload Error%>:" + xhr.statusText)
44 }
45 document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
46 docker_status_message()
47 })
48 }
49 xhr.send(formData)
50 }
51 let btnDownload = document.getElementById('download')
52 btnDownload.onclick = function (e) {
53 let downloadPath = document.getElementById('path').value
54 if (!downloadPath) {
55 docker_status_message('warning', "<%:Please input the PATH !%>")
56 document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
57 docker_status_message()
58 })
59 return
60 }
61 window.open('<%=luci.dispatcher.build_url("admin/docker/container_get_archive")%>?id=<%=self.container%>&path=' + encodeURIComponent(downloadPath))
62 }
63 </script>