mirror of
https://github.com/domfelipe/controle-inventario.git
synced 2026-08-07 05:26:47 +00:00
Add files via upload
This commit is contained in:
parent
5ee84c8528
commit
5732988428
3 changed files with 165744 additions and 0 deletions
23
09042025-xlsx-json.py
Normal file
23
09042025-xlsx-json.py
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import openpyxl
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
input_file = 'C:\\Users\\fdomingues\\JCDECAUX\\BR - Dados - Documentos\\01. Soluções\\MAPA OOH Live\\01. Projetos\\01. Praças\\01. Atualização Inventario (Todas as Praças)\\database_frontend.xlsx'
|
||||||
|
output_file = 'C:\\Users\\fdomingues\\JCDECAUX\\BR - Dados - Documentos\\01. Soluções\\MAPA OOH Live\\01. Projetos\\01. Praças\\01. Atualização Inventario (Todas as Praças)\\database_frontend.json'
|
||||||
|
|
||||||
|
workbook = openpyxl.load_workbook(input_file)
|
||||||
|
sheet = workbook.active
|
||||||
|
|
||||||
|
headers = list(next(sheet.iter_rows(min_row=1, max_row=1, values_only=True)))
|
||||||
|
|
||||||
|
data = []
|
||||||
|
for row in sheet.iter_rows(min_row=2, values_only=True):
|
||||||
|
row_dict = {}
|
||||||
|
for header, value in zip(headers, row):
|
||||||
|
row_dict[header] = value if value is not None else ""
|
||||||
|
data.append(row_dict)
|
||||||
|
|
||||||
|
with open(output_file, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||||
|
|
||||||
|
print(f"Arquivo convertido com sucesso para {output_file}")
|
||||||
165629
database_frontend.json
Normal file
165629
database_frontend.json
Normal file
File diff suppressed because it is too large
Load diff
92
index.html
Normal file
92
index.html
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pt-BR">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Controle de Inventário</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
}
|
||||||
|
.traffic-light {
|
||||||
|
display: inline-block;
|
||||||
|
width: 15px;
|
||||||
|
height: 15px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
.ok {
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
|
.nok {
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Controle de Inventário</h1>
|
||||||
|
<div id="tableContainer">Carregando base de dados...</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Caminho relativo para o arquivo JSON hospedado no mesmo domínio (GitHub Pages)
|
||||||
|
const fileUrl = './database.json';
|
||||||
|
|
||||||
|
fetch(fileUrl)
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Erro na requisição: ' + response.statusText);
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then(data => generateTable(data))
|
||||||
|
.catch(error => {
|
||||||
|
console.error("Erro ao carregar o arquivo JSON:", error);
|
||||||
|
document.getElementById('tableContainer').innerText = "Erro ao carregar a base de dados.";
|
||||||
|
});
|
||||||
|
|
||||||
|
function generateTable(data) {
|
||||||
|
let html = '<table>';
|
||||||
|
|
||||||
|
// Se há dados, cria um cabeçalho com as chaves do primeiro objeto
|
||||||
|
if (data.length > 0) {
|
||||||
|
html += '<thead><tr>';
|
||||||
|
for (const key in data[0]) {
|
||||||
|
html += '<th>' + key + '</th>';
|
||||||
|
}
|
||||||
|
html += '</tr></thead>';
|
||||||
|
}
|
||||||
|
|
||||||
|
html += '<tbody>';
|
||||||
|
data.forEach(row => {
|
||||||
|
html += '<tr>';
|
||||||
|
for (const key in row) {
|
||||||
|
let cellValue = row[key];
|
||||||
|
// Se for a coluna "OK/NOK": insere o semáforo
|
||||||
|
if (key.trim().toUpperCase() === 'OK/NOK') {
|
||||||
|
cellValue = '<div class="traffic-light ' +
|
||||||
|
(cellValue.toString().trim().toUpperCase() === 'OK' ? 'ok' : 'nok') +
|
||||||
|
'"></div>';
|
||||||
|
}
|
||||||
|
html += '<td>' + cellValue + '</td>';
|
||||||
|
}
|
||||||
|
html += '</tr>';
|
||||||
|
});
|
||||||
|
html += '</tbody></table>';
|
||||||
|
|
||||||
|
document.getElementById('tableContainer').innerHTML = html;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue