focuslight 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.env +13 -0
  3. data/.gitignore +21 -0
  4. data/.travis.yml +9 -0
  5. data/CHANGELOG.md +21 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/Procfile +3 -0
  9. data/Procfile-gem +3 -0
  10. data/README.md +162 -0
  11. data/Rakefile +37 -0
  12. data/bin/focuslight +7 -0
  13. data/config.ru +6 -0
  14. data/focuslight.gemspec +41 -0
  15. data/lib/focuslight.rb +6 -0
  16. data/lib/focuslight/cli.rb +56 -0
  17. data/lib/focuslight/config.rb +27 -0
  18. data/lib/focuslight/data.rb +258 -0
  19. data/lib/focuslight/graph.rb +240 -0
  20. data/lib/focuslight/init.rb +13 -0
  21. data/lib/focuslight/logger.rb +89 -0
  22. data/lib/focuslight/rrd.rb +393 -0
  23. data/lib/focuslight/validator.rb +220 -0
  24. data/lib/focuslight/version.rb +3 -0
  25. data/lib/focuslight/web.rb +614 -0
  26. data/lib/focuslight/worker.rb +97 -0
  27. data/public/css/bootstrap.min.css +7 -0
  28. data/public/favicon.ico +0 -0
  29. data/public/fonts/glyphicons-halflings-regular.eot +0 -0
  30. data/public/fonts/glyphicons-halflings-regular.svg +229 -0
  31. data/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  32. data/public/fonts/glyphicons-halflings-regular.woff +0 -0
  33. data/public/js/bootstrap.min.js +7 -0
  34. data/public/js/jquery-1.10.2.min.js +6 -0
  35. data/public/js/jquery-1.10.2.min.map +0 -0
  36. data/public/js/jquery.storageapi.min.js +2 -0
  37. data/public/js/site.js +214 -0
  38. data/spec/spec_helper.rb +3 -0
  39. data/spec/syntax_spec.rb +9 -0
  40. data/spec/validator_predefined_rules_spec.rb +177 -0
  41. data/spec/validator_result_spec.rb +27 -0
  42. data/spec/validator_rule_spec.rb +68 -0
  43. data/spec/validator_spec.rb +121 -0
  44. data/view/add_complex.erb +143 -0
  45. data/view/base.erb +200 -0
  46. data/view/docs.erb +125 -0
  47. data/view/edit.erb +102 -0
  48. data/view/edit_complex.erb +158 -0
  49. data/view/index.erb +19 -0
  50. data/view/list.erb +22 -0
  51. data/view/view.erb +42 -0
  52. data/view/view_graph.erb +16 -0
  53. metadata +345 -0
