treport 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/controllers/connects_controller.rb +56 -0
- data/app/controllers/dictionaries_controller.rb +56 -0
- data/app/controllers/reports_controller.rb +62 -0
- data/app/controllers/requirements_controller.rb +60 -0
- data/app/controllers/series_controller.rb +60 -0
- data/app/models/.keep +0 -0
- data/app/models/connect.rb +26 -0
- data/app/models/dictionary.rb +4 -0
- data/app/models/report.rb +34 -0
- data/app/models/requirement.rb +42 -0
- data/app/models/series.rb +4 -0
- data/app/views/connects/_form.html.erb +68 -0
- data/app/views/connects/edit.html.erb +1 -0
- data/app/views/connects/index.html.erb +48 -0
- data/app/views/connects/new.html.erb +1 -0
- data/app/views/dictionaries/_form.html.erb +49 -0
- data/app/views/dictionaries/edit.html.erb +1 -0
- data/app/views/dictionaries/index.html.erb +42 -0
- data/app/views/dictionaries/new.html.erb +1 -0
- data/app/views/layouts/report.html.erb +54 -0
- data/app/views/reports/_form.html.erb +65 -0
- data/app/views/reports/edit.html.erb +1 -0
- data/app/views/reports/index.html.erb +49 -0
- data/app/views/reports/new.html.erb +1 -0
- data/app/views/requirements/_form.html.erb +72 -0
- data/app/views/requirements/edit.html.erb +1 -0
- data/app/views/requirements/index.html.erb +51 -0
- data/app/views/requirements/new.html.erb +1 -0
- data/app/views/series/_form.html.erb +47 -0
- data/app/views/series/edit.html.erb +1 -0
- data/app/views/series/index.html.erb +40 -0
- data/app/views/series/new.html.erb +1 -0
- data/app/views/templates/public_one.html.erb +75 -0
- data/app/views/templates/public_two.html.erb +76 -0
- data/app/views/templates/text.html.erb +9 -0
- data/db/migrate/20160607002137_create_connects.rb +15 -0
- data/db/migrate/20160608123333_create_reports.rb +15 -0
- data/db/migrate/20160608124539_create_requirements.rb +16 -0
- data/db/migrate/20160608124549_create_dictionaries.rb +12 -0
- data/db/migrate/20160608124602_create_series.rb +11 -0
- data/lib/generators/report/install_generator.rb +26 -0
- data/lib/treport/db.rb +49 -0
- data/lib/treport.rb +9 -0
- data/public/report/css/AdminLTE.css +4906 -0
- data/public/report/css/AdminLTE.min.css +7 -0
- data/public/report/css/bootstrap.min.css +6 -0
- data/public/report/css/skins/_all-skins.css +1799 -0
- data/public/report/css/skins/_all-skins.min.css +1 -0
- data/public/report/js/app.js +44 -0
- data/public/report/js/echarts.min.js +35 -0
- data/treport.gemspec +12 -0
- metadata +94 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
|
+
<title>Report</title>
|
7
|
+
<%= stylesheet_link_tag "application" %>
|
8
|
+
<%= javascript_include_tag "application" %>
|
9
|
+
<%= csrf_meta_tags %>
|
10
|
+
<link rel="stylesheet" href="/report/css/bootstrap.min.css">
|
11
|
+
<link rel="stylesheet" href="/report/css/AdminLTE.min.css">
|
12
|
+
<link rel="stylesheet" href="/report/css/skins/_all-skins.min.css">
|
13
|
+
</head>
|
14
|
+
<body class="hold-transition skin-blue sidebar-mini">
|
15
|
+
<div class="wrapper">
|
16
|
+
<header class="main-header">
|
17
|
+
<!-- Logo -->
|
18
|
+
<a href="/" class="logo">
|
19
|
+
<span class="logo-lg"><b>Report</b></span>
|
20
|
+
</a>
|
21
|
+
</header>
|
22
|
+
<!-- Left side column. contains the logo and sidebar -->
|
23
|
+
<aside class="main-sidebar">
|
24
|
+
<!-- sidebar: style can be found in sidebar.less -->
|
25
|
+
<section class="sidebar">
|
26
|
+
<!-- sidebar menu: : style can be found in sidebar.less -->
|
27
|
+
<ul class="sidebar-menu">
|
28
|
+
<li class="header">MAIN NAVIGATION</li>
|
29
|
+
<li class="treeview">
|
30
|
+
<a href="/connects">
|
31
|
+
<span>Connect</span>
|
32
|
+
</a>
|
33
|
+
</li>
|
34
|
+
<li class="treeview">
|
35
|
+
<a href="/reports">
|
36
|
+
<span>Report</span>
|
37
|
+
</a>
|
38
|
+
</li>
|
39
|
+
</ul>
|
40
|
+
</section>
|
41
|
+
<!-- /.sidebar -->
|
42
|
+
</aside>
|
43
|
+
<!-- Content Wrapper. Contains page content -->
|
44
|
+
<div class="content-wrapper">
|
45
|
+
<%= yield %>
|
46
|
+
<!-- /.content -->
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
<!-- ./wrapper -->
|
50
|
+
<!-- ./wrapper -->
|
51
|
+
<script src='/report/js/app.js'></script>
|
52
|
+
</body>
|
53
|
+
</html>
|
54
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<% if @report.errors.any? %>
|
2
|
+
<% errors = "" %>
|
3
|
+
<% @report.errors.messages.values.each_with_index { |message, index| errors = errors +
|
4
|
+
"#{index+1}.#{message.join(";")}; " } %>
|
5
|
+
<h5 style="color: red;"><%= errors %></h5>
|
6
|
+
<% end %>
|
7
|
+
<section class="content-header">
|
8
|
+
<h1>
|
9
|
+
报表管理
|
10
|
+
</h1>
|
11
|
+
</section>
|
12
|
+
<!-- Main content -->
|
13
|
+
<section class="content">
|
14
|
+
<div class="row">
|
15
|
+
<!-- right column -->
|
16
|
+
<div class="col-md-6">
|
17
|
+
<!-- general form elements disabled -->
|
18
|
+
<div class="box box-primary">
|
19
|
+
<div class="box-header with-border">
|
20
|
+
<h3 class="box-title">报表管理</h3>
|
21
|
+
</div>
|
22
|
+
<!-- /.box-header -->
|
23
|
+
<div class="box-body">
|
24
|
+
<%= form_for(@report) do |f| %>
|
25
|
+
<div class="form-group">
|
26
|
+
<label>报表名称</label>
|
27
|
+
<%= f.text_field :name, class: "form-control", placeholder: "name" %>
|
28
|
+
</div>
|
29
|
+
<div class="form-group">
|
30
|
+
<label>数据库链接名称</label>
|
31
|
+
<%= f.select :connect_id, options_for_select(Connect.connect_options, @report.connect_id), {}, class: "form-control" %>
|
32
|
+
</div>
|
33
|
+
<div class="form-group">
|
34
|
+
<label> Sql内容 </label>
|
35
|
+
<%= f.text_area :sql_code, class: "form-control", placeholder: "sql_code" %>
|
36
|
+
</div>
|
37
|
+
<div class="form-group">
|
38
|
+
<%= f.check_box :is_sql_category %><label> 是否是sql获取 </label>
|
39
|
+
</div>
|
40
|
+
<div class="form-group">
|
41
|
+
<label> 分类名 </label>
|
42
|
+
<%= f.text_field :category_name, class: "form-control", placeholder: "category_name" %>
|
43
|
+
</div>
|
44
|
+
<div class="form-group">
|
45
|
+
<label> 模板地址 </label>
|
46
|
+
<%= f.text_field :template, class: "form-control", placeholder: "category_name" %>
|
47
|
+
</div>
|
48
|
+
<div class="form-group">
|
49
|
+
<label> 事件url </label>
|
50
|
+
<%= f.text_field :url, class: "form-control", placeholder: "url" %>
|
51
|
+
</div>
|
52
|
+
<div class="box-footer">
|
53
|
+
<button type="submit" class="btn btn-primary">提交</button>
|
54
|
+
</div>
|
55
|
+
<% end %>
|
56
|
+
</div>
|
57
|
+
<!-- /.box-body -->
|
58
|
+
</div>
|
59
|
+
<!-- /.box -->
|
60
|
+
</div>
|
61
|
+
<!--/.col (right) -->
|
62
|
+
</div>
|
63
|
+
<!-- /.row -->
|
64
|
+
</section>
|
65
|
+
<!-- /.content -->
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<section class="content-header">
|
2
|
+
<h1>
|
3
|
+
报表管理
|
4
|
+
</h1>
|
5
|
+
</section>
|
6
|
+
<!-- Main content -->
|
7
|
+
<section class="content">
|
8
|
+
<div class="row">
|
9
|
+
<div class="col-xs-12">
|
10
|
+
<div class="box">
|
11
|
+
<div class="box-header">
|
12
|
+
<h3 class="box-title">报表管理</h3>
|
13
|
+
</div>
|
14
|
+
<!-- /.box-header -->
|
15
|
+
<div class="box-body table-responsive no-padding">
|
16
|
+
<%= link_to '添加报表', new_report_path, class: "btn" %>
|
17
|
+
<table class="table table-hover">
|
18
|
+
<tr>
|
19
|
+
<th>报表名称</th>
|
20
|
+
<th>数据库链接名称</th>
|
21
|
+
<th>Sql内容</th>
|
22
|
+
<th>是否是sql获取</th>
|
23
|
+
<th>模板</th>
|
24
|
+
<th>分类名</th>
|
25
|
+
<th colspan="5"></th>
|
26
|
+
</tr>
|
27
|
+
<% @reports.each do |report| %>
|
28
|
+
<tr>
|
29
|
+
<td><%= report.name %></td>
|
30
|
+
<td><%= report.connect.name %></td>
|
31
|
+
<td><%= report.sql_code %></td>
|
32
|
+
<td><%= report.is_sql_category %></td>
|
33
|
+
<td><%= report.template %></td>
|
34
|
+
<td><%= report.category_name %></td>
|
35
|
+
<td><%= link_to '修改', edit_report_path(report) %></td>
|
36
|
+
<td><%= link_to '条件', report_requirements_path(report) %></td>
|
37
|
+
<td><%= link_to '系列', report_series_index_path(report) %></td>
|
38
|
+
<td><%= link_to '分类字典', dictionaries_path(resource_type: "Report", resource_id: report.id) %></td>
|
39
|
+
<td><%= link_to '删除', report, method: :delete, data: {confirm: '你确定要删除么?'} %></td>
|
40
|
+
</tr>
|
41
|
+
<% end %>
|
42
|
+
</table>
|
43
|
+
</div>
|
44
|
+
<!-- /.box-body -->
|
45
|
+
</div>
|
46
|
+
<!-- /.box -->
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
</section>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<% if @requirement.errors.any? %>
|
2
|
+
<% errors = "" %>
|
3
|
+
<% @requirement.errors.messages.values.each_with_index { |message, index| errors = errors +
|
4
|
+
"#{index+1}.#{message.join(";")}; " } %>
|
5
|
+
<h5 style="color: red;"><%= errors %></h5>
|
6
|
+
<% end %>
|
7
|
+
<% if @report.errors.any? %>
|
8
|
+
<% errors = "" %>
|
9
|
+
<% @report.errors.messages.values.each_with_index { |message, index| errors = errors +
|
10
|
+
"#{index+1}.#{message.join(";")}; " } %>
|
11
|
+
<h5 style="color: red;"><%= errors %></h5>
|
12
|
+
<% end %>
|
13
|
+
<section class="content-header">
|
14
|
+
<h1>
|
15
|
+
报表管理
|
16
|
+
</h1>
|
17
|
+
</section>
|
18
|
+
<!-- Main content -->
|
19
|
+
<section class="content">
|
20
|
+
<div class="row">
|
21
|
+
<!-- right column -->
|
22
|
+
<div class="col-md-6">
|
23
|
+
<!-- general form elements disabled -->
|
24
|
+
<div class="box box-primary">
|
25
|
+
<div class="box-header with-border">
|
26
|
+
<h3 class="box-title">报表管理</h3>
|
27
|
+
</div>
|
28
|
+
<!-- /.box-header -->
|
29
|
+
<div class="box-body">
|
30
|
+
<%= form_for(@requirement, url: (@requirement.id ? report_requirement_path(@report, @requirement) : report_requirements_path(@report))) do |f| %>
|
31
|
+
<div class="form-group">
|
32
|
+
<label>条件名</label>
|
33
|
+
<%= f.text_field :name, class: "form-control", placeholder: "name" %>
|
34
|
+
</div>
|
35
|
+
<div class="form-group">
|
36
|
+
<label>条件列名</label>
|
37
|
+
<%= f.text_field :sql_key, class: "form-control", placeholder: "sql_key" %>
|
38
|
+
</div>
|
39
|
+
<div class="form-group">
|
40
|
+
<label> 被替换的sql </label>
|
41
|
+
<%= f.text_field :sql_default, class: "form-control", placeholder: "sql_default" %>
|
42
|
+
</div>
|
43
|
+
<div class="form-group">
|
44
|
+
<label> 替换成的sql </label>
|
45
|
+
<%= f.text_field :sql_replace, class: "form-control", placeholder: "sql_replace" %>
|
46
|
+
</div>
|
47
|
+
<div class="form-group">
|
48
|
+
<label> 表单类型 </label>
|
49
|
+
<%= f.select :form_type, options_for_select(Requirement.form_type_options, @requirement.form_type), {}, class: "form-control" %>
|
50
|
+
</div>
|
51
|
+
<div class="form-group">
|
52
|
+
<label> 下拉数据源类型 </label>
|
53
|
+
<%= f.select :sql_type, options_for_select(Requirement.sql_type_options, @requirement.sql_type), {} , class: "form-control" %>
|
54
|
+
</div>
|
55
|
+
<div class="form-group">
|
56
|
+
<label> sql查询代码 </label>
|
57
|
+
<%= f.text_area :sql_str, class: "form-control" %>
|
58
|
+
</div>
|
59
|
+
<div class="box-footer">
|
60
|
+
<button type="submit" class="btn btn-primary">提交</button>
|
61
|
+
</div>
|
62
|
+
<% end %>
|
63
|
+
</div>
|
64
|
+
<!-- /.box-body -->
|
65
|
+
</div>
|
66
|
+
<!-- /.box -->
|
67
|
+
</div>
|
68
|
+
<!--/.col (right) -->
|
69
|
+
</div>
|
70
|
+
<!-- /.row -->
|
71
|
+
</section>
|
72
|
+
<!-- /.content -->
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<section class="content-header">
|
2
|
+
<h1>
|
3
|
+
条件管理
|
4
|
+
</h1>
|
5
|
+
</section>
|
6
|
+
<!-- Main content -->
|
7
|
+
<section class="content">
|
8
|
+
<div class="row">
|
9
|
+
<div class="col-xs-12">
|
10
|
+
<div class="box">
|
11
|
+
<div class="box-header">
|
12
|
+
<h3 class="box-title">条件管理</h3>
|
13
|
+
</div>
|
14
|
+
<!-- /.box-header -->
|
15
|
+
<div class="box-body table-responsive no-padding">
|
16
|
+
<%= link_to '添加条件', new_report_requirement_path, class: "btn" %>
|
17
|
+
<table class="table table-hover">
|
18
|
+
<tr>
|
19
|
+
<th>ID</th>
|
20
|
+
<th>条件名称</th>
|
21
|
+
<th>条件列名</th>
|
22
|
+
<th>被替换的sql</th>
|
23
|
+
<th>sql替换成</th>
|
24
|
+
<th>表单类型</th>
|
25
|
+
<th>下拉数据源类型</th>
|
26
|
+
<th>sql查询代码</th>
|
27
|
+
<th colspan="3"></th>
|
28
|
+
</tr>
|
29
|
+
<% @requirements.each do |requirement| %>
|
30
|
+
<tr>
|
31
|
+
<td><%= requirement.id %></td>
|
32
|
+
<td><%= requirement.name %></td>
|
33
|
+
<td><%= requirement.sql_key %></td>
|
34
|
+
<td><%= requirement.sql_default %></td>
|
35
|
+
<td><%= requirement.sql_replace %></td>
|
36
|
+
<td><%= requirement.form_type_name %></td>
|
37
|
+
<td><%= requirement.sql_type_name %></td>
|
38
|
+
<td><%= requirement.sql_str %></td>
|
39
|
+
<td><%= link_to '修改', edit_report_requirement_path(@report, requirement) %></td>
|
40
|
+
<td><%= link_to '字典', dictionaries_path(resource_type: "Requirement", resource_id: requirement.id) %></td>
|
41
|
+
<td><%= link_to '删除', report_requirement_path(@report, requirement), method: :delete, data: {confirm: '你确定要删除么?'} %></td>
|
42
|
+
</tr>
|
43
|
+
<% end %>
|
44
|
+
</table>
|
45
|
+
</div>
|
46
|
+
<!-- /.box-body -->
|
47
|
+
</div>
|
48
|
+
<!-- /.box -->
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
</section>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<% if @series.errors.any? %>
|
2
|
+
<% errors = "" %>
|
3
|
+
<% @series.errors.messages.values.each_with_index { |message, index| errors = errors +
|
4
|
+
"#{index+1}.#{message.join(";")}; " } %>
|
5
|
+
<h5 style="color: red;"><%= errors %></h5>
|
6
|
+
<% end %>
|
7
|
+
<!-- Content Header (Page header) -->
|
8
|
+
<section class="content-header">
|
9
|
+
<h1>
|
10
|
+
字典管理
|
11
|
+
</h1>
|
12
|
+
</section>
|
13
|
+
<!-- Main content -->
|
14
|
+
<section class="content">
|
15
|
+
<div class="row">
|
16
|
+
<!-- right column -->
|
17
|
+
<div class="col-md-6">
|
18
|
+
<!-- general form elements disabled -->
|
19
|
+
<div class="box box-primary">
|
20
|
+
<div class="box-header with-border">
|
21
|
+
<h3 class="box-title">字典管理</h3>
|
22
|
+
</div>
|
23
|
+
<!-- /.box-header -->
|
24
|
+
<div class="box-body">
|
25
|
+
<%= form_for(@series, url: (@series.id ? report_series_path(@report, @series) : report_series_index_path(@report))) do |f| %>
|
26
|
+
<div class="form-group">
|
27
|
+
<label>系列名</label>
|
28
|
+
<%= f.text_field :name, class: "form-control", placeholder: "name" %>
|
29
|
+
</div>
|
30
|
+
<div class="form-group">
|
31
|
+
<label>sql中的对应标识</label>
|
32
|
+
<%= f.text_field :sql_key, class: "form-control", placeholder: "sql_key" %>
|
33
|
+
</div>
|
34
|
+
<div class="box-footer">
|
35
|
+
<button type="submit" class="btn btn-primary">提交</button>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
38
|
+
</div>
|
39
|
+
<!-- /.box-body -->
|
40
|
+
</div>
|
41
|
+
<!-- /.box -->
|
42
|
+
</div>
|
43
|
+
<!--/.col (right) -->
|
44
|
+
</div>
|
45
|
+
<!-- /.row -->
|
46
|
+
</section>
|
47
|
+
<!-- /.content -->
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<section class="content-header">
|
2
|
+
<h1>
|
3
|
+
系列管理
|
4
|
+
</h1>
|
5
|
+
</section>
|
6
|
+
<!-- Main content -->
|
7
|
+
<section class="content">
|
8
|
+
<div class="row">
|
9
|
+
<div class="col-xs-12">
|
10
|
+
<div class="box">
|
11
|
+
<div class="box-header">
|
12
|
+
<h3 class="box-title">系列管理</h3>
|
13
|
+
</div>
|
14
|
+
<!-- /.box-header -->
|
15
|
+
<div class="box-body table-responsive no-padding">
|
16
|
+
<%= link_to '添加系列', new_report_series_path, class: "btn" %>
|
17
|
+
<table class="table table-hover">
|
18
|
+
<tr>
|
19
|
+
<th>ID</th>
|
20
|
+
<th>系列名</th>
|
21
|
+
<th>Sql列名</th>
|
22
|
+
<th colspan="2"></th>
|
23
|
+
</tr>
|
24
|
+
<% @series.each do |series| %>
|
25
|
+
<tr>
|
26
|
+
<td><%= series.id %></td>
|
27
|
+
<td><%= series.name %></td>
|
28
|
+
<td><%= series.sql_key %></td>
|
29
|
+
<td><%= link_to '修改', edit_report_series_path(@report, series) %></td>
|
30
|
+
<td><%= link_to '删除', report_series_path(@report, series), method: :delete, data: {confirm: '你确定要删除么?'} %></td>
|
31
|
+
</tr>
|
32
|
+
<% end %>
|
33
|
+
</table>
|
34
|
+
</div>
|
35
|
+
<!-- /.box-body -->
|
36
|
+
</div>
|
37
|
+
<!-- /.box -->
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
</section>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render 'form' %>
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<div id="main" style="height: 400px;"></div>
|
2
|
+
<script type="application/javascript" src="/report/js/echarts.min.js"></script>
|
3
|
+
<script type="text/javascript">
|
4
|
+
var myChart = echarts.init(document.getElementById('main'));
|
5
|
+
var option = {
|
6
|
+
title : {
|
7
|
+
text: '某站点用户访问来源',
|
8
|
+
x:'center'
|
9
|
+
},
|
10
|
+
tooltip : {
|
11
|
+
trigger: 'item'
|
12
|
+
},
|
13
|
+
legend: {
|
14
|
+
orient : 'vertical',
|
15
|
+
x : 'left',
|
16
|
+
data: [],
|
17
|
+
textStyle:{
|
18
|
+
color: '#000000'
|
19
|
+
}
|
20
|
+
},
|
21
|
+
toolbox: {
|
22
|
+
show : true,
|
23
|
+
feature : {
|
24
|
+
mark : {show: true},
|
25
|
+
dataView : {show: true, readOnly: true},
|
26
|
+
magicType : {
|
27
|
+
show: true,
|
28
|
+
type: ['pie'],
|
29
|
+
option: {
|
30
|
+
funnel: {
|
31
|
+
x: '25%',
|
32
|
+
width: '50%',
|
33
|
+
funnelAlign: 'left'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
},
|
37
|
+
restore : {show: true},
|
38
|
+
saveAsImage : {show: true}
|
39
|
+
}
|
40
|
+
},
|
41
|
+
calculable : true,
|
42
|
+
series : []
|
43
|
+
}
|
44
|
+
|
45
|
+
var result = <%= raw @data[:charts].to_json %>;
|
46
|
+
for(var i=0; i<result.length; i++){
|
47
|
+
var data = result[i].data;
|
48
|
+
var series = {
|
49
|
+
type: "pie",
|
50
|
+
radius: '55%',
|
51
|
+
center: ['50%', '60%'],
|
52
|
+
data: [],
|
53
|
+
itemStyle: {
|
54
|
+
emphasis: {
|
55
|
+
shadowBlur: 10,
|
56
|
+
shadowOffsetX: 0,
|
57
|
+
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
for(var j=0; j<data.length; j++){
|
62
|
+
option.legend.data.push(data[j].category_name);
|
63
|
+
series.data.push({value: data[j].value, name: data[j].category_name});
|
64
|
+
}
|
65
|
+
option.series.push(series);
|
66
|
+
}
|
67
|
+
|
68
|
+
myChart.setOption(option);
|
69
|
+
|
70
|
+
function eConsole(param) {
|
71
|
+
console.log(param);
|
72
|
+
}
|
73
|
+
|
74
|
+
myChart.on("click", eConsole);
|
75
|
+
</script>
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<div id="main" style="height: 400px;"></div>
|
2
|
+
<script type="application/javascript" src="/report/js/echarts.min.js"></script>
|
3
|
+
<script type="text/javascript">
|
4
|
+
var myChart = echarts.init(document.getElementById('main'));
|
5
|
+
var option = {
|
6
|
+
tooltip : {
|
7
|
+
trigger: 'axis',
|
8
|
+
axisPointer : { // 坐标轴指示器,坐标轴触发有效
|
9
|
+
type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
10
|
+
}
|
11
|
+
},
|
12
|
+
toolbox: {
|
13
|
+
show : true,
|
14
|
+
feature : {
|
15
|
+
mark : {show: true},
|
16
|
+
dataView : {show: true, readOnly: false},
|
17
|
+
magicType: {show: true, type: ['line', 'bar']},
|
18
|
+
restore : {show: true},
|
19
|
+
saveAsImage : {show: true}
|
20
|
+
}
|
21
|
+
},
|
22
|
+
calculable : true,
|
23
|
+
legend: {
|
24
|
+
data: []
|
25
|
+
},
|
26
|
+
grid: {
|
27
|
+
left: '3%',
|
28
|
+
right: '4%',
|
29
|
+
bottom: '3%',
|
30
|
+
containLabel: true
|
31
|
+
},
|
32
|
+
xAxis: [
|
33
|
+
{
|
34
|
+
type : 'category',
|
35
|
+
data : []
|
36
|
+
}
|
37
|
+
],
|
38
|
+
yAxis: [
|
39
|
+
{
|
40
|
+
type : 'value'
|
41
|
+
}
|
42
|
+
],
|
43
|
+
series : []
|
44
|
+
}
|
45
|
+
|
46
|
+
var result = <%= raw @data[:charts].to_json %>;
|
47
|
+
for(var i=0; i<result.length; i++){
|
48
|
+
option.legend.data.push(result[i].series_name);
|
49
|
+
var data = result[i].data;
|
50
|
+
var series = {
|
51
|
+
name: result[i].series_name,
|
52
|
+
type: "bar", //"line"
|
53
|
+
label: {
|
54
|
+
normal: {
|
55
|
+
show: true,
|
56
|
+
position: 'top'
|
57
|
+
}
|
58
|
+
},
|
59
|
+
data: [],
|
60
|
+
markLine: {data: [{type: 'average', name: '平均值'}]}
|
61
|
+
}
|
62
|
+
for(var j=0; j<data.length; j++){
|
63
|
+
option.xAxis[0].data.push(data[j].category_name);
|
64
|
+
series.data.push(data[j].value);
|
65
|
+
}
|
66
|
+
option.series.push(series);
|
67
|
+
}
|
68
|
+
|
69
|
+
myChart.setOption(option);
|
70
|
+
|
71
|
+
function eConsole(param) {
|
72
|
+
console.log(param);
|
73
|
+
}
|
74
|
+
|
75
|
+
myChart.on("click", eConsole);
|
76
|
+
</script>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateConnects < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :connects do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :adapter
|
6
|
+
t.string :database
|
7
|
+
t.string :username
|
8
|
+
t.string :password
|
9
|
+
t.string :host
|
10
|
+
t.string :port
|
11
|
+
|
12
|
+
t.timestamps null: false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateReports < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :reports do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :sql_code
|
6
|
+
t.boolean :is_sql_category
|
7
|
+
t.string :category_name
|
8
|
+
t.references :connect, index: true, foreign_key: true
|
9
|
+
t.string :template
|
10
|
+
t.string :url
|
11
|
+
|
12
|
+
t.timestamps null: false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateRequirements < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :requirements do |t|
|
4
|
+
t.references :report, index: true, foreign_key: true
|
5
|
+
t.string :name
|
6
|
+
t.string :sql_key
|
7
|
+
t.string :sql_default
|
8
|
+
t.string :sql_replace
|
9
|
+
t.text :sql_str
|
10
|
+
t.integer :sql_type
|
11
|
+
t.integer :form_type
|
12
|
+
|
13
|
+
t.timestamps null: false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module Report
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
desc "install report."
|
7
|
+
|
8
|
+
def report_initializer_file
|
9
|
+
filePath = File.expand_path(File.dirname(File.dirname(__FILE__)))
|
10
|
+
currPath = File.expand_path("../../", filePath)
|
11
|
+
FileUtils.cp_r "#{currPath}/db/migrate", "db/"
|
12
|
+
FileUtils.cp_r "#{currPath}/app/controllers", "app/"
|
13
|
+
FileUtils.cp_r "#{currPath}/app/models", "app/"
|
14
|
+
FileUtils.cp_r "#{currPath}/app/views", "app/"
|
15
|
+
FileUtils.cp_r "#{currPath}/app/views", "app/"
|
16
|
+
FileUtils.cp_r "#{currPath}/public/report", "public/"
|
17
|
+
puts "完成report模块构建"
|
18
|
+
route("resources :connects")
|
19
|
+
route("resources :dictionaries")
|
20
|
+
route("resources :reports do resources :series and resources :requirements end")
|
21
|
+
puts "report routes created!"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|