mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
parent
cfe8482c0d
commit
a080a78eeb
5 changed files with 65 additions and 3 deletions
|
@ -2,6 +2,7 @@ class @AgentShowPage
|
|||
constructor: ->
|
||||
$(".agent-show #show-tabs a[href='#logs'], #logs .refresh").on "click", @fetchLogs
|
||||
$(".agent-show #logs .clear").on "click", @clearLogs
|
||||
$(".agent-show #memory .clear").on "click", @clearMemory
|
||||
|
||||
# Trigger tabs when navigated to.
|
||||
if tab = window.location.href.match(/tab=(\w+)\b/i)?[1]
|
||||
|
@ -39,6 +40,20 @@ class @AgentShowPage
|
|||
$("#logs .spinner").stop(true, true).fadeOut ->
|
||||
$("#logs .refresh, #logs .clear").show()
|
||||
|
||||
clearMemory: (e) ->
|
||||
if confirm("Are you sure you want to clear memory of this Agent?")
|
||||
agentId = $(e.target).closest("[data-agent-id]").data("agent-id")
|
||||
e.preventDefault()
|
||||
$("#memory .spinner").css(display: 'inline-block')
|
||||
$("#memory .clear").hide()
|
||||
$.post "/agents/#{agentId}/memory", { "_method": "DELETE" }
|
||||
.done ->
|
||||
$("#memory .spinner").fadeOut ->
|
||||
$("#memory + .memory").text "{\n}\n"
|
||||
.fail ->
|
||||
$("#memory .spinner").fadeOut ->
|
||||
$("#memory .clear").css(display: 'inline-block')
|
||||
|
||||
$ ->
|
||||
Utils.registerPage(AgentShowPage, forPathsMatching: /^agents\/\d+/)
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ img.odin {
|
|||
display: none;
|
||||
}
|
||||
|
||||
img.spinner {
|
||||
.spinner {
|
||||
display: none;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
@ -172,6 +172,13 @@ span.not-applicable:after {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
// Memory
|
||||
|
||||
#memory .action-icon {
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
// Credentials
|
||||
|
||||
#ace-credential-value {
|
||||
|
@ -285,3 +292,28 @@ $service-colors: #55acee #8fc857 #444444 #2c4762 #007EE5;
|
|||
.label-service {
|
||||
@include services;
|
||||
}
|
||||
|
||||
// Font Awesome Spinner
|
||||
|
||||
.fa-spin-custom {
|
||||
@include animation(spin 1000ms infinite linear);
|
||||
}
|
||||
|
||||
@mixin keyframes($name)
|
||||
{
|
||||
@-webkit-keyframes $name {
|
||||
@content;
|
||||
}
|
||||
@keyframes $name {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@include keyframes(spin) {
|
||||
0% {
|
||||
@include rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
@include rotate(359deg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,16 @@ class AgentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def destroy_memory
|
||||
@agent = current_user.agents.find(params[:id])
|
||||
@agent.update!(memory: {})
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_back "Memory erased for '#{@agent.name}'" }
|
||||
format.json { head :ok }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@agent = current_user.agents.find(params[:id])
|
||||
|
||||
|
|
|
@ -162,9 +162,13 @@
|
|||
<pre><%= Utils.pretty_jsonify @agent.options || {} %></pre>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<p id="memory" data-agent-id="<%= @agent.id %>">
|
||||
<b>Memory:</b>
|
||||
<pre><%= Utils.pretty_jsonify @agent.memory || {} %></pre>
|
||||
<% if @agent.memory.present? %>
|
||||
<i class="fa fa-spinner fa-spin spinner"></i>
|
||||
<i class="fa fa-trash action-icon clear"></i>
|
||||
<% end %>
|
||||
<pre class="memory"><%= Utils.pretty_jsonify @agent.memory || {} %></pre>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -6,6 +6,7 @@ Huginn::Application.routes.draw do
|
|||
post :handle_details_post
|
||||
put :leave_scenario
|
||||
delete :remove_events
|
||||
delete :memory, action: :destroy_memory
|
||||
end
|
||||
|
||||
collection do
|
||||
|
|
Loading…
Add table
Reference in a new issue