birt 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9b827f61a45d0131df9e69fd89acbf05610e2cf
4
- data.tar.gz: 375aa3f7d51b810ce6b3dd41c377269df44cc9e4
3
+ metadata.gz: 0c83b4c4e93b56ff9b74eb6a2b9e82a606711312
4
+ data.tar.gz: 22d54994b83ef526d4c19efca1a1fc56da6cfe96
5
5
  SHA512:
6
- metadata.gz: aa76819f127fb816843ce80b51f997be80bb3dcca06d777bdf9994066e7b1275ec6afa16bda460d9b328758a8786f969abe97561cd2575c5c0dac6f9840a7443
7
- data.tar.gz: 3f17295c50b6d06037c6fa690c0a787762161abc205d0e4ecc65c3da35d59e4173250e6d20f268a40d9b4b7c1aa3373d15eca1d5eb7c80d053bceea99994285a
6
+ metadata.gz: 884bee3472036cbca128dca015950331e64ee3d65c542f5df98e801d9254a2e5dc6c0bb2bbdbc5ffb0678f63ea62adc2e8cdfab03743fa864899cba055810e92
7
+ data.tar.gz: 92eb494cd27a5445d1ae71dc9cdf6a18877c290ef2731232f7a01ed0e5e2eab6fcbaac0ebf3c7f7496018a08650b636876dffcbd47cfc463e0871d7887d62578
@@ -4,5 +4,4 @@
4
4
  //= require birt/birt
5
5
 
6
6
  var birt = new Birt();
