Skip to content

Dev #44

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

Merged
merged 4 commits into from
Jun 26, 2024
Merged

Dev #44

Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## CHANGELOG

### [24.6.4] - Jun 26, 2024
- The selected DataSet is now saved when you save the DataTemplate
- Updated Pandoc to 3.2.1 in Dockerfile

### [24.6.3] - Jun 24, 2024
- Fixed an issue with `/logs` as it didn't adhere to the default `Content-Security-Policy`
- Updated instructions for deploying JinjaFx Server as a Container using Kubernetes
Expand Down Expand Up @@ -319,6 +323,7 @@
### 21.11.0 - Nov 29, 2021
- Initial release

[24.6.4]: https://github.com/cmason3/jinjafx_server/compare/24.6.3...24.6.4
[24.6.3]: https://github.com/cmason3/jinjafx_server/compare/24.6.2...24.6.3
[24.6.2]: https://github.com/cmason3/jinjafx_server/compare/24.6.1...24.6.2
[24.6.1]: https://github.com/cmason3/jinjafx_server/compare/24.6.0...24.6.1
Expand Down
3 changes: 2 additions & 1 deletion jinjafx_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import re, argparse, hashlib, traceback, glob, hmac, uuid, struct, binascii, gzip, requests, ctypes, subprocess
import cmarkgfm, emoji

__version__ = '24.6.3'
__version__ = '24.6.4'

llock = threading.RLock()
rlock = threading.RLock()
Expand Down Expand Up @@ -702,6 +702,7 @@ def html_escape(text):
dt_yml += re.sub('^', ' ' * 4, vdt['template'], flags=re.MULTILINE) + '\n'

dt_yml += '\nrevision: ' + str(dt_revision) + '\n'
dt_yml += 'dataset: "' + dt['dataset'] + '"\n'

dt_hash = hashlib.sha256(dt_yml.encode('utf-8')).hexdigest()
dt_yml += 'dt_hash: "' + dt_hash + '"\n'
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends wget git build-essential; \

wget -P /tmp https://github.com/jgm/pandoc/releases/download/3.2/pandoc-3.2-1-amd64.deb; \
dpkg -i /tmp/pandoc-3.2-1-amd64.deb; \
wget -P /tmp https://github.com/jgm/pandoc/releases/download/3.2.1/pandoc-3.2.1-1-amd64.deb; \
dpkg -i /tmp/pandoc-3.2.1-1-amd64.deb; \

python3 -m venv /opt/jinjafx; \
/opt/jinjafx/bin/python3 -m pip install --upgrade git+https://github.com/cmason3/jinjafx_server.git@${BRANCH} lxml; \
Expand Down
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/4.1.0/js-yaml.min.js" integrity="sha512-CSBhVREyzHAjAFfBlIBakjoRUKp5h7VSweP0InR/pAJyptH7peuhCsqAI/snV+TwZmXZqoUklpXp6R6wMnYf5Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.11/dayjs.min.js" integrity="sha512-FwNWaxyfy2XlEINoSnZh1JQ5TRRtGow0D6XcmAWmYCRgvqOUTnzCxPc9uF35u5ZEpirk1uhlPVA19tflhvnW1g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.11/plugin/relativeTime.min.js" integrity="sha512-MVzDPmm7QZ8PhEiqJXKz/zw2HJuv61waxb8XXuZMMs9b+an3LoqOqhOEt5Nq3LY1e4Ipbbd/e+AWgERdHlVgaA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="/73874bbf/jinjafx_m.js"></script>
<script src="/ccaef2dc/jinjafx_m.js"></script>
</head>
<body>
<div id="overlay"></div>
Expand Down
56 changes: 37 additions & 19 deletions www/jinjafx_m.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ function getStatusText(code) {
};

function select_dataset(e) {
switch_dataset(e.currentTarget.ds_name, true);
switch_dataset(e.currentTarget.ds_name, true, false);
}