data/view/base.erb ADDED
@@ -0,0 +1,200 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html" charset="utf-8">
5
+ <link rel="shortcut icon" href="<%= url_for '/favicon.ico', v: 2 %>" type="image/vnd.microsoft.icon" />
6
+ <link rel="stylesheet" href="<%= url_for '/css/bootstrap.min.css' %>">
7
+ <style type='text/css'>
8
+ .modal form {
9
+ margin: 0 0;
10
+ }
11
+ .table-order-pointer, .table-order-remove {
12
+ cursor: pointer;
13
+ }
14
+ .table-order-pointer:hover, .table-order-remove:hover {
15
+ color: #999;
16
+ }
17
+ .panel {
18
+ border: 0;
19
+ box-shadow: none;
20
+ }
21
+ .panel-heading {
22
+ border-radius: 4px;
23
+ }
24
+ .panel>.list-group .list-group-item {
25
+ border: none;
26
+ }
27
+
28
+ .input-group-static {
29
+ display: table-cell;
30
+ padding: 6px 12px;
31
+ font-size:14px;
32
+ width: 1%;
33
+ white-space: nowrap;
34
+ text-align: center;
35
+ vertical-align: middle;
36
+ }
37
+
38
+ /* Sticky footer styles
39
+ -------------------------------------------------- */
40
+
41
+ html,
42
+ body {
43
+ height: 100%;
44
+ /* The html and body elements cannot have any padding or margin. */
45
+ }
46
+
47
+ /* Wrapper for page content to push down footer */
48
+ #wrap {
49
+ min-height: 100%;
50
+ height: auto;
51
+ /* Negative indent footer by its height */
52
+ margin: 0 auto -40px;
53
+ /* Pad bottom by footer height */
54
+ padding: 0 0 40px;
55
+ }
56
+
57
+ /* Set the fixed height of the footer here */
58
+ #footer {
59
+ height: 40px;
60
+ background-color: #f5f5f5;
61
+ }
62
+ </style>
63
+ <title>
64
+ <% if pathinfo.length() > 0 && pathinfo.length() < 5 %>
65
+ <%= pathinfo[0] %><%= pathinfo[1] ? " » " + pathinfo[1] : "" %><%= pathinfo[2] ? " » " + pathinfo[2] : "" %> | Focuslight
66
+ <% else %>
67
+ Focuslight
68
+ <% end %>
69
+ </title>
70
+ </head>
71
+ <body>
72
+ <div id="wrap">
73
+
74
+ <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
75
+ <div class="container">
76
+ <div class="navbar-header">
77
+ <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
78
+ <span class="sr-only">Toggle navigation</span>
79
+ <span class="icon-bar"></span>
80
+ <span class="icon-bar"></span>
81
+ <span class="icon-bar"></span>
82
+ </button>
83
+ <a class="navbar-brand" href="<%= url_for '/' %>">Focuslight</a>
84
+ </div>
85
+ <div class="navbar-collapse collapse">
86
+ <ul class="nav navbar-nav">
87
+ <li class="<%= pathinfo[4] != :docs ? 'active' : '' %>"><a href="<%= url_for '/' %>">Home</a></li>
88
+ <li class="<%= pathinfo[4] == :docs ? 'active' : '' %>"><a href="<%= url_for '/docs' %>">Docs</a></li>
89
+ </ul>
90
+ </div>
91
+ </div>
92
+ </div>
93
+
94
+ <div class="container">
95
+
96
+ <div class="page-header">
97
+
98
+ <% if pathinfo[4] %>
99
+ <div class="row">
100
+ <div class="col-md-12">
101
+ <% if pathinfo[4] == :docs %>
102
+ <h1>Document and Usage</h1>
103
+ <% elsif pathinfo[4] == :edit %>
104
+ <h1>Edit Graph</h1>
105
+ <% elsif pathinfo[4] == :add_complex %>
106
+ <h1>Add Complex Graph</h1>
107
+ <% elsif pathinfo[4] == :edit_complex %>
108
+ <h1>Edit Complex Graph</h1>
109
+ <% end %>
110
+ </div>
111
+ </div>
112
+
113
+ <% else %>
114
+
115
+ <div class="row">
116
+ <% header_left_col_cls = pathinfo.size >= 3 ? "col-md-10" : "col-md-8" %>
117
+ <% header_right_col_cls = pathinfo.size >= 3 ? "col-md-2" : "col-md-4" %>
118
+ <% term_arg = pathinfo.size == 4 ? {t: pathinfo[4]} : {} %>
119
+ <div class="<%= header_left_col_cls %>">
120
+ <h1>
121
+ <a href="<%= url_for '/' %>">Home</a>
122
+ <% if pathinfo.size == 1 %> » <%= pathinfo[0] %><% end %>
123
+ <% if pathinfo.size >= 2 %> » <a href="<%= url_for linkpath(pathinfo[0..0]) %>"><%= pathinfo[0] %></a><% end %>
124
+ <% if pathinfo.size == 2 %> » <%= pathinfo[1] %><% end %>
125
+ <% if pathinfo.size >= 3 %> » <a href="<%= url_for linkpath(pathinfo[0..1]), term_arg %>"><%= pathinfo[1] %></a><% end %>
126
+ <% if pathinfo.size >= 3 %> » <%= pathinfo[2] %><% end %>
127
+ </h1>
128
+ </div>
129
+ <div class="<%= header_right_col_cls %>" style="padding-top:25px; text-align:right">
130
+ <% if pathinfo.size == 0 %>
131
+ <a class="btn btn-default btn-sm" id="link-fold-all" href="#">fold all</a>
132
+ <a class="btn btn-default btn-sm" id="link-expand-all" href="#">expand all</a>
133
+ <% end %>
134
+ <% add_complex_arg = {} %>
135
+ <% add_complex_arg[:service_name] = pathinfo[0] if pathinfo.size >= 1 %>
136
+ <% add_complex_arg[:section_name] = pathinfo[1] if pathinfo.size >= 2 %>
137
+ <a class="btn btn-default btn-sm" href="<%= url_for '/add_complex', add_complex_arg %>">add complex graph</a>
138
+ </div>
139
+ </div>
140
+ <% end %>
141
+ </div>
142
+
143
+ <div class="row">
144
+ <div class="col-md-12">
145
+ <%== yield %>
146
+ </div>
147
+ </div>
148
+ </div>
149
+
150
+ </div>
151
+
152
+ <div id="footer">
153
+ <div class="container">
154
+ <p style="text-align:center;margin: 10px 0px 10px"><a href="#">back to top</a></p>
155
+ </div>
156
+ </div>
157
+
158
+ <script type="text/javascript" src="<%= url_for '/js/jquery-1.10.2.min.js' %>"></script>
159
+ <script type="text/javascript" src="<%= url_for '/js/bootstrap.min.js' %>"></script>
160
+ <script type="text/javascript" src="<%= url_for '/js/jquery.storageapi.min.js' %>"></script>
161
+ <script type="text/javascript" src="<%= url_for '/js/site.js' %>"></script>
162
+ <script type="text/javascript">
163
+ $(function(){
164
+ $('form.hxrpost').each(setHxrpost);
165
+ $('button.hxr_confirm_button').each(setHxrConfirmBtn);
166
+ $('#add-new-row').click(add_new_row);
167
+ $('form#complex-form').each(setTablePreview);
168
+ $('input.color_pallet').each(setColorPallets);
169
+ $('#link-fold-all').click(fold_all);
170
+ $('#link-expand-all').click(expand_all);
171
+
172
+ var $foldable_items = $('.service_sections, .section_graphs');
173
+
174
+ $foldable_items
175
+ .on('hidden.bs.collapse', function (e) {
176
+ var id = $(e.target).attr('id');
177
+ $.localStorage.set(id,'hide');
178
+ $('#for_'+id).find('span').removeClass('glyphicon-chevron-down')
179
+ .addClass('glyphicon-chevron-right');
180
+ })
181
+ .on('shown.bs.collapse', function (e) {
182
+ var id = $(e.target).attr('id');
183
+ $.localStorage.remove(id);
184
+ $('#for_'+id).find('span').removeClass('glyphicon-chevron-right')
185
+ .addClass('glyphicon-chevron-down');
186
+ })
187
+ ;
188
+
189
+ $foldable_items.each(function () {
190
+ var $target = $(this);
191
+ if ( $.localStorage.isSet($target.attr('id')) )
192
+ $target.collapse('hide');
193
+ });
194
+
195
+ });
196
+
197
+ </script>
198
+ </body>
199
+ </html>
200
+
data/view/docs.erb ADDED
@@ -0,0 +1,125 @@
1
+ <p class="alert alert-info">more details and japanese document are <a href="http://kazeburo.github.com/GrowthForecast/">here</a>.</p>
2
+
3
+ <hr />
4
+
5
+ <h3>How to Register Graphs</h3>
6
+
7
+ <p>To create graphs or update data, make a request to the following URL via a POST method.</p>
8
+
9
+ <pre>
10
+ <%= url_for '/', :full %>api/:service_name/:section_name/:graph_name
11
+ </pre>
12
+
13
+ <div class="row">
14
+ <div class="col-md-3">
15
+ <p>The names of the items within the URL to POST to are shown in the table to the right.</p>
16
+
17
+ <p>You can use multi-byte strings for each item name as long as it is UTF-8.</p>
18
+ </div>
19
+ <div class="col-md-7">
20
+
21
+ <table class="table">
22
+ <tr>
23
+ <th>The Name Used in the Example</th>
24
+ <th>Purpose</th>
25
+ <th>Actual Parameters</th>
26
+ </tr>
27
+ <tr>
28
+ <td>:service_name</td>
29
+ <td>The name of the service that you'd like to graph</td>
30
+ <td>blog, photo, place, socialgame</td>
31
+ </tr>
32
+ <tr>
33
+ <td>:section_name</td>
34
+ <td>The name of the feature or system to graph, within said service.</td>
35
+ <td>entry, user, spot, items</td>
36
+ </tr>
37
+ <tr>
38
+ <td>:graph_name</td>
39
+ <td>The actual name of the value being graphed</td>
40
+ <td>total_entry, kakin_user, muryo_user</td>
41
+ </tr>
42
+ </table>
43
+
44
+ </div>
45
+ </div>
46
+
47
+ <p>For example, if we are graphing the number of registered users in a social game, we would POST to the following URL:</p>
48
+
49
+ <pre>
50
+ <%= url_for '/', :full %>api/socialgame/member/register
51
+ </pre>
52
+
53
+ <p>Also, we would use the following parametens when POSTing.</p>
54
+
55
+ <table class="table">
56
+ <tr>
57
+ <th>Parameter</th>
58
+ <th>Description</th>
59
+ <th>Required/Optional</th>
60
+ </tr>
61
+ <tr>
62
+ <td>number</td>
63
+ <td>The number to give the graph</td>
64
+ <td>Required</td>
65
+ </tr>
66
+ <tr>
67
+ <td>mode</td>
68
+ <td>
69
+
70
+
71
+
72
+ Update method for the number: count, modified, gauge。
73
+
74
+ <dl>
75
+ <dt>count</dt>
76
+ <dd>Add the number and update</dd>
77
+
78
+ <dt>modified</dt>
79
+ <dd>Overwritten only when the numbers different from the previous</dd>
80
+
81
+ <dt>gauge</dt>
82
+ <dd>Always overwritten by the number</dd>
83
+
84
+ <dt>derive</dt>
85
+ <dd>Always overwritten by the number. To Display figures in per seconds</dd>
86
+ </dl>
87
+
88
+ Default is "gauge"<br />
89
+ <strong>⚠</strong>
90
+ The data type is determined at first time. Can't change mode from DERIVE to other and other to DERIVE.
91
+
92
+ </td>
93
+ <td>Optional</td>
94
+ </tr>
95
+ <tr>
96
+ <td>color</td>
97
+ <td>The color of the grah. Specify with #FFFFFF format.</td>
98
+ <td>Optional (auto-generated if unspecified in a new graph)</td>
99
+ </tr>
100
+
101
+ <tr>
102
+ <td>description</td>
103
+ <td>short description of this Graph</td>
104
+ <td>Option</td>
105
+ </tr>
106
+
107
+ </table>
108
+
109
+ <h3>Example: Creating a New Graph</h3>
110
+
111
+ <p>The example below shows how to create a new graph or update an existing one, using Perl's LWP module.</p>
112
+
113
+ <pre>
114
+ my $ua = LWP::UserAgent->new;
115
+ $ua->post('<%= url_for '/', :full %>api/socialgame/member/register', {
116
+ number => 10,
117
+ color => '#333399'
118
+ });
119
+ </pre>
120
+
121
+ <p>If using curl:</p>
122
+
123
+ <pre>
124
+ $ curl -F number=10 <%= url_for '/', :full %>api/socialgame/member/register
125
+ </pre>
data/view/edit.erb ADDED
@@ -0,0 +1,102 @@
1
+ <form class="hxrpost form-horizontal" method="post" action="<%= url_for linkpath(graph.path, '/edit') %>" role="form">
2
+
3
+ <fieldset>
4
+
5
+ <div class="form-group">
6
+ <label for="" class="col-sm-3 control-label">Path</label>
7
+ <div class="col-sm-8">
8
+ <div class="input-group">
9
+ <span class="input-group-addon">/</span>
10
+ <input type="text" class="form-control" name="service_name" value="<%= graph.service %>" />
11
+ <span class="input-group-addon">/</span>
12
+ <input type="text" class="form-control" name="section_name" value="<%= graph.section %>" />
13
+ <span class="input-group-addon">/</span>
14
+ <input type="text" class="form-control" name="graph_name" value="<%= graph.graph %>" />
15
+ </div>
16
+ <p class="help-block">Graph's URI(service name/section name/graph name)</p>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="form-group">
21
+ <label for="" class="col-sm-3 control-label">Description</label>
22
+ <div class="col-sm-9">
23
+ <input type="text" class="form-control" name="description" value="<%= graph.description %>" />
24
+ </div>
25
+ </div>
26
+
27
+ <div class="form-group">
28
+ <label for="" class="col-sm-3 control-label">Display order</label>
29
+ <div class="col-sm-4">
30
+ <select name="sort" class="form-control">
31
+ <% (0..19).map(&:to_i).reverse.each do |i| %>
32
+ <option value="<%= i %>" <%= selected?(graph.sort, i) %>><%= i %></option>
33
+ <% end %>
34
+ </select>
35
+ <p class="help-block">19 is top</p>
36
+ </div>
37
+ </div>
38
+
39
+ <div class="form-group">
40
+ <label for="" class="col-sm-3 control-label">Data adjustment</label>
41
+ <div class="col-sm-7">
42
+ <div class="input-group">
43
+ <span class="input-group-static">Value</span>
44
+ <select name="adjust" class="form-control">
45
+ <option value="*" <%= selected?(graph.adjust, '*') %>>×</option>
46
+ <option value="/" <%= selected?(graph.adjust, '/') %>>÷</option>
47
+ </select>
48
+ <span class="input-group-static" style="padding: 0"></span>
49
+ <input type="text" class="form-control" name="adjustval" value="<%= graph.adjustval %>" />
50
+ <span class="input-group-static">unit</span>
51
+ <input type="text" class="form-control" name="unit" value="<%= graph.unit %>" />
52
+ </div>
53
+ </div>
54
+ </div>
55
+
56
+ <div class="form-group">
57
+ <label for="" class="col-sm-3 control-label">Color</label>
58
+ <div class="col-sm-3">
59
+ <div class="input-group">
60
+ <input type="text" name="color" id="form--color" class="form-control color_pallet" value="<%= graph.color %>" />
61
+ </div>
62
+ <p class="help-block">#000000-#FFFFFF</p>
63
+ </div>
64
+ </div>
65
+
66
+ <div class="form-group">
67
+ <label for="" class="col-sm-3 control-label">Type</label>
68
+ <div class="col-sm-4">
69
+ <select name="type" class="form-control">
70
+ <option value="AREA" <%= selected?(graph.type, 'AREA') %>>AREA</option>
71
+ <option value="LINE1" <%= selected?(graph.type, 'LINE1') %>>LINE</option>
72
+ <option value="LINE2" <%= selected?(graph.type, 'LINE2') %>>LINE(Bold)</option>
73
+ </select>
74
+ </div>
75
+ </div>
76
+
77
+ <div class="form-group">
78
+ <label for="" class="control-label col-sm-3">Effective range</label>
79
+ <div class="col-sm-6">
80
+ <div class="input-group">
81
+ <input type="text" class="form-control" name="llimit" value="<%= graph.llimit %>" />
82
+ <span class="input-group-static">〜</span>
83
+ <input type="text" class="form-control" name="ulimit" value="<%= graph.ulimit %>" />
84
+ </div>
85
+ </div>
86
+ </div>
87
+
88
+ </fieldset>
89
+
90
+ <hr />
91
+
92
+ <div class="form-group">
93
+ <div class="col-sm-offset-3 col-sm-6">
94
+ <input type="submit" class="btn btn-default btn-primary" value="Submit" />
95
+ <a href="<%= url_for linkpath([graph.service, graph.section]) %>" class="btn btn-default">Cancel</a>
96
+ <button type="button" class="btn btn-default btn-danger hxr_confirm_button" data-confirm="remove '<%= graph.graph %>'?" data-uri="<%= url_for linkpath(graph.path, '/delete') %>">remove</button>
97
+ </div>
98
+ </div>
99
+
100
+ </form>
101
+ <br />
102
+ <br />
@@ -0,0 +1,158 @@
1
+ <form id="complex-form" class="hxrpost form-horizontal" method="post" action="<%= url_for "/edit_complex/#{complex.id}" %>" role="form">
2
+
3
+ <fieldset>
4
+
5
+ <div class="form-group">
6
+ <label for="" class="control-label col-sm-3">Path</label>
7
+ <div class="col-sm-8">
8
+ <div class="input-group">
9
+ <span class="input-group-addon">/</span>
10
+ <input type="text" class="form-control" name="service_name" value="<%= complex.service %>" />
11
+ <span class="input-group-addon">/</span>
12
+ <input type="text" class="form-control" name="section_name" value="<%= complex.section %>" />
13
+ <span class="input-group-addon">/</span>
14
+ <input type="text" class="form-control" name="graph_name" value="<%= complex.graph %>" />
15
+ </div>
16
+ <p class="help-block">Graph's URI(service name/section name/graph name)</p>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="form-group">
21
+ <label for="" class="col-sm-3 control-label">Description</label>
22
+ <div class="col-sm-9">
23
+ <input type="text" class="form-control" name="description" value="<%= complex.description %>" />
24
+ </div>
25
+ </div>
26
+
27
+ <div class="form-group">
28
+ <label for="" class="control-label col-sm-3">Display sum up value</label>
29
+ <div class="col-sm-4">
30
+ <select name="sumup" class="form-control">
31
+ <option value="0" <%= selected?(complex.sumup, false) %>>disable</option>
32
+ <option value="1" <%= selected?(complex.sumup, true ) %>>enable</option>
33
+ </select>
34
+ </div>
35
+ </div>
36
+
37
+ <div class="form-group">
38
+ <label for="" class="control-label col-sm-3">Display order</label>
39
+ <div class="col-sm-4">
40
+ <select name="sort" class="form-control">
41
+ <% (0..19).map(&:to_i).reverse.each do |i| %>
42
+ <option value="<%= i %>" <%= selected?(complex.sort, i) %>><%= i %></option>
43
+ <% end %>
44
+ </select>
45
+ <p class="help-block">19 is top</p>
46
+ </div>
47
+ </div>
48
+
49
+ </fieldset>
50
+
51
+ <fieldset>
52
+ <legend>Data</legend>
53
+
54
+ <div class="form-group">
55
+ <label for="" class="control-label col-sm-2">Series-1</label>
56
+ <div class="col-sm-10">
57
+
58
+ <% first_row = complex.data_rows.first %>
59
+
60
+ <table class="table table-bordered table-striped">
61
+ <tr>
62
+ <th style="width: 6%;">&nbsp;</th>
63
+ <th style="width: 18%;">Type</th>
64
+ <th style="width: 62%;">Path</th>
65
+ <th style="width: 13%; text-align: center">Mode</th>
66
+ </tr>
67
+ <tr>
68
+ <td>&nbsp;</td>
69
+ <td><select name="type-1" class="form-control">
70
+ <option value="AREA" <%= selected?(first_row[:type], 'AREA') %>>AREA</option>
71
+ <option value="LINE1" <%= selected?(first_row[:type], 'LINE1') %>>LINE</option>
72
+ <option value="LINE2" <%= selected?(first_row[:type], 'LINE2') %>>LINE(Bold)</option>
73
+ </select></td>
74
+ <td><select name="path-1" class="form-control">
75
+ <% graphs.each do |graph| %>
76
+ <option value="<%= graph[:id] %>" <%= selected?(first_row[:path], graph[:id]) %>>/<%= graph[:service_name] %>/<%= graph[:section_name] %>/<%= graph[:graph_name] %></option>
77
+ <% end %>
78
+ </select></td>
79
+ </tr>
80
+ </table>
81
+ </div>
82
+ </div>
83
+
84
+ <div class="form-group">
85
+ <label for="" class="control-label col-sm-2">Series-2 and more</label>
86
+ <div class="col-sm-10">
87
+
88
+ <table class="table table-bordered table-striped" id="add-data-tbl">
89
+ <tr>
90
+ <th style="width: 6%;">&nbsp;</th>
91
+ <th style="width: 18%;">Type</th>
92
+ <th style="width: 39%;">Path</th>
93
+ <th style="width: 12%; text-align: center;">Mode</th>
94
+ <th style="width: 12%; text-align: center;">Stack</th>
95
+ <th style="width: 12%; text-align: center;">&nbsp;</th>
96
+ </tr>
97
+
98
+ <tr>
99
+ <td>&nbsp;</td>
100
+ <td><select name="type-add" id="type-add" class="form-control">
101
+ <option value="AREA">AREA</option>
102
+ <option value="LINE1">LINE</option>
103
+ <option value="LINE2">LINE(Bold)</option>
104
+ </select></t>
105
+ <td><select name="path-add" id="path-add" class="form-control">
106
+ <% graphs.each do |graph| %>
107
+ <option value="<%= graph[:id] %>" <%= selected?(first_row[:path], graph[:id]) %>>/<%= graph[:service_name] %>/<%= graph[:section_name] %>/<%= graph[:graph_name] %></option>
108
+ <% end %>
109
+ </select></td>
110
+ <td style="text-align:center;"><select name="stack-add" id="stack-add" class="form-control">
111
+ <option value="1">enable</option>
112
+ <option value="0">disable</option>
113
+ </select>
114
+ </td>
115
+ <td style="text-align:center;"><button id="add-new-row" class="btn btn-default" style="padding: 3px 14px 4px;">追加</button></td>
116
+ </tr>
117
+
118
+ <% complex.data_rows[1..-1].each do |row| %>
119
+ <tr class="can-table-order">
120
+ <td><span class="table-order-pointer table-order-up">⬆</span><span class="table-order-pointer table-order-down">⬇</span></td>
121
+ <td><%= case row[:type] when 'AREA' then 'AREA' when 'LINE1' then 'LINE' else 'LINE(Bold)' end %><input type="hidden" name="type-2[]" value="<%= row[:type] %>"/></td>
122
+ <% graph = dic[row[:graph_id]] %>
123
+ <td>/<%= graph[:service_name] %>/<%= graph[:section_name] %>/<%= graph[:graph_name] %><input type="hidden" name="path-2[]" value="<%= row[:path] %>"/></td>
124
+ <td style="text-align:center"><%= row[:stack] ? 'enable' : 'disable' %><input type="hidden" name="stack-2[]" value="<%= row[:stack] ? 1 : 0 %>" /></td>
125
+ <td style="text-align:center"><span class="table-order-remove">✖</span></td>
126
+ </tr>
127
+ <% end %>
128
+
129
+ </table>
130
+ </div>
131
+ </div>
132
+
133
+ </fieldset>
134
+
135
+ <fieldset>
136
+ <legend>Preview</legend>
137
+
138
+ <div class="form-group">
139
+ <div class="col-sm-offset-2 col-sm-10">
140
+ <div id="preview-graph"></div>
141
+ </div>
142
+ </div>
143
+
144
+ </fieldset>
145
+
146
+ <hr />
147
+
148
+ <div class="form-group">
149
+ <div class="col-sm-offset-3 col-sm-9">
150
+ <input type="submit" class="btn btn-primary" value="Submit" />
151
+ <a href="<%= url_for linkpath([complex.service, complex.section]) %>" class="btn btn-default">Cancel</a>
152
+ <button type="button" class="btn btn-danger hxr_confirm_button" data-confirm="Remove '<%= complex.graph %>'?" data-uri="<%= url_for "/delete_complex/#{complex.id}" %>">Remove</button>
153
+ </div>
154
+ </div>
155
+
156
+ </form>
157
+ <br />
158
+ <br />