Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #72

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Dev #72

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
45647e8
Very various code revork and refactoring (#29)
leechwort Dec 6, 2023
6531848
Delete file, forgotten from previous commit
leechwort Dec 6, 2023
98dd5c5
Fixed docker file and add ci for build docker images
VovaStelmashchuk Dec 7, 2023
98b5700
change to correct tag
VovaStelmashchuk Dec 7, 2023
4120558
Implement build docker image with correct tags
VovaStelmashchuk Dec 7, 2023
1e8e139
Merge pull request #36 from hacklabkyiv/fix_docker
VovaStelmashchuk Dec 7, 2023
7dca0cb
Implement creating database on start if not exist
VovaStelmashchuk Dec 14, 2023
e737cb3
Flash RFID readers from admin panel (#42)
leechwort Dec 18, 2023
02ce2e8
Fix problem with settings editor
leechwort Dec 19, 2023
78ce56a
Docker configuration changed
leechwort Dec 20, 2023
8886144
Improve plugin subsystem
leechwort Dec 21, 2023
e6c1c87
Fix UUID generator
leechwort Dec 21, 2023
169084b
Fix AddUser() bug
leechwort Dec 21, 2023
4816b7c
Some changes to login and database create logic
leechwort Dec 21, 2023
58c1099
UI fixes (#53)
temhota Jan 6, 2024
b8b51ad
Docker-related stuff changed
leechwort Jan 13, 2024
00f421b
Fix add user functionality
leechwort Jan 13, 2024
c0c9408
Some fixes (#57)
leechwort Jan 15, 2024
a9874a9
Add image and other fix (#58)
leechwort Jan 21, 2024
be74e5e
Another fixes
leechwort Jan 22, 2024
f701e77
Several changes, revealed during smoke test on final stages (#61)
leechwort Feb 5, 2024
15cf169
Merge branch 'master' into dev
leechwort Feb 5, 2024
41783a5
Tool door split (#65)
leechwort Feb 10, 2024
26a2ea6
Latest activity added (#66)
leechwort Feb 11, 2024
5640b86
Slack notifier separately notify door and tool (#67)
leechwort Feb 11, 2024
6909ce8
Merge branch 'master' into dev
leechwort Feb 14, 2024
6450653
Make device name editable (#69)
temhota Feb 20, 2024
439811f
Added margin in settings editor
leechwort Feb 20, 2024
217ede0
Merge branch 'master' into dev
leechwort Feb 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,19 @@
height: 100%;
}
}

.editable-field span {
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
padding-bottom: 5px;
}

.editable-field i.edit {
opacity: 0;
}

.editable-field:hover i.edit, .editable-field:focus i.edit {
opacity: 1;
transition: 0.3s;
}
54 changes: 53 additions & 1 deletion app/static/js/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function generateAccordionItems(devices) {
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapse-${device.id}" aria-expanded="false" aria-controls="flush-collapse-${device.id}">
<i class="bi bi-phone-vibrate-fill"></i> | ${device.name}
<p class="editable-field"><i class="bi bi-phone-vibrate-fill"></i> | <span class="deviceName" contenteditable="true" spellcheck="false" id="device-${device.id}" onclick="makeEditable(event, '${device.id}')">${device.name}</span>
<i class="bi bi-pencil-fill edit" onclick="makeEditable(event, '${device.id}', true)"></i></p>
</button>
</h2>

Expand Down Expand Up @@ -119,6 +120,33 @@ function addDevice(deviceName, isDeviceTool) {
});
}

function updateDevice(deviceId, deviceName) {
// Prepare device data
const deviceData = {
name: deviceName,
};
// Make API call to update device
fetch(`/api/devices/${deviceId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(deviceData),
})
.then((response) => {
// Check if response status code is 200 (OK)
if (response.status === 200) {
alert("Device updated successfully!");
} else {
alert("Error updating device. Please try again later.");
}
})
.catch((error) => {
console.error("Error updating device:", error);
alert("Error updating device. Please try again later.");
});
}

function removeDevice(deviceId) {
fetch(`/api/devices/${deviceId}`, {
method: "DELETE",
Expand All @@ -143,3 +171,27 @@ function refreshDevicesList() {
.then((data) => generateAccordionItems(data))
.catch((error) => console.error("Error fetching data:", error));
}

function makeEditable(event, deviceId, isEditIconClicked = false) {
const element = document.getElementById(`device-${deviceId}`);
if (isEditIconClicked) {
element === document.activeElement ? element.blur() : element.focus();
}
let originalContent = element.textContent;

element.addEventListener("keydown", function (event) {
if (event.key === "Enter") {
this.blur();
}
});

element.onblur = async function () {
if (element.textContent === "" || element.textContent === originalContent) {
// if the new name is empty, revert to the original name
// TODO: add validation
element.textContent = originalContent;
return;
}
await updateDevice(deviceId, element.textContent);
};
}
2 changes: 1 addition & 1 deletion app/templates/prismo/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1 class="my-4">Settings</h1>

<div id="jsoneditor"></div>

<button class="btn btn-primary" id="save-settings-button">Save Settings</button>
<button class="btn btn-primary mt-4" id="save-settings-button">Save Settings</button>

<script type="module">
import { JSONEditor } from '../static/js/jsoneditor-standalone.js'
Expand Down
Loading