Skip to content
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

ui patch agent show #1326

Merged
merged 17 commits into from
Mar 12, 2016
9 changes: 7 additions & 2 deletions app/assets/javascripts/pages/agent-show-page.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class @AgentShowPage
$(".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
$('#toggle-memory').on "click", @toggleMemory

# Trigger tabs when navigated to.
if tab = window.location.href.match(/tab=(\w+)\b/i)?[1]
Expand Down Expand Up @@ -40,6 +41,12 @@ class @AgentShowPage
$("#logs .spinner").stop(true, true).fadeOut ->
$("#logs .refresh, #logs .clear").show()

toggleMemory: ->
if $('#memorypanel').hasClass('hidden')
$('#memorypanel').removeClass 'hidden'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the button text does not change anymore when you show the memory, is that intended?

else
$('#memorypanel').addClass 'hidden'

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")
Expand All @@ -53,7 +60,5 @@ class @AgentShowPage
.fail ->
$("#memory .spinner").fadeOut ->
$("#memory .clear").css(display: 'inline-block')

$ ->
Utils.registerPage(AgentShowPage, forPathsMatching: /^agents\/\d+/)

23 changes: 13 additions & 10 deletions app/views/agents/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,20 @@
<b>Options:</b>
<pre><%= Utils.pretty_jsonify @agent.options || {} %></pre>
</p>

<p id="memory" data-agent-id="<%= @agent.id %>">
<b>Memory:</b>
<% if @agent.memory.present? %>
<i class="fa fa-spinner fa-pulse spinner"></i>
<i class="fa fa-trash action-icon clear"></i>
<% end %>
<pre class="memory"><%= Utils.pretty_jsonify @agent.memory || {} %></pre>
</p>
<button type="submit" class="btn btn-default" id="toggle-memory">Show Memory</button>
<div id="memorypanel" class="hidden">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This div block should be indented the same level as the button above.

<p id="memory" data-agent-id="<%= @agent.id %>">
<b>Memory:</b>
<% if @agent.memory.present? %>
<i class="fa fa-spinner fa-pulse spinner"></i>
<i class="fa fa-trash action-icon clear"></i>
<% end %>
<pre class="memory"><%= Utils.pretty_jsonify @agent.memory || {} %></pre>
</p>
</div>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added one opening div and two closing /divs, I think one of the closing divs needs to be removed.

</div>
</div>
</div>
</div>
</div>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is good practice to have an empty new line at the end of every file.