Skip to content

Commit

Permalink
Nicer formatting of JSONEditor; minor tweeks; Scenarios show up in th…
Browse files Browse the repository at this point in the history
…e quick navigation menu
  • Loading branch information
cantino committed Jun 15, 2014
1 parent cca78da commit a7ed5b5
Show file tree
Hide file tree
Showing 11 changed files with 598 additions and 581 deletions.
13 changes: 13 additions & 0 deletions app/assets/stylesheets/scenarios.css.scss
@@ -1,2 +1,15 @@
.scenario-import {
.agent-import-list {
.agent-import {
margin-bottom: 20px;

.instructions {
margin-bottom: 10px;
}

.current {
font-weight: bold;
}
}
}
}
13 changes: 6 additions & 7 deletions app/models/agents/pushover_agent.rb
Expand Up @@ -19,13 +19,13 @@ class PushoverAgent < Agent
Your event can provide any of the following optional parameters or you can provide defaults:
* `device` - your user's device name to send the message directly to that device, rather than all of the user's devices
* `title` or `subject` - your notifications's title
* `title` or `subject` - your notification's title
* `url` - a supplementary URL to show with your message - `512` Character Limit
* `url_title` - a title for your supplementary URL, otherwise just the URL is shown - `100` Character Limit
* `priority` - send as `-1` to always send as a quiet notification, `0` is default, `1` to display as high-priority and bypass the user's quiet hours, or `2` for emergency priority: [Please read Pushover Docs on Emergency Priority](https://pushover.net/api#priority)
* `sound` - the name of one of the sounds supported by device clients to override the user's default sound choice. [See PushOver docs for sound options.](https://pushover.net/api#sounds)
* `retry` - Requred for emergency priority - Specifies how often (in seconds) the Pushover servers will send the same notification to the user. Minimum value: `30`
* `expire` - Requred for emergency priority - Specifies how many seconds your notification will continue to be retried for (every retry seconds). Maximum value: `86400`
* `retry` - Required for emergency priority - Specifies how often (in seconds) the Pushover servers will send the same notification to the user. Minimum value: `30`
* `expire` - Required for emergency priority - Specifies how many seconds your notification will continue to be retried for (every retry seconds). Maximum value: `86400`
Your event can also pass along a timestamp parameter:
Expand All @@ -42,10 +42,10 @@ def default_options
'title' => '',
'url' => '',
'url_title' => '',
'priority' => 0,
'priority' => '0',
'sound' => 'pushover',
'retry' => 0,
'expire' => 0,
'retry' => '0',
'expire' => '0',
'expected_receive_period_in_days' => '1'
}
end
Expand Down Expand Up @@ -102,6 +102,5 @@ def send_notification(post_params)
response = HTTParty.post(API_URL, :query => post_params)
puts response
end

end
end
4 changes: 2 additions & 2 deletions app/views/agents/_form.html.erb
Expand Up @@ -77,7 +77,7 @@
<div class="col-md-12">
<div class="form-group">
<%= f.label :options %>
<textarea rows="10" id="agent_options" name="agent[options]" class="form-control live-json-editor <%= (@agent.new_record? && @agent.options == {}) ? "showing-default" : "" %>">
<textarea rows="15" id="agent_options" name="agent[options]" class="form-control live-json-editor <%= (@agent.new_record? && @agent.options == {}) ? "showing-default" : "" %>">
<%= Utils.jsonify((@agent.new_record? && @agent.options == {}) ? @agent.default_options : @agent.options) %>
</textarea>
</div>
Expand All @@ -104,7 +104,7 @@

<div class='row'>
<div class="col-md-12">
<%= f.submit :class => "btn btn-primary" %>
<%= f.submit "Save", :class => "btn btn-primary" %>
</div>
</div>

Expand Down
24 changes: 14 additions & 10 deletions app/views/layouts/application.html.erb
Expand Up @@ -31,18 +31,22 @@

