mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-15 03:51:51 +00:00
40 lines
1.3 KiB
HTML
Executable file
40 lines
1.3 KiB
HTML
Executable file
<div style="display: inline-block;">
|
|
<input type="button"" class="btn cbi-button cbi-button-add" id="btnload" name="load" value="<%:Load%>" <% if self.disable then %>disabled <% end %>/>
|
|
<input type="file" id="file_load" style="visibility:hidden; position: absolute;top: 0px; left: 0px;" accept="application/x-tar" />
|
|
</div>
|
|
<script type="text/javascript">
|
|
let btnLoad = document.getElementById('btnload')
|
|
btnLoad.onclick = function (e) {
|
|
document.getElementById("file_load").click()
|
|
e.preventDefault()
|
|
}
|
|
|
|
let fileLoad = document.getElementById('file_load')
|
|
fileLoad.onchange = function(e){
|
|
let fileLoad = document.getElementById('file_load')
|
|
if (!fileLoad.value) {
|
|
return
|
|
}
|
|
let fileName = fileLoad.files[0].name
|
|
let formData = new FormData()
|
|
formData.append('upload-filename', fileName)
|
|
formData.append('upload-archive', fileLoad.files[0])
|
|
let xhr = new XMLHttpRequest()
|
|
xhr.open("POST", '<%=luci.dispatcher.build_url("admin/docker/images_load")%>', true)
|
|
xhr.onload = function() {
|
|
if (xhr.status == 200) {
|
|
docker_status_message('notice', xhr.statusText)
|
|
function sleep(time) {
|
|
return new Promise((resolve) => setTimeout(resolve, time))
|
|
}
|
|
sleep(1500).then(() => {
|
|
location.reload()
|
|
})
|
|
} else {
|
|
location.reload()
|
|
}
|
|
}
|
|
uci_confirm_docker()
|
|
xhr.send(formData)
|
|
}
|
|
</script>
|