Skip to content

Commit

Permalink
cleanup autosave
Browse files Browse the repository at this point in the history
  • Loading branch information
karchjd committed Oct 1, 2024
1 parent 3ae7e4c commit b6983ea
Show file tree
Hide file tree
Showing 69 changed files with 490 additions and 119,852 deletions.
16 changes: 8 additions & 8 deletions R/functionsServer.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ getGroupTable <- function(parTable) {

importModel <- function(session, full, importedModel) {
imported <- FALSE
if (Sys.getenv('SHINY_PORT') == "") {
server <- FALSE
if (Sys.getenv("SHINY_PORT") == "") {
shinyapps <- FALSE
} else {
server <- TRUE
shinyapps <- TRUE
}
session$sendCustomMessage("fullServer", message = list(full=full,server=server))
session$sendCustomMessage("fullServer", message = list(full = full, shinyapps = shinyapps))

makeNewVars <- function(vars, groups) {
allCombs <- expand.grid(vars, groups)
paste0(allCombs$Var1, ".", allCombs$Var2)
}

# import model if present
if ((!imported) && !(is.null(importedModel))) {
parTable <- importedModel$parTable
Expand Down Expand Up @@ -63,8 +63,8 @@ modifyResTable <- function(ests) {
names(ests)[names(ests) == "lhs"] <- "source"
names(ests)[names(ests) == "op"] <- "arrow"
names(ests)[names(ests) == "rhs"] <- "target"
ests$arrow[ests$arrow == "~"] <- "\u2192" #
ests$arrow[ests$arrow == "=~"] <- "\u2192" #
ests$arrow[ests$arrow == "~~"] <- "\u2194" #
ests$arrow[ests$arrow == "~"] <- "\u2192" #
ests$arrow[ests$arrow == "=~"] <- "\u2192" #
ests$arrow[ests$arrow == "~~"] <- "\u2194" #
return(ests)
}
2 changes: 1 addition & 1 deletion dev/compile_restart_dev.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
recompile_front <- T # nolint
release <- F
release <- T

if (recompile_front) {
# Compile Svelte front end
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<Debug />
<FromR />
<DuckTapeFixes />
{#if $appState.server}
{#if $appState.shinyapps}
<AutoSave />
{/if}
{/if}
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/AutoSave.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import { onMount } from "svelte";
import { parseModel } from "./MenuTop/IO";
const timeoutSeconds = 5;
const timeoutSeconds = 840;
function idleTimer() {
var t = setTimeout(logout, timeoutSeconds * 1000);
Expand Down Expand Up @@ -39,17 +40,20 @@
model = jsonModel();
}
if (model != null || data != null) {
bootbox.alert(
"Due to inactivity, you will be disconnected from the server shortly. Your work was saved for you. In case you have already been disconnected now, you can continue where you left off by refreshing the page.",
);
let sessionId = sessionStorage.getItem("sessionId");
if (!sessionId) {
sessionId = Date.now().toString(); // Generate a unique session ID
sessionId = Date.now().toString();
sessionStorage.setItem("sessionId", sessionId);
console.log("Session ID save: ", sessionId);
}
var db = new Dexie("ModelDatabase");
db.version(1).stores({
cache: "sessionId, model, data",
});
await db.cache.clear(); // Corrected from delete() to clear()
await db.cache.clear();
await db.cache.put({
sessionId: sessionId,
model: model,
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/MenuTop/IO.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { resetCounters } from "../Graph/graphmanipulation.js";
import { applyLinkedClass } from "../Shiny/applyLinkedClass.js";
import { checkNodeLoop } from "../Graph/checkNodeLoop.js";




export async function requestData(goal) {
// @ts-expect-error
Shiny.setInputValue("down-requestData", { goal: goal, random: Math.random() });
Expand Down
19 changes: 5 additions & 14 deletions frontend/src/Shiny/AppReady.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
<script>
import { appState } from "../stores";
function serverAvail() {
return typeof Shiny === "object" && Shiny !== null;
}
if (serverAvail()) {
Shiny.addCustomMessageHandler("fullServer", function (fullServer) {
$appState.full = fullServer.full;
$appState.ready = true;
$appState.server = true; //fullServer.server;
console.log("fullServer", fullServer.server);
});
} else {
$appState.full = true;
// @ts-ignore
Shiny.addCustomMessageHandler("fullServer", function (fullServer) {
$appState.full = fullServer.full;
$appState.ready = true;
}
$appState.shinyapps = fullServer.shinyapps; //fullServer.server;
});
</script>
3 changes: 2 additions & 1 deletion frontend/src/stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export let appState = writable({
drawing: "none",
undoEmpty: true,
redoEmpty: true,
server: false
server: false,
shinyapps: false
});

export let dataInfo = writable(0);
Expand Down
1 change: 1 addition & 0 deletions inst/www/assets/@babel-75df473a.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions inst/www/assets/@jaames-324f80d4.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/www/assets/canvg-9877eea0.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions inst/www/assets/core-js-bbf708ea.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/www/assets/cose-base-3e61f9ec.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/www/assets/cssesc-5de85916.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions inst/www/assets/cytoscape-86e840ae.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions inst/www/assets/cytoscape-automove-085c6bfa.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b6983ea

Please sign in to comment.