Skip to content
Open
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
1 change: 1 addition & 0 deletions InfoLogger/config-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
tls: false,
allow: true,
name: 'ILG',
apiAuthRoutes: true,
},

// optional data source, comment object if not used
Expand Down
42 changes: 22 additions & 20 deletions InfoLogger/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

import { sessionService } from '/js/src/index.js';
sessionService.loadAndHideParameters();
const isSessionLoaded = sessionService.loadAndHideParameters({ loginUrl: '/api/login' });

// Expose sessionService to interact with it the browser's console
window.sessionService = sessionService;
Expand All @@ -23,25 +23,27 @@
import view from './view.js';
import Model from './Model.js';

// Start application
const model = new Model();
const debug = true; // shows when redraw is done
StatefulComponent.useRenderer(model); // Register the model for the stateful components
let currentView = view;
mount(document.body, (model) => currentView(model), model, debug);
// Start application, unless the browser is being redirected to the login
if (isSessionLoaded) {
const model = new Model();
const debug = true; // shows when redraw is done
StatefulComponent.useRenderer(model); // Register the model for the stateful components
let currentView = view;
mount(document.body, (model) => currentView(model), model, debug);

// Expose model to interact with it the browser's console
window.model = model;
// Expose model to interact with it the browser's console
window.model = model;

// Dev only, stripped from the prod build. On an edit, Vite walks up from the changed file through its importers
// until it finds an accept() for it.
// Edits under view.js stop here, we swap in the new view and redraw with the same model, so state is preserved here.
// Edits under Model.js reach this file via Model.js, which is not accepted, so Vite just reloads the whole page.
// Unlike React/Pinia, our models keep state as fields on instances of the old class, next to observers set up in
// their constructors, so they can't be swapped in place.
if (import.meta.hot) {
import.meta.hot.accept('./view.js', (newModule) => {
currentView = newModule.default;
model.notify();
});
// Dev only, stripped from the prod build. On an edit, Vite walks up from the changed file through its importers
// until it finds an accept() for it.
// Edits under view.js stop here, we swap in the new view and redraw with the same model, so state is preserved here.
// Edits under Model.js reach this file via Model.js, which is not accepted, so Vite just reloads the whole page.
// Unlike React/Pinia, our models keep state as fields on instances of the old class, next to observers set up in
// their constructors, so they can't be swapped in place.
if (import.meta.hot) {
import.meta.hot.accept('./view.js', (newModule) => {
currentView = newModule.default;
model.notify();
});
}
}
1 change: 1 addition & 0 deletions InfoLogger/test/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports = {
tls: false,
allow: true,
name: 'TST',
apiAuthRoutes: true,
},
infoLoggerServer: {
host: 'localhost',
Expand Down
Loading