<script>
var agentPaths = {};
<% if current_user -%>
var myAgents = <%= Utils.jsonify(current_user.agents.select([:name, :id, :schedule]).inject({}) {|m, a| m[a.name] = agent_path(a); m }) %>;
var agentNames = [];
<% if current_user.present? -%>
var myAgents = <%= Utils.jsonify(current_user.agents.pluck(:name, :id).inject({}) {|m, a| m[a.first] = agent_path(a.last); m }) %>;
var myScenarios = <%= Utils.jsonify(current_user.scenarios.pluck(:name, :id).inject({}) {|m, s| m[s.first + " Scenario"] = scenario_path(s.last); m }) %>;
$.extend(agentPaths, myAgents);
$.extend(agentPaths, myScenarios);
agentPaths["All Agents Index"] = <%= Utils.jsonify agents_path %>;
agentPaths["New Agent"] = <%= Utils.jsonify new_agent_path %>;
agentPaths["Account"] = <%= Utils.jsonify edit_user_registration_path %>;
agentPaths["Events Index"] = <%= Utils.jsonify events_path %>;
agentPaths["View Agent Diagram"] = <%= Utils.jsonify diagram_agents_path %>;
agentPaths["Run Event Propagation"] = { url: <%= Utils.jsonify propagate_agents_path %>, method: 'POST' };


$.each(agentPaths, function(name, v) { agentNames.push(name); });
<% end -%>
agentPaths["All Agents Index"] = <%= Utils.jsonify agents_path %>;
agentPaths["New Agent"] = <%= Utils.jsonify new_agent_path %>;
agentPaths["Account"] = <%= Utils.jsonify edit_user_registration_path %>;
agentPaths["Events Index"] = <%= Utils.jsonify events_path %>;
agentPaths["View Agent Diagram"] = <%= Utils.jsonify diagram_agents_path %>;
agentPaths["Run Event Propagation"] = { url: <%= Utils.jsonify propagate_agents_path %>, method: 'POST' };
var agentNames = [];
$.each(agentPaths, function(name, v) { agentNames.push(name); });
</script>
</body>
</html>
7 changes: 3 additions & 4 deletions app/views/scenario_imports/_step_one.html.erb
Expand Up @@ -7,10 +7,9 @@
</div>

<div class='row'>
<blockquote>
You can import Scenarios, either from a <code>.json</code> file, or via a public Scenario URL. When you
import a Scenario, Huginn will keep track of where it came from and later let you update it.
</blockquote>
<blockquote>You can import Scenarios, either from a <code>.json</code> file, or via a public
Scenario URL. When you import a Scenario, Huginn will keep track of where it came from and
later let you update it.</blockquote>
</div>

<div class='row'>
Expand Down
10 changes: 6 additions & 4 deletions app/views/scenario_imports/_step_two.html.erb
Expand Up @@ -22,8 +22,10 @@
<div class="page-header">
<h2>
<%= @scenario_import.parsed_data["name"] %>
<span class='text-muted'>(<%= pluralize @scenario_import.parsed_data["agents"].length, "Agent" %>
; exported <%= time_ago_in_words Time.parse(@scenario_import.parsed_data["exported_at"]) %> ago)</span>
<span class='text-muted'>
(<%= pluralize @scenario_import.parsed_data["agents"].length, "Agent" %>;
exported <%= time_ago_in_words Time.parse(@scenario_import.parsed_data["exported_at"]) %> ago)
</span>
</h2>
</div>

Expand All @@ -48,7 +50,7 @@
</h3>

<% if agent_diff.agent_exists? %>
<div>
<div class="instructions">
This Agent exists in your Huginn system.

<% if agent_diff.requires_merge? %>
Expand Down Expand Up @@ -105,7 +107,7 @@
</div>

<div class='col-md-6'>
<textarea name="scenario_import[merges][<%= index %>][options]" rows='10' class="form-control live-json-editor">
<textarea name="scenario_import[merges][<%= index %>][options]" rows='15' class="form-control live-json-editor">
<%= Utils.pretty_jsonify(agent_diff.options.updated) %>
</textarea>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/scenarios/index.html.erb
Expand Up @@ -7,7 +7,8 @@
</h2>
</div>

<blockquote>Scenarios are named groups of Agents. Scenarios allow you to organize your agents, and to export sets of Agents for sharing.</blockquote>
<blockquote>Scenarios are named groups of Agents. Scenarios allow you to organize your agents,
and to import and export sets of Agents to share.</blockquote>

<table class='table table-striped'>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion app/views/scenarios/show.html.erb
Expand Up @@ -2,7 +2,7 @@
<div class='row'>
<div class='col-md-12'>
<div class="page-header">
<h2><%= "Public" if @scenario.public? %> Scenario <span class='label label-info scenario'><%= @scenario.name %></span></h2>
<h2><span class='label label-info scenario'><%= @scenario.name %></span> <%= "Public" if @scenario.public? %> Scenario</h2>
</div>

<% if @scenario.description.present? %>
Expand Down

0 comments on commit a7ed5b5

Please sign in to comment.