luci-app-statistics: add missing ValuesPercentage option
[project/luci.git] / applications / luci-app-dockerman / luasrc / view / dockerman / images_import.htm
1 <input type="text" class="cbi-input-text" name="isrc" placeholder="http://host/image.tar" id="isrc" />
2 <input type="text" class="cbi-input-text" name="itag" placeholder="repository:tag" id="itag" />
3 <div style="display: inline-block;">
4 <input type="button"" class=" cbi-button cbi-button-add" id="btnimport" name="import" value="<%:Import%>" />
5 <input type="file" id="file_import" style="visibility:hidden; position: absolute;top: 0px; left: 0px;" />
6 </div>
7
8 <script type="text/javascript">
9 let btnImport = document.getElementById('btnimport')
10 let valISrc = document.getElementById('isrc')
11 let valITag = document.getElementById('itag')
12 btnImport.onclick = function (e) {
13 if (valISrc.value == "") {
14 document.getElementById("file_import").click()
15 return
16 } else {
17 let formData = new FormData()
18 formData.append('src', valISrc.value)
19 formData.append('tag', valITag.value)
20 let xhr = new XMLHttpRequest()
21 uci_confirm_docker()
22 xhr.open("POST", "<%=luci.dispatcher.build_url('admin/docker/images_import')%>", true)
23 xhr.onload = function () {
24 location.reload()
25 }
26 xhr.send(formData)
27 }
28 }
29 let fileimport = document.getElementById('file_import')
30 fileimport.onchange = function (e) {
31 let fileimport = document.getElementById('file_import')
32 if (!fileimport.value) {
33 return
34 }
35 let valITag = document.getElementById('itag')
36 let fileName = fileimport.files[0].name
37 let formData = new FormData()
38 formData.append('upload-filename', fileName)
39 formData.append('tag', valITag.value)
40 formData.append('upload-archive', fileimport.files[0])
41 let xhr = new XMLHttpRequest()
42 uci_confirm_docker()
43 xhr.open("POST", "<%=luci.dispatcher.build_url('admin/docker/images_import')%>", true)
44 xhr.onload = function () {
45 fileimport.value = ''
46 location.reload()
47 }
48 xhr.send(formData)
49 }
50
51 let new_tag = function (image_id) {
52 let new_tag = prompt("<%:New tag%>\n<%:Image%>" + "ID: " + image_id + "\n<%:Please input new tag%>:", "")
53 if (new_tag) {
54 (new XHR()).post("<%=luci.dispatcher.build_url('admin/docker/images_tag')%>",
55 { id: image_id, tag: new_tag },
56 function (r) {
57 if (r.status == 201) {
58 location.reload()
59 }
60 else {
61 docker_status_message('warning', 'Image: untagging ' + tag + '...fail code:' + r.status + r.statusText);
62 document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
63 docker_status_message()
64 })
65 }
66 })
67 }
68 }
69
70 let un_tag = function (tag) {
71 if (tag.match("<none>")) return
72 if (confirm("<%:Remove tag%>: " + tag + " ?")) {
73 (new XHR()).post("<%=luci.dispatcher.build_url('admin/docker/images_untag')%>",
74 { tag: tag },
75 function (r) {
76 if (r.status == 200) {
77 location.reload()
78 }
79 else {
80 docker_status_message('warning', 'Image: untagging ' + tag + '...fail code:' + r.status + r.statusText);
81 document.getElementById('docker_apply_overlay').addEventListener("click", (e)=>{
82 docker_status_message()
83 })
84 }
85 })
86 }
87 }
88 </script>