feat: adding settings and pushSite, siteswitch via header, basic frontend stuff

This commit is contained in:
2024-12-13 18:21:03 +01:00
parent ff73600daf
commit f16522fd66
17 changed files with 4161 additions and 131 deletions

View File

@ -0,0 +1,52 @@
const HomeType= {
Home: 1,
Push: 2,
Settings: 3
}
function handleDayChange() {
selectedDay = document.getElementById('day-dropdown').value;
console.log('Selected day:', selectedDay);
}
function handleAdd() {
if (!day || !type || !role || !shortInput || !longInput) {
alert('Please fill in all fields!');
return;
}
day = document.getElementById('day-dropdown').value;
type = document.getElementById('type-dropdown').value;
role = document.getElementById('role-dropdown').value;
shortInput = document.getElementById('short-input').value;
longInput = document.getElementById('long-input').value;
newRow.innerHTML = `
<td class="px-4 py-2 border border-gray-300 dark:text-gray-200">${type}</td>
<td class="px-4 py-2 border border-gray-300 dark:text-gray-200">${role}</td>
<td class="px-4 py-2 border border-gray-300 dark:text-gray-200">${shortInput}</td>
`;
tableBody.appendChild(newRow);
console.log('Added task:', { day, type, role, shortInput, longInput });
}
function ChangeSite(mimetype){
console.log(mimetype);
if (mimetype === HomeType.Home){
homeDiv.style.display = 'block';
pushDiv.style.display = 'none';
settingsDiv.style.display = 'none';
} else if (mimetype === HomeType.Push){
homeDiv.style.display = 'none';
pushDiv.style.display = 'block';
settingsDiv.style.display = 'none';
} else if (mimetype === HomeType.Settings){
homeDiv.style.display = 'none';
pushDiv.style.display = 'none';
settingsDiv.style.display = 'block';
}
}

View File

@ -0,0 +1,19 @@
let day = document.getElementById('day-dropdown').value;
let type = document.getElementById('type-dropdown').value;
let role = document.getElementById('role-dropdown').value;
let shortInput = document.getElementById('short-input').value;
let longInput = document.getElementById('long-input').value;
let day = document.getElementById('day-dropdown').value;
let type = document.getElementById('type-dropdown').value;
let role = document.getElementById('role-dropdown').value;
let shortInput = document.getElementById('short-input').value;
let longInput = document.getElementById('long-input').value;
let tableBody = document.getElementById('task-table-body');
let newRow = document.createElement('tr');
let selectedDay = document.getElementById('day-dropdown').value;
const homeDiv = document.getElementById('homeDiv');
const pushDiv = document.getElementById('pushDiv');
const settingsDiv = document.getElementById('settingsDiv');

19
components/js/preload.js Normal file
View File

@ -0,0 +1,19 @@
const { contextBridge } = require('electron')
contextBridge.exposeInMainWorld('versions', {
node: () => process.versions.node,
chrome: () => process.versions.chrome,
electron: () => process.versions.electron,
})
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})

View File

View File

@ -0,0 +1,30 @@
const fetch = require('node-fetch');
require('dotenv').config();
const GIT_REPO = process.env.GIT_REPO; // z.B. https://your-git-server.com/api/v4/projects/PROJECT_ID/repository/files
const GIT_TOKEN = process.env.GIT_TOKEN;
const GIT_BRANCH = process.env.GIT_BRANCH; // z.B. 'main'
async function fetchRepositoryFiles() {
try {
const response = await fetch(`${GIT_REPO}?ref=${GIT_BRANCH}`, { // Hier wird der Branch angegeben
method: 'GET',
headers: {
'Authorization': `Bearer ${GIT_TOKEN}`, // Möglicherweise 'Bearer' anstelle von 'token'
'Accept': 'application/json' // Möglicherweise 'application/json' anstelle von 'application/vnd.github.v3+json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const files = await response.json();
return files.map(file => file.name); // Gibt nur die Dateinamen zurück
} catch (error) {
console.error('Error fetching repository files:', error);
return [];
}
}
module.exports = { fetchRepositoryFiles };