-
Notifications
You must be signed in to change notification settings - Fork 16
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
Clear image list cache #189
Changes from 10 commits
ee65b7b
5cc391f
6c4cd14
8a41b57
1fe4085
cbd9e19
e9ed967
fbb15df
1b6749c
b14e19b
0ed46d3
3b500be
33160c3
07562eb
8b56aa2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
defmodule FieldHubWeb.ProjectShowLive do | ||
alias FieldHub.Project | ||
|
||
alias FieldHubWeb.{ | ||
Router.Helpers, | ||
UserAuth, | ||
|
@@ -42,6 +44,9 @@ defmodule FieldHubWeb.ProjectShowLive do | |
|> assign(:project, project) | ||
|> assign(:current_user, user_name) | ||
|> assign(:new_password, "") | ||
|> assign(:confirm_project_name, "") | ||
|> assign(:delete_files, false) | ||
|> assign(:cache,"") | ||
|> read_project_doc() | ||
} | ||
|
||
|
@@ -112,6 +117,75 @@ defmodule FieldHubWeb.ProjectShowLive do | |
{:noreply, assign(socket, :new_password, password)} | ||
end | ||
|
||
# def handle_event("delete_cache", %{"project" => project} = _values, socket) do | ||
def handle_event("delete_cache", _values, %{assigns: %{project: project}}=socket) do | ||
new_cache = "Delete or update cache in this handle_event" | ||
cache_index = FieldHub.FileStore.file_index(project) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the ticket you do not need to create a new cache, that is already handled by the The only thing that has to be triggered from the interface is the FileStore's function to clear the existing cache. If you want to have a look how the file index looks like, you could for example use the Desktop client to push new images into the repository. |
||
|
||
|
||
IO.inspect(cache_index) | ||
{:noreply, assign(socket, :cache, new_cache)} | ||
# {:noreply, assign(socket, :cache, inspect(cache_index))} | ||
end | ||
|
||
def handle_event( | ||
"delete_form_change", | ||
%{ | ||
"repeat_project_name_input" => repeated_project_name, | ||
"delete_files_radio" => delete_files | ||
} = _values, | ||
socket | ||
) do | ||
delete_files = | ||
case delete_files do | ||
"delete_files" -> | ||
true | ||
|
||
"keep_files" -> | ||
false | ||
end | ||
|
||
socket = assign(socket, :confirm_project_name, repeated_project_name) | ||
socket = assign(socket, :delete_files, delete_files) | ||
{:noreply, socket} | ||
end | ||
|
||
def handle_event( | ||
"delete", | ||
_values, | ||
%{assigns: %{project: project, current_user: user_name, delete_files: delete_files}} = | ||
socket | ||
) do | ||
socket = | ||
case User.is_admin?(user_name) do | ||
true -> | ||
%{database: :deleted} = Project.delete(project, delete_files) | ||
:deleted = User.delete(project) | ||
|
||
if delete_files == false do | ||
{:ok, "Project database`#{project}` has been deleted successfully."} | ||
else | ||
{:ok, "Project database`#{project}` and images have been deleted successfully."} | ||
end | ||
|
||
false -> | ||
{:error, "You are not authorized to delete the project."} | ||
end | ||
|> case do | ||
{:ok, msg} -> | ||
socket | ||
|> put_flash(:info, msg) | ||
|
||
{:error, msg} -> | ||
socket | ||
|> put_flash(:error, msg) | ||
end | ||
|
||
IO.inspect(delete_files) | ||
|
||
{:noreply, redirect(socket, to: "/")} | ||
end | ||
|
||
def handle_event("generate_password", _values, socket) do | ||
{:noreply, assign(socket, :new_password, CouchService.create_password())} | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did you try here? This line should probably be deleted at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wanted to see what happened without wait one day.