7
- birt.run();
8
-
7
+ birt.run();
@@ -29,11 +29,8 @@ var Birt = (function () {
29
29
  Birt.prototype.onCreate = function () {
30
30
  $birt = $('.birt');
31
31
 
32
- $birt.append("<ul class='birt-menus'></ul>");
33
32
  $menus = $birt.find(".birt-menus");
34
33
 
35
- $birt.append("<div class='birt-reports'></div>");
36
- $reports = $birt.find(".birt-reports");
37
34
  };
38
35
 
39
36
  /**
@@ -46,24 +43,16 @@ var Birt = (function () {
46
43
  $.birtLoading();
47
44
  $.ajax(
48
45
  {
49
- url: '/birt/api.json?_report={0}'.format(_this.file_name),
46
+ url: '/birt/api?_report={0}'.format(_this.file_name),
50
47
  type: 'GET',
51
48
  success: function (data) {
52
49
  $.birtLoading('hide');
53
- rptDesignJsonData = data.rpt_design;
54
- _this.showDisplayName();
55
- console.log(data.rpt_design.tables);
56
-
57
- var tables = data.rpt_design.tables;
58
- for (var i = 0; i < tables.length; i++) {
59
- var table = tables[i];
60
- _this.showTable(table);
61
- }
62
-
63
- var lineCharts = data.rpt_design.line_charts;
64
- for (var i = 0; i < lineCharts.length; i++) {
65
- _this.showLineChart(lineCharts[i]);
66
- }
50
+ $birt.append(data);
51
+ $reports = $birt.find(".birt-reports");
52
+ $reports.find(".birt-line-charts").each(function () {
53
+ _this.showLineChart($(this).data('line-chart'));
54
+ });
55
+
67
56
  },
68
57
  error: function (data) {
69
58
  $.birtLoading('hide');
@@ -78,17 +67,20 @@ var Birt = (function () {
78
67
  Birt.prototype.getMenus = function () {
79
68
  var menus = _this.getMenusFromCache();
80
69
  if (menus) {
81
- _this.showMenus(menus);
70
+ $birt.prepend(menus);
71
+ $birt.find("ul.birt-menus li.item").removeClass('active');
72
+ $birt.find("ul.birt-menus li.item[data-rptdesign='{0}']".format(_this.file_name.replace(".rptdesign",""))).addClass('active');
73
+
82
74
  return;
83
75
  }
84
76
  $.ajax(
85
77
  {
86
- url: '/birt/api/menus.json',
78
+ url: '/birt/api/menus?current='+_this.file_name.replace(".rptdesign", ""),
87
79
  type: 'GET',
88
80
  success: function (data) {
89
81
  console.log(data);
90
- _this.showMenus(data.menus);
91
- _this.putMenusToCache(data.menus);
82
+ $birt.prepend(data);
83
+ _this.putMenusToCache(data);
92
84
  },
93
85
  error: function (data) {
94
86
  }
@@ -102,79 +94,15 @@ var Birt = (function () {
102
94
  Birt.prototype.getMenusFromCache = function () {
103
95
  var menus = localStorage.getItem("birt_menus");
104
96
  console.log(menus);
105
- return menus ? JSON.parse(menus) : null;
97
+ return menus;
106
98
  };
107
99
 
108
100
  /**
109
101
  * 将菜单数据写入缓存
110
102
  * @param menus
111
103
  */
112
- Birt.prototype.putMenusToCache = function (menus) {
113
- localStorage.setItem("birt_menus", JSON.stringify(menus));
114
- };
115
-
116
- /**
117
- * 显示报表的名称
118
- */
119
- Birt.prototype.showDisplayName = function () {
120
- $reports.append("<h2 class='display-name'>{0}</h2>".format(rptDesignJsonData.display_name));
121
- };
122
-
123
- /**
124
- * 显示报表菜单
125
- * @param menus
126
- */
127
- Birt.prototype.showMenus = function (menus) {
128
- for (var i = 0; i < menus.length; i++) {
129
- var menu = menus[i];
130
- var active = menu.file_name == _this.file_name.replace(".rptdesign", "") ? 'active' : '';
131
- $menus.append("<li class='item {1}'><a href='/?_report={2}'><span class='icon-note'></span>&nbsp;{0}</a></li>".format(menu.display_name, active, menu.file_name));
132
- }
133
- };
134
-
135
-
136
- /**
137
- * 显示行
138
- * @param rowData
139
- * @param cellName
140
- * @returns {string}
141
- */
142
- Birt.prototype.showTableRow = function (rowData, cellName) {
143
-
144
- var row_html = '<tr>';
145
- for (var i = 0; i < rowData.length; i++) {
146
- if (cellName == 'th') {
147
- row_html += "<th>{0}</th>".format(rowData[i]);
148
- } else {
149
- row_html += "<td>{0}</td>".format(rowData[i]);
150
- }
151
- }
152
- row_html += '</tr>';
153
- return row_html;
154
- };
155
-
156
- /**
157
- * 显示表格
158
- * @param table
159
- * @returns {string}
160
- */
161
- Birt.prototype.showTable = function (table) {
162
- var table_html = '<table id="report_{0}" class="birt-table"> '.format(table.id);
163
-
164
- for (var i = 0; i < table.header.length; i++) {
165
- table_html += _this.showTableRow(table.header[i], 'th');
166
- }
167
-
168
-
169
- for (var i = 0; i < table.detail.length; i++) {
170
- table_html += _this.showTableRow(table.detail[i], 'td');
171
- }
172
-
173
- table_html += "</table>";
174
-
175
- $reports.append(table_html);
176
- console.log(table);
177
- return table_html;
104
+ Birt.prototype.putMenusToCache = function (menus_html) {
105
+ localStorage.setItem("birt_menus", menus_html);
178
106
  };
179
107
 
180
108
 
@@ -0,0 +1,14 @@
1
+ .birt-reports
2
+ h2.display-name=@rpt_design.display_name
3
+ - @rpt_design.reports[:tables].values.each do |table|
4
+ table.birt-table(id="report_#{table.id}")
5
+ - parse_table_header(table.header).each do |header|
6
+ tr
7
+ - header.each do |cell|
8
+ th=cell
9
+ - parse_table_detail(table.detail, table).each do |detail|
10
+ tr
11
+ - detail.each do |cell|
12
+ td=cell
13
+ - @rpt_design.reports[:line_charts].values.inject([]) { |acc, line_chart| acc<<line_chart.json; acc }.each do |linechart|
14
+ div(id="report_#{linechart[:id]}" class="birt-line-charts" data-line-chart="#{linechart.to_json}")
@@ -0,0 +1,7 @@
1
+ ul.birt-menus
2
+ -@menus.each do |menu|
3
+ li.item(class="#{'active' if params[:current]==menu[:file_name]}" data-rptdesign="#{menu[:file_name]}")
4
+ a(href='/?_report=#{menu[:file_name]}')
5
+ span.icon-note
6
+ |&nbsp;
7
+ =menu[:display_name]
@@ -11,11 +11,18 @@ module Birt
11
11
  #数据解析
12
12
  @rpt_design.parse_rpt
13
13
  @rpt_design.data_sets.values.each { |data_set| data_set.data_set_result }
14
+
15
+ response do |format|
16
+ format.html layout: nil
17
+ format.json
18
+ end
14
19
  end
15
20
 
16
21
  #获取文件目录列表
17
22
  def menus
18
- @menus = Birt.menus
23
+ @menus = Rails.cache.fetch('birt-menus', expires_in: 1.minutes) do
24
+ Birt.menus
25
+ end
19
26
  end
20
27
 
21
28
  end
data/lib/birt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Birt
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  module Core
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: birt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-15 00:00:00.000000000 Z
11
+ date: 2015-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: slim
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.6
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.6
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +140,6 @@ files:
126
140
  - app/assets/javascripts/birt.js
127
141
  - app/assets/javascripts/birt/birt.js
128
142
  - app/assets/javascripts/birt/components/loading.js
129
- - app/assets/javascripts/birt/jade/jade.jade
130
143
  - app/assets/javascripts/birt/utils/string.js
131
144
  - app/assets/stylesheets/birt.scss
132
145
  - app/assets/stylesheets/birt/base/constant.scss
@@ -136,7 +149,9 @@ files:
136
149
  - app/assets/stylesheets/birt/components/menus.scss
137
150
  - app/assets/stylesheets/birt/components/reports.scss
138
151
  - app/assets/stylesheets/birt/components/table.scss
152
+ - app/views/birt/api/index.html.slim
139
153
  - app/views/birt/api/index.json.jbuilder
154
+ - app/views/birt/api/menus.html.slim
140
155
  - app/views/birt/api/menus.json.jbuilder
141
156
  - config/birt.yml
142
157
  - config/routes.rb
@@ -1,6 +0,0 @@
1
- doctype html
2
- html
3
- head
4
- title learning jade
5
- body
6
- h2 学习jade