fix: properly persist cookies

This commit is contained in:
Zach Daniel 2023-08-02 17:04:03 -04:00
parent 47f87550fe
commit 667fe6ba8c
12 changed files with 63 additions and 8203 deletions

4
.gitignore vendored
View file

@ -10,6 +10,8 @@
# Where third-party dependencies like ExDoc output generated docs.
/doc/
node_modules
# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch
@ -22,4 +24,4 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
ash_admin-*.tar
.DS_Store
.DS_Store

View file

@ -128,6 +128,15 @@ Hooks.Actor = {
this.handleEvent("toggle_actor_paused", (payload) => {
document.cookie = "actor_paused" + "=" + payload.actor_paused + ";path=/";
});
this.pushEvent("set_actor_from_session", {
actor_resource: document.cookie.actor_resource,
actor_primary_key: document.cookie.actor_primary_key,
actor_action: document.cookie.actor_action,
actor_api: document.cookie.actor_api,
actor_authorizing: document.cookie.actor_authorizing,
actor_paused: document.cookie.actor_paused
})
},
};

View file

@ -306,6 +306,19 @@ defmodule AshAdmin.PageLive do
|> push_event("clear_actor", %{})}
end
def handle_event("set_actor_from_session", payload, socket) do
assigns =
payload
|> Map.take(
~w[actor_resource actor_primary_key actor_action actor_api actor_authorizing actor_paused]
)
|> Enum.map(fn {key, value} ->
{String.to_existing_atom(key), value}
end)
{:noreply, assign(socket, assigns)}
end
def handle_event(
"set_actor",
%{"resource" => resource, "api" => api, "pkey" => primary_key},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -0,0 +1,6 @@
{
"!comment!":"This file was auto-generated by `mix phx.digest`. Remove it and all generated artefacts with `mix phx.digest.clean --all`",
"version":1,
"latest":{"assets/app.css":"assets/app-161d914bba3ef8912bae46d62332075a.css","assets/app.js":"assets/app-c9fc8078e7bd6db471c3dfa3fcebe839.js"},
"digests":{"assets/app-161d914bba3ef8912bae46d62332075a.css":{"size":35588,"sha512":"UD0fP1n3WDpLGBt/Z/B2CpSpg8DUFlcIM3LV86qlBW28sgXzM2nOogI6tFmH6IclRlq2VBl+O5Pc+TKkBgHTcg==","digest":"161d914bba3ef8912bae46d62332075a","logical_path":"assets/app.css","mtime":63858229399},"assets/app-c9fc8078e7bd6db471c3dfa3fcebe839.js":{"size":92526,"sha512":"GzSgXYTWePK9QG0akmOU5Xv0o+H0UvSGvNo3jKMKI8m/iPH/+S7Of2p1q/bvc722pqyZB8rHCBv3hFNCZtrMcQ==","digest":"c9fc8078e7bd6db471c3dfa3fcebe839","logical_path":"assets/app.js","mtime":63858229399}}
}