birt 0.2.1 → 0.2.2

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: 9b7b2e02b34b0e0a11a383755b89d6949439b5ef
4
- data.tar.gz: 63c116c33dc69424de1d89a063310384afd7ebd2
3
+ metadata.gz: d17fdc7fb01954788c080eeb639a7b7445c2c030
4
+ data.tar.gz: 2dbf5737474092bf6d09bdfc6f9994938d934bb3
5
5
  SHA512:
6
- metadata.gz: ea1bd93581c306b71c195aec4fcc318d20cbab24b74f3d3a8924a0f5f500b46a1867ad7b9e638380d1d16f0c0752bcc52b2fb7ec7208741c1a1b1c33edbad723
7
- data.tar.gz: 1ccabe819bb5d15b48bad7454eed264e50ab567877f297799505abff74670540ff2bbdd37562c2b8eebfc86395d2f1b754ec5885736931b5c6b3c0f37797b87b
6
+ metadata.gz: db5677cbc475cca359859fb168ed9bc9d7b227521ddb89807252fdfbbbdd7086c0dbd1d68241092bd01f009cbbb2b27a23f80bbf14603824a124c8765caf8d87
7
+ data.tar.gz: dd24ead72fc2c37d57f3dede77823894ce827f02e8864ce443a605882e27a6ac7ad29410affa701659fbfc3913d7841432e8cb08eb8e3e37cbe710e93d0444de
Binary file
@@ -1,16 +1,39 @@
1
1
  var Birt = (function () {
2
2
  var _this;
3
3
 
4
- var rptDesignJsonData;
4
+ var rptDesignJsonData; //报表的json数据
5
5
 
6
- var $birt;
6
+ var $birt; //birt报表整个区域
7
+ var $reports; //报表区域
8
+ var $menus; //文件列表,菜单区域
7
9
 
8
10
  function Birt(designJsonData) {
9
11
  _this = this;
10
12
  rptDesignJsonData = designJsonData;
11
- $birt = $('.birt');
12
13
  }
13
14
 
15
+ /**
16
+ * 开始加载
17
+ */
18
+ Birt.prototype.run = function () {
19
+ _this.onCreate();
20
+ _this.getMenus();
21
+ _this.getRetDesign();
22
+ };
23
+
24
+ /**
25
+ * 被创建时
26
+ */
27
+ Birt.prototype.onCreate = function () {
28
+ $birt = $('.birt');
29
+
30
+ $birt.append("<ul class='birt-menus'></ul>");
31
+ $menus = $birt.find(".birt-menus");
32
+
33
+ $birt.append("<div class='birt-reports'></div>");
34
+ $reports = $birt.find(".birt-reports");
35
+ };
36
+
14
37
  /**
15
38
  * 获取报表数据
16
39
  * @param rptDesignName
@@ -45,8 +68,43 @@ var Birt = (function () {
45
68
  );
46
69
  };
47
70
 
71
+ /**
72
+ * 获取报表的目录结构
73
+ */
74
+ Birt.prototype.getMenus = function () {
75
+ $.birtLoading();
76
+ $.ajax(
77
+ {
78
+ url: '/birt/api/menus.json',
79
+ type: 'GET',
80
+ success: function (data) {
81
+ $.birtLoading('hide');
82
+ console.log(data);
83
+ _this.showMenus(data.menus);
84
+ },
85
+ error: function (data) {
86
+ $.birtLoading('hide');
87
+ }
88
+ }
89
+ );
90
+ };
91
+
92
+ /**
93
+ * 显示报表的名称
94
+ */
48
95
  Birt.prototype.showDisplayName = function () {
49
- $birt.append('<h2>{0}</h2>'.format(rptDesignJsonData.display_name));
96
+ $reports.append("<h2 class='display-name'>{0}</h2>".format(rptDesignJsonData.display_name));
97
+ };
98
+
99
+ /**
100
+ * 显示报表菜单
101
+ * @param menus
102
+ */
103
+ Birt.prototype.showMenus = function (menus) {
104
+ for (var i = 0; i < menus.length; i++) {
105
+ var menu = menus[i];
106
+ $menus.append("<li class='item'><i class='icon'></i><a>{0}</a></li>".format(menu.display_name));
107
+ }
50
108
  };
51
109
 
52
110
 
@@ -89,7 +147,7 @@ var Birt = (function () {
89
147
 
90
148
  table_html += "</table>";
91
149
 
92
- $(".birt").append(table_html);
150
+ $reports.append(table_html);
93
151
  console.log(table);
94
152
  return table_html;
95
153
  };
@@ -5,4 +5,4 @@
5
5
 
6
6
  var birt = new Birt();
7
7
 
8
- birt.getRetDesign();
8
+ birt.run();
@@ -0,0 +1,9 @@
1
+ .birt-reports {
2
+ display: table-cell;
3
+ vertical-align: top;
4
+ padding-left: 8px;
5
+ text-align: left;
6
+ > .display-name {
7
+ margin: 0 0 12px 0;
8
+ }
9
+ }
@@ -0,0 +1,27 @@
1
+ .birt-menus {
2
+ display: table-cell;
3
+ width: 200px;
4
+ list-style: none;
5
+ border: 1px solid #ddd;
6
+ padding: 8px;
7
+ vertical-align: top;
8
+ > .item {
9
+ > .icon {
10
+ width: 20px;
11
+ height: 20px;
12
+ background-image: url(asset_path('tree.png'));
13
+ display: inline-block;
14
+ background-position: -100px -20px;
15
+ line-height: 20px;
16
+ vertical-align: top;
17
+ cursor: pointer;
18
+ }
19
+ > a {
20
+ font: 14px/1.7 "微软雅黑";
21
+ height: 20px;
22
+ line-height: 20px;
23
+ vertical-align: top;
24
+ cursor: pointer;
25
+ }
26
+ }
27
+ }
@@ -1,9 +1,10 @@
1
1
  @import "birt/base/*";
2
- @import "birt/components/table";
3
- @import "birt/components/loading";
2
+ @import "birt/components/*";
4
3
 
5
4
  .birt {
6
5
  @include birt_base;
7
6
  width: 100%;
8
7
  padding: 12px;
9
- }
8
+ position: relative;
9
+ display: table;
10
+ }
@@ -0,0 +1 @@
1
+ json.menus @menus
data/config/routes.rb CHANGED
@@ -3,4 +3,5 @@
3
3
  # end
4
4
  Rails.application.routes.draw do
5
5
  get 'birt/api', :to => 'birt/api#index'
6
+ get 'birt/api/menus', :to => 'birt/api#menus'
6
7
  end
@@ -12,5 +12,11 @@ module Birt
12
12
  @rpt_design.parse_rpt
13
13
  @rpt_design.data_sets.values.each { |data_set| data_set.data_set_result }
14
14
  end
15
+
16
+ #获取文件目录列表
17
+ def menus
18
+ @menus = Birt.menus
19
+ end
20
+
15
21
  end
16
22
  end
data/lib/birt/routing.rb CHANGED
@@ -3,6 +3,7 @@ module Birt #:nodoc:
3
3
  module MapperExtensions
4
4
  def self.birts
5
5
  @set.add_route("/birt/api", {:controller => "birt/api_controller", :action => "index"})
6
+ @set.add_route("/birt/api/menus", {:controller => "birt/api_controller", :action => "menus"})
6
7
  end
7
8
  end
8
9
  end
data/lib/birt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Birt
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  module Core
4
4
 
5
5
  end
data/lib/birt.rb CHANGED
@@ -26,17 +26,16 @@ module Birt
26
26
  "<div class=\"birt\" data-rptdesign=\"#{rptdesign_name}.rptdesign\"></div>"
27
27
  end
28
28
 
29
- #获取目录结构
29
+ #获取报表的目录结构
30
30
  def menus
31
-
32
31
  Dir.glob("./reports/*.rptdesign").inject([]) { |acc, f|
33
32
  names = REXML::Document.new(File.read(f)).root.get_elements("/report/text-property[@name='displayName']")
34
33
  display_name = names[0].text if names && names[0]
34
+ file_name = f.split('/').last.split(".").first
35
35
  acc << {
36
- file: f,
37
- display_name: display_name
36
+ file_name: file_name,
37
+ display_name: display_name || file_name
38
38
  }; acc
39
39
  }
40
-
41
40
  end
42
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: birt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - saxer
@@ -132,6 +132,7 @@ files:
132
132
  - MIT-LICENSE
133
133
  - README.rdoc
134
134
  - Rakefile
135
+ - app/assets/images/tree.png
135
136
  - app/assets/javascripts/birt.js
136
137
  - app/assets/javascripts/birt/birt.js
137
138
  - app/assets/javascripts/birt/components/loading.js
@@ -139,11 +140,13 @@ files:
139
140
  - app/assets/stylesheets/birt.scss
140
141
  - app/assets/stylesheets/birt/base/constant.scss
141
142
  - app/assets/stylesheets/birt/base/mixins.scss
143
+ - app/assets/stylesheets/birt/components/birt_reports.scss
142
144
  - app/assets/stylesheets/birt/components/loading.scss
145
+ - app/assets/stylesheets/birt/components/menus.scss
143
146
  - app/assets/stylesheets/birt/components/table.scss
144
147
  - app/views/birt/api/index.json.jbuilder
148
+ - app/views/birt/api/menus.json.jbuilder
145
149
  - config/birt.yml
146
- - config/database.yml
147
150
  - config/routes.rb
148
151
  - lib/app/controllers/birt/api_controller.rb
149
152
  - lib/app/helpers/application_helper.rb
@@ -195,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
198
  version: '0'
196
199
  requirements: []
197
200
  rubyforge_project:
198
- rubygems_version: 2.2.2
201
+ rubygems_version: 2.4.6
199
202
  signing_key:
200
203
  specification_version: 4
201
204
  summary: birt report
data/config/database.yml DELETED
@@ -1,13 +0,0 @@
1
- default: &default
2
- adapter: mysql2
3
- encoding: utf8
4
- pool: 5
5
- username: root
6
- password: sun
7
- host: localhost
8
- development:
9
- <<: *default
10
- database: spider
11
- production:
12
- <<: *default
13
- database: spider