This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aggiunta ed ultimata funzione di elimnazione dei dati inseriti
- Loading branch information
1 parent
35ed121
commit f7444c2
Showing
11 changed files
with
244 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Gym Utils</title> | ||
<link rel="stylesheet" href="index.css"> | ||
<script defer src="delete.js"></script> | ||
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css"> | ||
</head> | ||
<body> | ||
<div class="container is-fluid"> | ||
|
||
|
||
<div class="tabs is-centered"> | ||
<ul> | ||
<li id="addTab"><a>Aggiungi</a></li> | ||
<li id="visualizeTab" ><a>Visualizza</a></li> | ||
<li id="editTab" ><a>Modifica</a></li> | ||
<li id="deleteTab" class="is-active"><a>Elimina</a></li> | ||
<li id="settingsTab"><a>Impostazioni</a></li> | ||
</ul> | ||
</div> | ||
<div class="has-text-centered"> | ||
<p>Seleziona un campo e poi clicca elimina</p> | ||
</div> | ||
<div class="table-container " > | ||
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth" id="visualizeTable"> | ||
<thread > | ||
<th>Data</th> | ||
<th>Peso</th> | ||
</thread> | ||
<tbody> | ||
</tbody> | ||
</table> | ||
</div> | ||
<div class="has-text-centered"> | ||
<button class="button is-danger is-outlined" id="deleteRowBtn"> | ||
<span>Elimina</span> | ||
<span class="icon is-small"> | ||
<i class="fas fa-times"></i> | ||
</span> | ||
</button> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
const db = require('electron-db'); | ||
const { app, BrowserWindow } = require('electron'); | ||
const { ipcRenderer } = require('electron') | ||
|
||
//Tabs | ||
const visualizeTab = document.getElementById('visualizeTab'); | ||
const settingsTab = document.getElementById('settingsTab') | ||
const addTab = document.getElementById('addTab'); | ||
const editTab = document.getElementById('editTab'); | ||
|
||
//Table | ||
const table = document.getElementById('visualizeTable'); | ||
|
||
//Buttons | ||
const deleteRowBtn = document.getElementById('deleteRowBtn'); | ||
|
||
var lastSelectedRow = null; | ||
|
||
deleteRowBtn.onclick = () =>{ | ||
deselectEffect(lastSelectedRow); | ||
var date = lastSelectedRow.getElementsByTagName('td')[0].textContent; | ||
db.deleteRow('peso', {'data': date}, (succ, msg) => { | ||
console.log(msg); | ||
}); | ||
location.reload(); | ||
} | ||
|
||
function selectEffect(row){ | ||
if(row != null) | ||
row.classList.add('is-selected'); | ||
} | ||
function deselectEffect(row){ | ||
if(row != null) | ||
if ( row.classList.contains('is-selected') ) | ||
row.classList.remove('is-selected'); | ||
|
||
} | ||
|
||
|
||
function fillTable(){ | ||
db.getAll('peso',(succ, data) => { | ||
console.log(data); | ||
let index = 1; | ||
//create row | ||
for(elems in data){ | ||
var row = table.insertRow(index); | ||
var dataCell = row.insertCell(0); | ||
var pesoCell = row.insertCell(1); | ||
dataCell.innerHTML = data[elems].data; | ||
pesoCell.innerHTML = data[elems].peso; | ||
index+=1; | ||
} | ||
return data; | ||
}) | ||
} | ||
function addRowsListeners(){ | ||
console.log('Aggiungedo listeners'); | ||
var rows = table.getElementsByTagName("tr"); | ||
for(i=0; i<rows.length;i++){ | ||
var currentRow = table.rows[i]; | ||
var createClickListener = function(row){ | ||
return function(){ | ||
deselectEffect(lastSelectedRow); | ||
selectEffect(row); | ||
lastSelectedRow = row; | ||
} | ||
} | ||
currentRow.onclick = createClickListener(currentRow); | ||
} | ||
} | ||
|
||
visualizeTab.onclick = () =>{ | ||
ipcRenderer.sendSync('synchronous-message', 'visualize'); | ||
}; | ||
|
||
settingsTab.onclick = () => { | ||
ipcRenderer.sendSync('synchronous-message', 'settings'); | ||
}; | ||
addTab.onclick = () =>{ | ||
ipcRenderer.sendSync('synchronous-message', 'add'); | ||
} | ||
editTab.onclick = () =>{ | ||
ipcRenderer.sendSync('synchronous-message', 'edit'); | ||
} | ||
|
||
fillTable(); | ||
addRowsListeners(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Gym Utils</title> | ||
<link rel="stylesheet" href="index.css"> | ||
<script defer src="edit.js"></script> | ||
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css"> | ||
</head> | ||
<body> | ||
<div class="container is-fluid"> | ||
|
||
|
||
<div class="tabs is-centered"> | ||
<ul> | ||
<li id="addTab"><a>Aggiungi</a></li> | ||
<li id="visualizeTab" ><a>Visualizza</a></li> | ||
<li id="editTab" class="is-active"><a>Modifica</a></li> | ||
<li id="deleteTab"><a>Elimina</a></li> | ||
<li id="settingsTab"><a>Impostazioni</a></li> | ||
</ul> | ||
</div> | ||
|
||
Edit | ||
<div class="table-container " > | ||
<table class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth" id="visualizeTable"> | ||
<thread > | ||
<th>Data</th> | ||
<th>Peso</th> | ||
</thread> | ||
<tbody > | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<canvas id="chart" ></canvas> | ||
|
||
</canva> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const db = require('electron-db'); | ||
const { app, BrowserWindow } = require('electron'); | ||
const { ipcRenderer } = require('electron') | ||
|
||
|
||
//Tabs | ||
const visualizeTab = document.getElementById('visualizeTab'); | ||
const settingsTab = document.getElementById('settingsTab') | ||
const addTab = document.getElementById('addTab'); | ||
const deleteTab = document.getElementById('deleteTab'); | ||
|
||
//Tabs listeners | ||
visualizeTab.onclick = () =>{ | ||
ipcRenderer.sendSync('synchronous-message', 'visualize'); | ||
}; | ||
|
||
settingsTab.onclick = () => { | ||
ipcRenderer.sendSync('synchronous-message', 'settings'); | ||
}; | ||
addTab.onclick = () =>{ | ||
ipcRenderer.sendSync('synchronous-message', 'add'); | ||
} | ||
deleteTab.onclick = () =>{ | ||
ipcRenderer.sendSync('synchronous-message', 'delete'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters