- Add _() translation function to add_tablet.html, add_user.html, loan_tablet.html - Add _() translation function to add_non_loanable_device.html, edit_non_loanable_device.html - Add _() translation function to history.html, non_loanable_devices.html, project_management.html - Update app.py to use cookie-based language persistence with 1-year expiry - Add /set_language endpoint to handle language switching with cookie + session - Update language switcher in base.html to use new endpoint - Set Spanish (es) as default language for internal app - Import make_response and session from Flask
213 lines
6.8 KiB
HTML
213 lines
6.8 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
|
<h2>{{ _('Project Management - Development Notes') }}</h2>
|
|
|
|
<div class="project-management-container">
|
|
<div class="editor-section">
|
|
<div class="editor-controls">
|
|
<button onclick="saveNotes()" class="btn">{{ _('Save Notes') }}</button>
|
|
<button onclick="loadNotes()" class="btn">{{ _('Reload') }}</button>
|
|
<span id="status" style="margin-left: 15px; font-style: italic;"></span>
|
|
</div>
|
|
|
|
<div class="editor-row">
|
|
<div class="editor-col">
|
|
<h3>{{ _('Editor') }}</h3>
|
|
<textarea id="markdown-editor" class="markdown-editor"
|
|
placeholder="{{ _('Write your markdown notes here...') }}"></textarea>
|
|
</div>
|
|
|
|
<div class="editor-col">
|
|
<h3>{{ _('Preview') }}</h3>
|
|
<div id="markdown-preview" class="markdown-preview"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
<script>
|
|
const NOTES_FILE = 'notes_development/project_notes.md';
|
|
|
|
// Initialize: load and render notes
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
loadNotes();
|
|
|
|
// Set up live preview
|
|
const editor = document.getElementById('markdown-editor');
|
|
const preview = document.getElementById('markdown-preview');
|
|
|
|
editor.addEventListener('input', function() {
|
|
preview.innerHTML = marked.parse(editor.value);
|
|
});
|
|
});
|
|
|
|
function loadNotes() {
|
|
fetch('/get_notes/' + NOTES_FILE)
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
throw new Error('File not found, using default');
|
|
}
|
|
return response.text();
|
|
})
|
|
.then(content => {
|
|
document.getElementById('markdown-editor').value = content;
|
|
document.getElementById('markdown-preview').innerHTML = marked.parse(content);
|
|
document.getElementById('status').textContent = '{{ _("Loaded successfully") }}';
|
|
setTimeout(() => {
|
|
document.getElementById('status').textContent = '';
|
|
}, 2000);
|
|
})
|
|
.catch(error => {
|
|
document.getElementById('status').textContent = '{{ _("Using default content") }}';
|
|
setTimeout(() => {
|
|
document.getElementById('status').textContent = '';
|
|
}, 2000);
|
|
});
|
|
}
|
|
|
|
function saveNotes() {
|
|
const content = document.getElementById('markdown-editor').value;
|
|
const statusEl = document.getElementById('status');
|
|
|
|
fetch('/save_notes', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({ content: content, filename: NOTES_FILE })
|
|
})
|
|
.then(response => {
|
|
if (response.ok) {
|
|
statusEl.textContent = '{{ _("Saved successfully!") }}';
|
|
statusEl.style.color = '#4CAF50';
|
|
} else {
|
|
statusEl.textContent = '{{ _("Error saving") }}';
|
|
statusEl.style.color = '#f44336';
|
|
}
|
|
setTimeout(() => {
|
|
statusEl.textContent = '';
|
|
statusEl.style.color = '';
|
|
}, 2000);
|
|
})
|
|
.catch(error => {
|
|
statusEl.textContent = '{{ _("Error") }}: ' + error.message;
|
|
statusEl.style.color = '#f44336';
|
|
setTimeout(() => {
|
|
statusEl.textContent = '';
|
|
statusEl.style.color = '';
|
|
}, 2000);
|
|
});
|
|
}
|
|
|
|
// Auto-save every 30 seconds
|
|
setInterval(() => {
|
|
saveNotes();
|
|
}, 30000);
|
|
</script>
|
|
|
|
<style>
|
|
.project-management-container {
|
|
max-width: 100%;
|
|
}
|
|
|
|
.editor-controls {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
margin-bottom: 15px;
|
|
padding: 10px;
|
|
background-color: #f9f9f9;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.editor-row {
|
|
display: flex;
|
|
gap: 20px;
|
|
}
|
|
|
|
.editor-col {
|
|
flex: 1;
|
|
}
|
|
|
|
.markdown-editor {
|
|
width: 100%;
|
|
height: 500px;
|
|
padding: 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
font-family: monospace;
|
|
font-size: 14px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.markdown-preview {
|
|
width: 100%;
|
|
height: 500px;
|
|
padding: 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
background-color: white;
|
|
overflow-y: auto;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.markdown-preview h1,
|
|
.markdown-preview h2,
|
|
.markdown-preview h3,
|
|
.markdown-preview h4,
|
|
.markdown-preview h5,
|
|
.markdown-preview h6 {
|
|
margin-top: 0;
|
|
}
|
|
|
|
.markdown-preview pre {
|
|
background-color: #f5f5f5;
|
|
padding: 10px;
|
|
border-radius: 4px;
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.markdown-preview code {
|
|
font-family: monospace;
|
|
background-color: #f5f5f5;
|
|
padding: 2px 4px;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.markdown-preview table {
|
|
border-collapse: collapse;
|
|
width: 100%;
|
|
}
|
|
|
|
.markdown-preview th,
|
|
.markdown-preview td {
|
|
border: 1px solid #ddd;
|
|
padding: 8px;
|
|
}
|
|
|
|
/* ============================================
|
|
RESPONSIVE DESIGN FOR PROJECT MANAGEMENT
|
|
============================================ */
|
|
@media (max-width: 768px) {
|
|
.editor-row {
|
|
flex-direction: column;
|
|
}
|
|
.markdown-editor,
|
|
.markdown-preview {
|
|
height: 350px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.editor-controls {
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
.editor-controls button {
|
|
width: 100%;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|