mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-06-05 19:49:33 +00:00
Added file transfer from web to flask server
This commit is contained in:
@@ -1,19 +1,24 @@
|
||||
html, body, .container {
|
||||
html, body, .my-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 20px;
|
||||
html {
|
||||
height: calc(100% - 56px);
|
||||
}
|
||||
|
||||
.my-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
height: 100%;
|
||||
width: 70%;
|
||||
height: calc(100% - 40px);
|
||||
width: calc(70% - 40px);
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.button {
|
||||
@@ -29,8 +34,18 @@ body {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
padding: 0 0 15px 20px;
|
||||
}
|
||||
|
||||
.action-container button {
|
||||
margin: 10px;
|
||||
.action-container .my-label {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.action-container .btn-group {
|
||||
padding-top: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.btn-group button {
|
||||
width: 100%;
|
||||
}
|
||||
93
Server/static/css/spinner.css
Normal file
93
Server/static/css/spinner.css
Normal file
@@ -0,0 +1,93 @@
|
||||
.lds-spinner {
|
||||
color: official;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.lds-spinner div {
|
||||
transform-origin: 20px 20px;
|
||||
animation: lds-spinner 1.2s linear infinite;
|
||||
}
|
||||
|
||||
.lds-spinner div:after {
|
||||
content: " ";
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 25px;
|
||||
width: 3px;
|
||||
height: 10px;
|
||||
border-radius: 20%;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(1) {
|
||||
transform: rotate(0deg);
|
||||
animation-delay: -1.1s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(2) {
|
||||
transform: rotate(30deg);
|
||||
animation-delay: -1s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(3) {
|
||||
transform: rotate(60deg);
|
||||
animation-delay: -0.9s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(4) {
|
||||
transform: rotate(90deg);
|
||||
animation-delay: -0.8s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(5) {
|
||||
transform: rotate(120deg);
|
||||
animation-delay: -0.7s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(6) {
|
||||
transform: rotate(150deg);
|
||||
animation-delay: -0.6s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(7) {
|
||||
transform: rotate(180deg);
|
||||
animation-delay: -0.5s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(8) {
|
||||
transform: rotate(210deg);
|
||||
animation-delay: -0.4s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(9) {
|
||||
transform: rotate(240deg);
|
||||
animation-delay: -0.3s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(10) {
|
||||
transform: rotate(270deg);
|
||||
animation-delay: -0.2s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(11) {
|
||||
transform: rotate(300deg);
|
||||
animation-delay: -0.1s;
|
||||
}
|
||||
|
||||
.lds-spinner div:nth-child(12) {
|
||||
transform: rotate(330deg);
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
@keyframes lds-spinner {
|
||||
0% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
55
Server/static/js/file.js
Normal file
55
Server/static/js/file.js
Normal file
@@ -0,0 +1,55 @@
|
||||
let animationInput = document.getElementById('animationFile');
|
||||
let configInput = document.getElementById('configFile');
|
||||
let arucoInput = document.getElementById('arucoFile');
|
||||
|
||||
animationInput.onchange = function (e) {
|
||||
document.getElementById('animationFileLabel').innerText = animationInput.files[0].name;
|
||||
};
|
||||
configInput.onchange = function (e) {
|
||||
document.getElementById('configFileLabel').innerText = configInput.files[0].name;
|
||||
};
|
||||
arucoInput.onchange = function (e) {
|
||||
document.getElementById('arucoFileLabel').innerText = arucoInput.files[0].name;
|
||||
};
|
||||
|
||||
function sendRows(selectedRows) {
|
||||
var animationFile = animationInput.files[0];
|
||||
var configFile = configInput.files[0];
|
||||
var arucoFile = arucoInput.files[0];
|
||||
spinner.style.display = 'inline-block';
|
||||
setTimeout(function () {
|
||||
selectedRows.forEach(function (element) {
|
||||
if (animationFile) {
|
||||
let animReq = new XMLHttpRequest();
|
||||
let animFormData = new FormData();
|
||||
animFormData.append("file", animationFile);
|
||||
animReq.open("POST", '/set/animation?ip=' + element._row.data.ip, false);
|
||||
animReq.send(animFormData);
|
||||
}
|
||||
if (configFile) {
|
||||
let configReq = new XMLHttpRequest();
|
||||
let congifFormData = new FormData();
|
||||
congifFormData.append("file", configFile);
|
||||
configReq.open("POST", '/set/config?ip=' + element._row.data.ip, false);
|
||||
configReq.send(congifFormData);
|
||||
}
|
||||
if (arucoFile) {
|
||||
let arucoReq = new XMLHttpRequest();
|
||||
let arucoFormData = new FormData();
|
||||
arucoFormData.append("file", arucoFile);
|
||||
arucoReq.open("POST", '/set/animation?ip=' + element._row.data.ip, false);
|
||||
arucoReq.send(arucoFormData);
|
||||
}
|
||||
element.deselect();
|
||||
});
|
||||
spinner.style.display = 'none';
|
||||
}, 20);
|
||||
}
|
||||
|
||||
function sendSelected() {
|
||||
sendRows(table.getSelectedRows());
|
||||
}
|
||||
|
||||
function sendAll() {
|
||||
sendRows(table.getRows());
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
let spinner = document.getElementById('spinner');
|
||||
var tabledata = [];
|
||||
updateData();
|
||||
|
||||
@@ -11,6 +12,7 @@ function updateData() {
|
||||
var table = new Tabulator("#copters-table", {
|
||||
data: tabledata,
|
||||
reactiveData: true,
|
||||
selectable: true,
|
||||
layout: "fitColumns",
|
||||
columns: [
|
||||
{title: "Name", field: "name"},
|
||||
@@ -22,3 +24,28 @@ var table = new Tabulator("#copters-table", {
|
||||
{title: "Time", field: "time"},
|
||||
],
|
||||
});
|
||||
|
||||
function refreshRows(selectedRows) {
|
||||
spinner.style.display = 'inline-block';
|
||||
setTimeout(function () {
|
||||
selectedRows.forEach(function (element) {
|
||||
let req = new XMLHttpRequest();
|
||||
req.open('POST', '/selfcheck/selected?ip=' + element._row.data.ip, false);
|
||||
req.send();
|
||||
element.deselect();
|
||||
let response = JSON.parse(req.response);
|
||||
Object.keys(response).forEach(function (item) {
|
||||
element._row.data[item] = response[item];
|
||||
});
|
||||
});
|
||||
spinner.style.display = 'none';
|
||||
}, 20);
|
||||
}
|
||||
|
||||
function refreshSelected() {
|
||||
refreshRows(table.getSelectedRows());
|
||||
}
|
||||
|
||||
function refreshAll() {
|
||||
refreshRows(table.getRows());
|
||||
}
|
||||
Reference in New Issue
Block a user