Secrets client side implementation
This commit is contained in:
parent
f938653f8e
commit
3bcb427dd7
@ -66,9 +66,9 @@
|
||||
<input placeholder="funko name" id="new-secret-funko" name="funko">
|
||||
<input placeholder="secret name" id="new-secret-name" name="name">
|
||||
<input placeholder="secret value" type="password" id="new-secret-password" name="value">
|
||||
<button type="submit" hx-on:htmx:after-request="update_secrets(); hide_new_secret()">CREATE</button>
|
||||
<button type="submit" hx-on:htmx:after-request="hide_new_secret()">CREATE</button>
|
||||
</form>
|
||||
<button onclick="hide_new_secret(); close()">CLOSE</button>
|
||||
<button onclick="hide_new_secret(); close();">CLOSE</button>
|
||||
</dialog>
|
||||
<script>
|
||||
update_secrets = function() {
|
||||
@ -76,15 +76,16 @@
|
||||
}
|
||||
show_new_secret = function() {
|
||||
document.getElementById('new-secret-funko').value=""
|
||||
document.getElementById('add-secret').value=""
|
||||
document.getElementById('add-secret').value=""
|
||||
document.getElementById('new-secret-name').value=""
|
||||
document.getElementById('new-secret-password').value=""
|
||||
document.getElementById('add-secret').show()
|
||||
}
|
||||
hide_new_secret = function() {
|
||||
document.getElementById('new-secret-funko').value=""
|
||||
document.getElementById('add-secret').value=""
|
||||
document.getElementById('add-secret').value=""
|
||||
document.getElementById('new-secret-name').value=""
|
||||
document.getElementById('new-secret-password').value=""
|
||||
document.getElementById('add-secret').close()
|
||||
update_secrets()
|
||||
}
|
||||
</script>
|
||||
</main>
|
||||
|
@ -34,9 +34,10 @@ module Secrets
|
||||
end
|
||||
|
||||
# Deletes a secret from the disk and memory
|
||||
delete "/secrets/:name/" do |env|
|
||||
delete "/secrets/:funko/:name/" do |env|
|
||||
funko = env.params.url["funko"]
|
||||
name = env.params.url["name"]
|
||||
SECRETS.delete(name)
|
||||
SECRETS.delete("#{funko}-#{name}")
|
||||
update_secrets
|
||||
halt env, status_code: 204, response: "Deleted"
|
||||
end
|
||||
|
@ -1,6 +1,7 @@
|
||||
require "./commands/build.cr"
|
||||
require "./commands/export.cr"
|
||||
require "./commands/scale.cr"
|
||||
require "./commands/secret.cr"
|
||||
require "./commands/status.cr"
|
||||
require "./funko.cr"
|
||||
require "crest"
|
||||
|
@ -41,7 +41,7 @@ Usage:
|
||||
faaso scale FUNKO [SCALE] [-v=<level>] [-l]
|
||||
faaso status FUNKO_NAME [-v=<level>] [-l]
|
||||
faaso export SOURCE DESTINATION [-v=<level>]
|
||||
faaso secret [-d|-a] FUNKO NAME [-v=<level>] [-l]
|
||||
faaso secret [-d|-a] FUNKO SECRET [-v=<level>] [-l]
|
||||
|
||||
Options:
|
||||
-l --local Run commands locally instead of against a FaaSO server.
|
||||
@ -65,4 +65,6 @@ when .fetch("scale", false)
|
||||
Faaso::Commands::Scale.new.run(ans, ans["FUNKO_NAME"].as(String), ans["SCALE"])
|
||||
when .fetch("status", false)
|
||||
Faaso::Commands::Status.new.run(ans, ans["FUNKO_NAME"].as(String))
|
||||
when .fetch("secret", false)
|
||||
Faaso::Commands::Secret.new.run(ans, ans["FUNKO"].as(String), ans["SECRET"].as(String))
|
||||
end
|
||||
|
@ -15,9 +15,9 @@ module Secrets
|
||||
File.write(Path.new(funko_dir, name), value)
|
||||
end
|
||||
# Delete secrets not in the hash
|
||||
Dir.glob(Path.new(SECRET_PATH, "*")).each do |funko_dir|
|
||||
Dir.glob("#{SECRET_PATH}/*").each do |funko_dir|
|
||||
funko = File.basename(funko_dir)
|
||||
Dir.glob(Path.new(funko_dir, "*")).each do |secret_file|
|
||||
Dir.glob("#{funko_dir}/*").each do |secret_file|
|
||||
name = File.basename(secret_file)
|
||||
unless SECRETS.has_key?("#{funko}-#{name}")
|
||||
File.delete(secret_file)
|
||||
|
@ -4,7 +4,7 @@
|
||||
<td><%= f["name"] %></td>
|
||||
<td>
|
||||
<button hx-post="secrets/" hx-on:htmx:after-request="update_secrets()">Change</button>
|
||||
<button hx-delete="secrets/<%= f["funko"] %>-<%= f["name"] %>/" hx-on:htmx:after-request="update_secrets()">Delete</button>
|
||||
<button hx-delete="secrets/<%= f["funko"] %>/<%= f["name"] %>/" hx-on:htmx:after-request="update_secrets()">Delete</button>
|
||||
<img id="spinner-<%= f["name"] %>" src="bars.svg" class="htmx-indicator">
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user