function switch_dataset(ds, sflag) {
function switch_dataset(ds, sflag, dflag) {
if (sflag) {
datasets[current_ds][0] = window.cmData.swapDoc(datasets[ds][0]);
datasets[current_ds][1] = window.cmVars.swapDoc(datasets[ds][1]);
Expand All @@ -136,6 +136,13 @@ function getStatusText(code) {
window.cmVars.swapDoc(datasets[ds][1]);
}
if (ds != current_ds) {
if (dflag) {
window.addEventListener('beforeunload', onBeforeUnload);
if (document.getElementById('get_link').value != 'false') {
document.title = 'JinjaFx [unsaved]';
}
}
dirty = true;
document.getElementById('selected_ds').innerHTML = ds;
current_ds = ds;
onDataBlur();
Expand Down Expand Up @@ -198,14 +205,14 @@ function getStatusText(code) {

function delete_dataset(ds) {
delete datasets[ds];
window.addEventListener('beforeunload', onBeforeUnload);
if (document.getElementById('get_link').value != 'false') {
document.title = 'JinjaFx [unsaved]';
}
dirty = true;
//window.addEventListener('beforeunload', onBeforeUnload);
//if (document.getElementById('get_link').value != 'false') {
// document.title = 'JinjaFx [unsaved]';
//}
//dirty = true;

rebuild_datasets();
switch_dataset(Object.keys(datasets)[0], false);
switch_dataset(Object.keys(datasets)[0], false, true);
fe.focus();
}

Expand Down Expand Up @@ -540,6 +547,7 @@ function getStatusText(code) {
return false;
}

dt.dataset = current_ds;
dt.template = e(window.cmTemplate.getValue().replace(/\t/g, " "));

if ((current_ds === 'Default') && (Object.keys(datasets).length === 1)) {
Expand All @@ -553,7 +561,7 @@ function getStatusText(code) {
dt.global = e(window.cmgVars.getValue().replace(/\t/g, " "));
}

switch_dataset(current_ds, true);
switch_dataset(current_ds, true, false);
Object.keys(datasets).forEach(function(ds) {
dt.datasets[ds] = {};
dt.datasets[ds].data = e(datasets[ds][0].getValue());
Expand Down Expand Up @@ -711,7 +719,12 @@ function getStatusText(code) {
try {
var dt = jsyaml.load(d(JSON.parse(this.responseText)['dt']), jsyaml_schema);

load_datatemplate(dt['dt'], qs);
if (dt.hasOwnProperty('dataset')) {
load_datatemplate(dt['dt'], qs, dt['dataset']);
}
else {
load_datatemplate(dt['dt'], qs, null);
}
dt_id = qs.dt;

document.getElementById('update').classList.remove('d-none');
Expand Down Expand Up @@ -1393,13 +1406,13 @@ function getStatusText(code) {
if (!datasets.hasOwnProperty(new_ds)) {
datasets[new_ds] = [CodeMirror.Doc('', 'data'), CodeMirror.Doc('', 'yaml')];
rebuild_datasets();
window.addEventListener('beforeunload', onBeforeUnload);
if (document.getElementById('get_link').value != 'false') {
document.title = 'JinjaFx [unsaved]';
}
dirty = true;
//window.addEventListener('beforeunload', onBeforeUnload);
//if (document.getElementById('get_link').value != 'false') {
// document.title = 'JinjaFx [unsaved]';
//}
//dirty = true;
}
switch_dataset(new_ds, true);
switch_dataset(new_ds, true, true);
}
else {
set_status("darkred", "ERROR", "Invalid Data Set Name");
Expand Down Expand Up @@ -1687,7 +1700,7 @@ function getStatusText(code) {
}

function apply_dt() {
load_datatemplate(pending_dt, null);
load_datatemplate(pending_dt, null, null);
reset_location('');
dt_id = '';
dt_password = null;
Expand Down Expand Up @@ -1747,7 +1760,7 @@ function getStatusText(code) {
}
}

function load_datatemplate(_dt, _qs) {
function load_datatemplate(_dt, _qs, _ds) {
try {
current_ds = 'Default';

Expand All @@ -1762,7 +1775,12 @@ function getStatusText(code) {
datasets[ds] = [CodeMirror.Doc(data, 'data'), CodeMirror.Doc(vars, 'yaml')];
});

current_ds = Object.keys(datasets)[0];
if ((_ds == null) || !datasets.hasOwnProperty(_ds)) {
current_ds = Object.keys(datasets)[0];
}
else {
current_ds = _ds;
}
window.cmData.swapDoc(datasets[current_ds][0]);
window.cmVars.swapDoc(datasets[current_ds][1]);

Expand Down