kanaui 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +41 -0
  4. data/Rakefile +40 -0
  5. data/app/assets/images/back_disabled.png +0 -0
  6. data/app/assets/images/back_enabled.png +0 -0
  7. data/app/assets/images/back_enabled_hover.png +0 -0
  8. data/app/assets/images/favicon.ico +0 -0
  9. data/app/assets/images/forward_disabled.png +0 -0
  10. data/app/assets/images/forward_enabled.png +0 -0
  11. data/app/assets/images/forward_enabled_hover.png +0 -0
  12. data/app/assets/images/sort_asc.png +0 -0
  13. data/app/assets/images/sort_asc_disabled.png +0 -0
  14. data/app/assets/images/sort_both.png +0 -0
  15. data/app/assets/images/sort_desc.png +0 -0
  16. data/app/assets/images/sort_desc_disabled.png +0 -0
  17. data/app/assets/javascripts/application.js +19 -0
  18. data/app/assets/javascripts/kanaui/dashboard.js +131 -0
  19. data/app/assets/javascripts/kanaui/killbill.js +1114 -0
  20. data/app/assets/javascripts/kanaui/purl.js +271 -0
  21. data/app/assets/javascripts/kanaui/reports.dataTables.js +31 -0
  22. data/app/assets/javascripts/kanaui/reports.graphs.js +190 -0
  23. data/app/assets/javascripts/kanaui/reports.js +201 -0
  24. data/app/assets/javascripts/kanaui/reports.urls.js +44 -0
  25. data/app/assets/javascripts/kanaui/tests.js +2 -0
  26. data/app/assets/stylesheets/application.css +8 -0
  27. data/app/assets/stylesheets/bootstrap_and_overrides.css +7 -0
  28. data/app/assets/stylesheets/kanaui/dashboard.css +121 -0
  29. data/app/assets/stylesheets/kanaui/tests.css +4 -0
  30. data/app/controllers/kanaui/dashboard_controller.rb +59 -0
  31. data/app/controllers/kanaui/engine_controller.rb +18 -0
  32. data/app/helpers/kanaui/application_helper.rb +6 -0
  33. data/app/helpers/kanaui/dashboard_helper.rb +28 -0
  34. data/app/models/kanaui/dashboard.rb +5 -0
  35. data/app/views/kanaui/dashboard/index.html.erb +48 -0
  36. data/app/views/kanaui/layouts/kanaui_application.html.erb +43 -0
  37. data/config/locales/en.bootstrap.yml +18 -0
  38. data/config/routes.rb +10 -0
  39. data/lib/kanaui/engine.rb +7 -0
  40. data/lib/kanaui/version.rb +3 -0
  41. data/lib/kanaui.rb +22 -0
  42. data/lib/tasks/kanaui_tasks.rake +4 -0
  43. data/test/dummy/README.rdoc +261 -0
  44. data/test/dummy/Rakefile +7 -0
  45. data/test/dummy/app/controllers/application_controller.rb +3 -0
  46. data/test/dummy/app/helpers/application_helper.rb +2 -0
  47. data/test/dummy/config/application.rb +64 -0
  48. data/test/dummy/config/boot.rb +10 -0
  49. data/test/dummy/config/database.yml +25 -0
  50. data/test/dummy/config/environment.rb +5 -0
  51. data/test/dummy/config/environments/development.rb +39 -0
  52. data/test/dummy/config/environments/production.rb +67 -0
  53. data/test/dummy/config/environments/test.rb +37 -0
  54. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  55. data/test/dummy/config/initializers/inflections.rb +15 -0
  56. data/test/dummy/config/initializers/killbill_client.rb +4 -0
  57. data/test/dummy/config/initializers/mime_types.rb +5 -0
  58. data/test/dummy/config/initializers/secret_token.rb +7 -0
  59. data/test/dummy/config/initializers/session_store.rb +8 -0
  60. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  61. data/test/dummy/config/locales/en.yml +5 -0
  62. data/test/dummy/config/routes.rb +4 -0
  63. data/test/dummy/config.ru +4 -0
  64. data/test/dummy/db/development.sqlite3 +0 -0
  65. data/test/dummy/db/production.sqlite3 +0 -0
  66. data/test/dummy/db/test.sqlite3 +0 -0
  67. data/test/dummy/log/test.log +6 -0
  68. data/test/dummy/public/404.html +26 -0
  69. data/test/dummy/public/422.html +26 -0
  70. data/test/dummy/public/500.html +25 -0
  71. data/test/dummy/public/favicon.ico +0 -0
  72. data/test/dummy/script/rails +6 -0
  73. data/test/dummy/tmp/cache/assets/C49/370/sprockets%2Fe0912451e460967cb546e2ac00632667 +0 -0
  74. data/test/dummy/tmp/cache/assets/C59/3D0/sprockets%2F22311d65dd6f27979f0144f4e9603762 +0 -0
  75. data/test/dummy/tmp/cache/assets/C5C/180/sprockets%2F6b609032785fe05974b318057b808dc9 +0 -0
  76. data/test/dummy/tmp/cache/assets/C60/440/sprockets%2F9e401779c0877cf93949e930228032ac +0 -0
  77. data/test/dummy/tmp/cache/assets/C61/8F0/sprockets%2Fe8f725654ee48124c086d488379340e0 +0 -0
  78. data/test/dummy/tmp/cache/assets/C70/FA0/sprockets%2F43c86018a096a0a65a0905da2b709455 +0 -0
  79. data/test/dummy/tmp/cache/assets/C7A/180/sprockets%2F19b994259f9c7b6f2879718c3275f359 +0 -0
  80. data/test/dummy/tmp/cache/assets/C8A/AB0/sprockets%2Fdc2f837cd27313996699c80342b07e04 +0 -0
  81. data/test/dummy/tmp/cache/assets/C8C/2E0/sprockets%2F8ef8759ba58c509567a8444201c19b24 +0 -0
  82. data/test/dummy/tmp/cache/assets/C97/750/sprockets%2F34d94639228f869665db78f42ca3118e +0 -0
  83. data/test/dummy/tmp/cache/assets/CA2/C20/sprockets%2F1d186d79051934c85a0594a610a1ab6b +0 -0
  84. data/test/dummy/tmp/cache/assets/CB3/D00/sprockets%2F6e18e78b81412e49d335a04a68f16c35 +0 -0
  85. data/test/dummy/tmp/cache/assets/CBF/560/sprockets%2Fe944ecb8026957a176e29a392a069f46 +0 -0
  86. data/test/dummy/tmp/cache/assets/CC5/C70/sprockets%2Fc4dacfb400c37f046545be4501065313 +0 -0
  87. data/test/dummy/tmp/cache/assets/CCA/090/sprockets%2Fc04069b3046b34950b843e32bbdf2a60 +0 -0
  88. data/test/dummy/tmp/cache/assets/CCF/750/sprockets%2F0512cc5ddae07c2bf0861332668640e4 +0 -0
  89. data/test/dummy/tmp/cache/assets/CCF/FC0/sprockets%2F09d578e3a00293a0e60b65f01ed551c4 +0 -0
  90. data/test/dummy/tmp/cache/assets/CD0/E60/sprockets%2F34b252a436ea97340eb6a33353ec7c60 +0 -0
  91. data/test/dummy/tmp/cache/assets/CD9/960/sprockets%2F9faf733d3c943879081f001120abfc09 +0 -0
  92. data/test/dummy/tmp/cache/assets/CDA/100/sprockets%2F1421707c6cd2bf4619c218d15c5ed449 +0 -0
  93. data/test/dummy/tmp/cache/assets/CDD/750/sprockets%2F51c5d9b965a7a23e2703b0d8c74d1358 +0 -0
  94. data/test/dummy/tmp/cache/assets/CE3/750/sprockets%2Fc54b480c74716d0ff447cc13f9471f25 +0 -0
  95. data/test/dummy/tmp/cache/assets/CE6/EF0/sprockets%2F358f2a7450053d2e7e60d219787ede7a +0 -0
  96. data/test/dummy/tmp/cache/assets/CF1/600/sprockets%2F758e0f59cc7d377813b72e9f17109c2d +0 -0
  97. data/test/dummy/tmp/cache/assets/CF4/4C0/sprockets%2F66ae774f6007684bc3ce544d15a879f9 +0 -0
  98. data/test/dummy/tmp/cache/assets/CF4/910/sprockets%2F47246555fd8dde5f73d513149bd7d495 +0 -0
  99. data/test/dummy/tmp/cache/assets/CFB/570/sprockets%2F70a944fdac8557dc70819ec989604e95 +0 -0
  100. data/test/dummy/tmp/cache/assets/D04/E10/sprockets%2F32fb56262b67a8013f6d1fe3bc45263b +0 -0
  101. data/test/dummy/tmp/cache/assets/D0A/8E0/sprockets%2Faaccd4041294c01f9d52b59d90e61649 +0 -0
  102. data/test/dummy/tmp/cache/assets/D0D/B20/sprockets%2F83c8c6d067f200b94289a27ae217cd2d +0 -0
  103. data/test/dummy/tmp/cache/assets/D16/140/sprockets%2F71765207ccd3c89388ba290d1ead7e73 +0 -0
  104. data/test/dummy/tmp/cache/assets/D16/610/sprockets%2Fc45f9a1f74ae89810e305307c8c2c98a +0 -0
  105. data/test/dummy/tmp/cache/assets/D1A/1A0/sprockets%2Fa9e56834936cc1d4e033ed75459f7ac1 +0 -0
  106. data/test/dummy/tmp/cache/assets/D1D/880/sprockets%2Fe29808c67d12f86b83bb3f545e0685cc +0 -0
  107. data/test/dummy/tmp/cache/assets/D28/2F0/sprockets%2F0c216cfb363ad008c4dd27e21e286e20 +0 -0
  108. data/test/dummy/tmp/cache/assets/D29/350/sprockets%2Fa251294b0bc12651ee0dd16fb427ed08 +0 -0
  109. data/test/dummy/tmp/cache/assets/D2E/DD0/sprockets%2F4aab8120d7fdda3c3101795fc937044a +0 -0
  110. data/test/dummy/tmp/cache/assets/D33/E20/sprockets%2F01e77b5ab7c8f25d7e007e42d210e60f +0 -0
  111. data/test/dummy/tmp/cache/assets/D3A/5A0/sprockets%2F3205c58e5fc648bb07247dd6fc1aa058 +0 -0
  112. data/test/dummy/tmp/cache/assets/D3B/B20/sprockets%2Ff25927a9a796c888c93f9892db4ded57 +0 -0
  113. data/test/dummy/tmp/cache/assets/D3C/BA0/sprockets%2F499c3460b0df4ea435a25d1fa3776ae7 +0 -0
  114. data/test/dummy/tmp/cache/assets/D3D/FD0/sprockets%2F6cd2d6e10e5aa7649192213d87ae1dd8 +0 -0
  115. data/test/dummy/tmp/cache/assets/D40/880/sprockets%2Fa65183bd762da798d82ca16b2384ae3e +0 -0
  116. data/test/dummy/tmp/cache/assets/D4A/220/sprockets%2Fc3fa86c7916fd5cf3448a46c2701d48f +0 -0
  117. data/test/dummy/tmp/cache/assets/D4A/710/sprockets%2F19bdf938259f801b6bc26fda54907c3f +0 -0
  118. data/test/dummy/tmp/cache/assets/D50/880/sprockets%2F6491c413570f9b5ee67b43dae6fb988b +0 -0
  119. data/test/dummy/tmp/cache/assets/D5C/600/sprockets%2Fdd005cf1e2da44e307bfb30f6e711177 +0 -0
  120. data/test/dummy/tmp/cache/assets/D62/6B0/sprockets%2Feb40cf55d9fba5bb18801041e5a755b4 +0 -0
  121. data/test/dummy/tmp/cache/assets/D65/7F0/sprockets%2Fc431bdd5c16d69e6d48b025be24e07b3 +0 -0
  122. data/test/dummy/tmp/cache/assets/D6D/170/sprockets%2Fe7474ced980c0a511ab3ed94ca66507f +0 -0
  123. data/test/dummy/tmp/cache/assets/D6F/2F0/sprockets%2Ff83749b55e1a31b4bc71d8f10c9c8ed1 +0 -0
  124. data/test/dummy/tmp/cache/assets/D71/CA0/sprockets%2F2efce3b73b5a0834d61c30f3e88f943e +0 -0
  125. data/test/dummy/tmp/cache/assets/D71/D00/sprockets%2F8f431cf56efe254dc4ad2f39f1f05325 +0 -0
  126. data/test/dummy/tmp/cache/assets/D72/FC0/sprockets%2F0e88a2c64eef7d00ae16ec3d6587446b +0 -0
  127. data/test/dummy/tmp/cache/assets/D74/AA0/sprockets%2F2a2594863afdfb329cf44429c3f4cdb6 +0 -0
  128. data/test/dummy/tmp/cache/assets/D78/5F0/sprockets%2Fd779c87f1d25bc5e67e24be981ab005e +0 -0
  129. data/test/dummy/tmp/cache/assets/D7D/230/sprockets%2F0d9f8069a79511caa7b72d8f7e9ba3e6 +0 -0
  130. data/test/dummy/tmp/cache/assets/D7E/D40/sprockets%2Fbb1ee49d28b0f4826af433e66b99f68b +0 -0
  131. data/test/dummy/tmp/cache/assets/D7F/D40/sprockets%2F5df2d7d854a34efce561038973fea75e +0 -0
  132. data/test/dummy/tmp/cache/assets/D80/C00/sprockets%2F807575a6bca580997ea68b2849eeebab +0 -0
  133. data/test/dummy/tmp/cache/assets/D8D/640/sprockets%2F3cb906dcb26ce1bb8b148a9ec38151a0 +0 -0
  134. data/test/dummy/tmp/cache/assets/D8F/740/sprockets%2Fc28d091b6eec75f690312b1babac173e +0 -0
  135. data/test/dummy/tmp/cache/assets/D99/810/sprockets%2F40a77b8fdb5dbb4a8be79582930bac11 +0 -0
  136. data/test/dummy/tmp/cache/assets/D9B/590/sprockets%2F415dfd73bc9dcf11a3c443636a7cc85d +0 -0
  137. data/test/dummy/tmp/cache/assets/D9F/0E0/sprockets%2Fe225dd3abeea78368f1e094da4d6e038 +0 -0
  138. data/test/dummy/tmp/cache/assets/DA0/D50/sprockets%2Fbe08c987f77ac1cf011f2c295f64ae0e +0 -0
  139. data/test/dummy/tmp/cache/assets/DA0/DF0/sprockets%2F54a3fbb89812981e0ddd9f293ee0cca0 +0 -0
  140. data/test/dummy/tmp/cache/assets/DA2/9A0/sprockets%2Fc217dc63d5bb979ab458f9440b8aaeb5 +0 -0
  141. data/test/dummy/tmp/cache/assets/DAC/420/sprockets%2F8419ce35fe9f11d3ea2c9f8edb48a661 +0 -0
  142. data/test/dummy/tmp/cache/assets/DB0/FA0/sprockets%2Ff3e0e6737d4f66ef48581ed3f26cc2fc +0 -0
  143. data/test/dummy/tmp/cache/assets/DB7/B30/sprockets%2Fa35d57efd41de3d595e79db74d99a6a7 +0 -0
  144. data/test/dummy/tmp/cache/assets/DBD/520/sprockets%2F646b4ef551d2e6dbcafc30ec6a1a1921 +0 -0
  145. data/test/dummy/tmp/cache/assets/DC3/A40/sprockets%2Fec0ae4ff1ed6a72c0fc4ec564700195b +0 -0
  146. data/test/dummy/tmp/cache/assets/DCA/970/sprockets%2Fa5b14cb6e98a7b2f9dfdd413420d3be7 +0 -0
  147. data/test/dummy/tmp/cache/assets/DCD/570/sprockets%2Fdacdabcd4b599417317af696f0bc70f3 +0 -0
  148. data/test/dummy/tmp/cache/assets/DD0/630/sprockets%2F1a6f238c9a7e8609caef71fff2ad1a16 +0 -0
  149. data/test/dummy/tmp/cache/assets/DD4/F20/sprockets%2Fe280ef07c4f086afbc447e8a3df6e4e2 +0 -0
  150. data/test/dummy/tmp/cache/assets/DD5/460/sprockets%2F6670c88dab8f5cb0b36bd51caf58a87f +0 -0
  151. data/test/dummy/tmp/cache/assets/DD9/7A0/sprockets%2Fa913b7e4c6665cd4d75cd5e4efa46b8c +0 -0
  152. data/test/dummy/tmp/cache/assets/DE8/770/sprockets%2Fce3edfabfb12520c063ee21bd2ea1858 +0 -0
  153. data/test/dummy/tmp/cache/assets/DEA/910/sprockets%2F96c4857b4f859eef5c6bf113ecdb8ce9 +0 -0
  154. data/test/dummy/tmp/cache/assets/DEF/590/sprockets%2Fb8d8adfe3d233e16821faf0cbd03a09d +0 -0
  155. data/test/dummy/tmp/cache/assets/DF6/EA0/sprockets%2Fda2b70e5c0a5e5e5b2b8e4f3438aaf6f +0 -0
  156. data/test/dummy/tmp/cache/assets/E01/6A0/sprockets%2Feeec15d595b932dabdbb8f2fd66266b1 +0 -0
  157. data/test/dummy/tmp/cache/assets/E60/DF0/sprockets%2F7dced5bcfe17976cc5e41ffc1c33dbd2 +0 -0
  158. data/test/dummy/tmp/cache/assets/E8B/700/sprockets%2F3bd227fedfbfab5ede67a13feec45e14 +0 -0
  159. data/test/fixtures/kanaui/dashboards.yml +11 -0
  160. data/test/functional/kanaui/tests_controller_test.rb +9 -0
  161. data/test/integration/navigation_test.rb +10 -0
  162. data/test/kanaui_test.rb +7 -0
  163. data/test/test_helper.rb +15 -0
  164. data/test/unit/helpers/kanaui/tests_helper_test.rb +6 -0
  165. metadata +551 -0
@@ -0,0 +1,271 @@
1
+ /*
2
+ * JQuery URL Parser plugin, v2.2.1
3
+ * Developed and maintanined by Mark Perkins, mark@allmarkedup.com
4
+ * Source repository: https://github.com/allmarkedup/jQuery-URL-Parser
5
+ * Licensed under an MIT-style license. See https://github.com/allmarkedup/jQuery-URL-Parser/blob/master/LICENSE for details.
6
+ */
7
+
8
+ ;(function(factory) {
9
+ if (typeof define === 'function' && define.amd) {
10
+ // AMD available; use anonymous module
11
+ if ( typeof jQuery !== 'undefined' ) {
12
+ define(['jquery'], factory);
13
+ } else {
14
+ define([], factory);
15
+ }
16
+ } else {
17
+ // No AMD available; mutate global vars
18
+ if ( typeof jQuery !== 'undefined' ) {
19
+ factory(jQuery);
20
+ } else {
21
+ factory();
22
+ }
23
+ }
24
+ })(function($, undefined) {
25
+
26
+ var tag2attr = {
27
+ a : 'href',
28
+ img : 'src',
29
+ form : 'action',
30
+ base : 'href',
31
+ script : 'src',
32
+ iframe : 'src',
33
+ link : 'href'
34
+ },
35
+
36
+ key = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'fragment'], // keys available to query
37
+
38
+ aliases = { 'anchor' : 'fragment' }, // aliases for backwards compatability
39
+
40
+ parser = {
41
+ strict : /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, //less intuitive, more accurate to the specs
42
+ loose : /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // more intuitive, fails on relative paths and deviates from specs
43
+ },
44
+
45
+ toString = Object.prototype.toString,
46
+
47
+ isint = /^[0-9]+$/;
48
+
49
+ function parseUri( url, strictMode ) {
50
+ var str = decodeURI( url ),
51
+ res = parser[ strictMode || false ? 'strict' : 'loose' ].exec( str ),
52
+ uri = { attr : {}, param : {}, seg : {} },
53
+ i = 14;
54
+
55
+ while ( i-- ) {
56
+ uri.attr[ key[i] ] = res[i] || '';
57
+ }
58
+
59
+ // build query and fragment parameters
60
+ uri.param['query'] = parseString(uri.attr['query']);
61
+ uri.param['fragment'] = parseString(uri.attr['fragment']);
62
+
63
+ // split path and fragement into segments
64
+ uri.seg['path'] = uri.attr.path.replace(/^\/+|\/+$/g,'').split('/');
65
+ uri.seg['fragment'] = uri.attr.fragment.replace(/^\/+|\/+$/g,'').split('/');
66
+
67
+ // compile a 'base' domain attribute
68
+ uri.attr['base'] = uri.attr.host ? (uri.attr.protocol ? uri.attr.protocol+'://'+uri.attr.host : uri.attr.host) + (uri.attr.port ? ':'+uri.attr.port : '') : '';
69
+
70
+ return uri;
71
+ };
72
+
73
+ function getAttrName( elm ) {
74
+ var tn = elm.tagName;
75
+ if ( typeof tn !== 'undefined' ) return tag2attr[tn.toLowerCase()];
76
+ return tn;
77
+ }
78
+
79
+ function promote(parent, key) {
80
+ if (parent[key].length == 0) return parent[key] = {};
81
+ var t = {};
82
+ for (var i in parent[key]) t[i] = parent[key][i];
83
+ parent[key] = t;
84
+ return t;
85
+ }
86
+
87
+ function parse(parts, parent, key, val) {
88
+ var part = parts.shift();
89
+ if (!part) {
90
+ if (isArray(parent[key])) {
91
+ parent[key].push(val);
92
+ } else if ('object' == typeof parent[key]) {
93
+ parent[key] = val;
94
+ } else if ('undefined' == typeof parent[key]) {
95
+ parent[key] = val;
96
+ } else {
97
+ parent[key] = [parent[key], val];
98
+ }
99
+ } else {
100
+ var obj = parent[key] = parent[key] || [];
101
+ if (']' == part) {
102
+ if (isArray(obj)) {
103
+ if ('' != val) obj.push(val);
104
+ } else if ('object' == typeof obj) {
105
+ obj[keys(obj).length] = val;
106
+ } else {
107
+ obj = parent[key] = [parent[key], val];
108
+ }
109
+ } else if (~part.indexOf(']')) {
110
+ part = part.substr(0, part.length - 1);
111
+ if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
112
+ parse(parts, obj, part, val);
113
+ // key
114
+ } else {
115
+ if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
116
+ parse(parts, obj, part, val);
117
+ }
118
+ }
119
+ }
120
+
121
+ function merge(parent, key, val) {
122
+ if (~key.indexOf(']')) {
123
+ var parts = key.split('['),
124
+ len = parts.length,
125
+ last = len - 1;
126
+ parse(parts, parent, 'base', val);
127
+ } else {
128
+ if (!isint.test(key) && isArray(parent.base)) {
129
+ var t = {};
130
+ for (var k in parent.base) t[k] = parent.base[k];
131
+ parent.base = t;
132
+ }
133
+ set(parent.base, key, val);
134
+ }
135
+ return parent;
136
+ }
137
+
138
+ function parseString(str) {
139
+ return reduce(String(str).split(/&|;/), function(ret, pair) {
140
+ try {
141
+ pair = decodeURIComponent(pair.replace(/\+/g, ' '));
142
+ } catch(e) {
143
+ // ignore
144
+ }
145
+ var eql = pair.indexOf('='),
146
+ brace = lastBraceInKey(pair),
147
+ key = pair.substr(0, brace || eql),
148
+ val = pair.substr(brace || eql, pair.length),
149
+ val = val.substr(val.indexOf('=') + 1, val.length);
150
+
151
+ if ('' == key) key = pair, val = '';
152
+
153
+ return merge(ret, key, val);
154
+ }, { base: {} }).base;
155
+ }
156
+
157
+ function set(obj, key, val) {
158
+ var v = obj[key];
159
+ if (undefined === v) {
160
+ obj[key] = val;
161
+ } else if (isArray(v)) {
162
+ v.push(val);
163
+ } else {
164
+ obj[key] = [v, val];
165
+ }
166
+ }
167
+
168
+ function lastBraceInKey(str) {
169
+ var len = str.length,
170
+ brace, c;
171
+ for (var i = 0; i < len; ++i) {
172
+ c = str[i];
173
+ if (']' == c) brace = false;
174
+ if ('[' == c) brace = true;
175
+ if ('=' == c && !brace) return i;
176
+ }
177
+ }
178
+
179
+ function reduce(obj, accumulator){
180
+ var i = 0,
181
+ l = obj.length >> 0,
182
+ curr = arguments[2];
183
+ while (i < l) {
184
+ if (i in obj) curr = accumulator.call(undefined, curr, obj[i], i, obj);
185
+ ++i;
186
+ }
187
+ return curr;
188
+ }
189
+
190
+ function isArray(vArg) {
191
+ return Object.prototype.toString.call(vArg) === "[object Array]";
192
+ }
193
+
194
+ function keys(obj) {
195
+ var keys = [];
196
+ for ( prop in obj ) {
197
+ if ( obj.hasOwnProperty(prop) ) keys.push(prop);
198
+ }
199
+ return keys;
200
+ }
201
+
202
+ function purl( url, strictMode ) {
203
+ if ( arguments.length === 1 && url === true ) {
204
+ strictMode = true;
205
+ url = undefined;
206
+ }
207
+ strictMode = strictMode || false;
208
+ url = url || window.location.toString();
209
+
210
+ return {
211
+
212
+ data : parseUri(url, strictMode),
213
+
214
+ // get various attributes from the URI
215
+ attr : function( attr ) {
216
+ attr = aliases[attr] || attr;
217
+ return typeof attr !== 'undefined' ? this.data.attr[attr] : this.data.attr;
218
+ },
219
+
220
+ // return query string parameters
221
+ param : function( param ) {
222
+ return typeof param !== 'undefined' ? this.data.param.query[param] : this.data.param.query;
223
+ },
224
+
225
+ // return fragment parameters
226
+ fparam : function( param ) {
227
+ return typeof param !== 'undefined' ? this.data.param.fragment[param] : this.data.param.fragment;
228
+ },
229
+
230
+ // return path segments
231
+ segment : function( seg ) {
232
+ if ( typeof seg === 'undefined' ) {
233
+ return this.data.seg.path;
234
+ } else {
235
+ seg = seg < 0 ? this.data.seg.path.length + seg : seg - 1; // negative segments count from the end
236
+ return this.data.seg.path[seg];
237
+ }
238
+ },
239
+
240
+ // return fragment segments
241
+ fsegment : function( seg ) {
242
+ if ( typeof seg === 'undefined' ) {
243
+ return this.data.seg.fragment;
244
+ } else {
245
+ seg = seg < 0 ? this.data.seg.fragment.length + seg : seg - 1; // negative segments count from the end
246
+ return this.data.seg.fragment[seg];
247
+ }
248
+ }
249
+
250
+ };
251
+
252
+ };
253
+
254
+ if ( typeof $ !== 'undefined' ) {
255
+
256
+ $.fn.url = function( strictMode ) {
257
+ var url = '';
258
+ if ( this.length ) {
259
+ url = $(this).attr( getAttrName(this[0]) ) || '';
260
+ }
261
+ return purl( url, strictMode );
262
+ };
263
+
264
+ $.url = purl;
265
+
266
+ } else {
267
+ window.purl = purl;
268
+ }
269
+
270
+ });
271
+
@@ -0,0 +1,31 @@
1
+ function ReportsDataTables(reports) {
2
+ this.reports = reports;
3
+ }
4
+
5
+ ReportsDataTables.prototype.build = function(data, id, wrapper) {
6
+ log.debug('Building dataTable for id ' + id);
7
+ log.trace(data);
8
+
9
+ var dataTableWrapper = $('<div class="dataTableWrapper" id="dataTableWrapper-' + id + '"><h3>' + data['name'] + '</h3></div>');
10
+ wrapper.append(dataTableWrapper);
11
+
12
+ var dataTable = $('<table cellpadding="0" cellspacing="0" border="0" class="display" id="dataTable-' + id + '"></table>');
13
+ dataTableWrapper.append(dataTable);
14
+
15
+ var aaData = [];
16
+ for (var i in data['values']) {
17
+ aaData.push([data.values[i]['x'], data.values[i]['y']])
18
+ }
19
+
20
+ dataTable.dataTable({
21
+ "aaData": aaData,
22
+ "aoColumns": [
23
+ { "sTitle": "Date" },
24
+ { "sTitle": "Value" },
25
+ ]
26
+ });
27
+ }
28
+
29
+ ReportsDataTables.prototype.buildCSVURL = function(position) {
30
+ return this.reports.buildDataURL(position, 'csv');
31
+ }
@@ -0,0 +1,190 @@
1
+ function ReportsGraphs(reports) {
2
+ // To build the data tables
3
+ this.reportsDataTables = new ReportsDataTables(reports);
4
+ }
5
+
6
+ ReportsGraphs.prototype.getTitle = function(defaultTitle, position) {
7
+ var overridenTitle = $.url().param('title' + position);
8
+ if (!overridenTitle) {
9
+ return defaultTitle;
10
+ } else {
11
+ return overridenTitle;
12
+ }
13
+ }
14
+
15
+ ReportsGraphs.prototype.getMappingType = function(inputType, position) {
16
+ if (inputType == 'TIMELINE') {
17
+ var layersOrLines = $.url().param('__layersOrLines' + position);
18
+ if (!layersOrLines || layersOrLines != 'layers') {
19
+ return 'lines';
20
+ } else {
21
+ return 'layers';
22
+ }
23
+ } else if (inputType == 'COUNTERS') {
24
+ return 'pie';
25
+ } else {
26
+ return 'unknown';
27
+ }
28
+ }
29
+
30
+ ReportsGraphs.prototype.doDrawAll = function(input) {
31
+ var inputData = input.data;
32
+
33
+ var nbGraphs = inputData.length + 1;
34
+ var canvasHeigthWithMargins = input.topMargin + (nbGraphs * input.canvasHeigth) + ((nbGraphs - 1) * input.betweenGraphMargin) + input.bottomMargin;
35
+ var canvasHeigthGraph = input.canvasHeigth;
36
+
37
+ var translateX = input.leftMargin;
38
+
39
+ var graphStructure = new killbillGraph.GraphStructure();
40
+
41
+
42
+ graphStructure.setupDomStructure();
43
+ var canvas = graphStructure.createCanvas([input.topMargin, input.rightMargin, input.bottomMargin, input.leftMargin],
44
+ input.canvasWidth, canvasHeigthWithMargins);
45
+
46
+
47
+ var curTranslateY = input.topMargin;
48
+ var curTranslateLabelY = curTranslateY + (canvasHeigthGraph / 2);
49
+
50
+ for (var i = 0; i < inputData.length; i++) {
51
+ var curInput = inputData[i];
52
+ var curType = this.getMappingType(curInput.type, i + 1);
53
+ var curData = curInput.data;
54
+ var curTitle = this.getTitle(curInput.title, i + 1);
55
+
56
+ log.debug("Drawing '" + curTitle + "'");
57
+ log.trace(curData);
58
+
59
+ // Add the xAxis tick first for ordering purpose.
60
+ var nextTranslateY = curTranslateY + canvasHeigthGraph;
61
+ var xAxisCanvaGroup;
62
+ if (curType == 'lines' || curType == 'layers') {
63
+ xAxisCanvaGroup = graphStructure.createCanvasGroup(canvas, translateX, nextTranslateY);
64
+ }
65
+
66
+ var canvasGrp = graphStructure.createCanvasGroup(canvas, translateX, curTranslateY);
67
+ var theGraph;
68
+ if (curType == 'lines') {
69
+ theGraph = new killbillGraph.KBLinesGraph(canvasGrp, curTitle, curData, input.canvasWidth, canvasHeigthGraph, d3.scale.category20b());
70
+ } else if (curType == 'layers') {
71
+ theGraph = new killbillGraph.KBLayersGraph(canvasGrp, curTitle, curData, input.canvasWidth, canvasHeigthGraph, d3.scale.category20c());
72
+ } else if (curType == 'pie') {
73
+ theGraph = new killbillGraph.KBPie(canvasGrp, curTitle, curData, input.canvasWidth, canvasHeigthGraph, d3.scale.category20c(), true);
74
+ } else if (curType == 'histogram') {
75
+ var canvasGrp = graphStructure.createCanvasGroup(canvas, translateX, curTranslateY);
76
+ theGraph = new killbillGraph.KBHistogram(canvasGrp, curTitle, curData, input.canvasWidth, canvasHeigthGraph, d3.scale.category20c());
77
+ }
78
+ theGraph.draw();
79
+
80
+ curTranslateLabelY = curTranslateLabelY;
81
+ curTranslateY = nextTranslateY;
82
+
83
+ if (curType == 'lines' || curType == 'layers') {
84
+ theGraph.createXAxis(xAxisCanvaGroup, canvasHeigthGraph);
85
+ }
86
+
87
+ // Add subtitle
88
+ this.addSubtitle(input, curData, i, curTranslateY + 20, curType);
89
+
90
+ curTranslateY = curTranslateY + input.betweenGraphMargin;
91
+ }
92
+ }
93
+
94
+ ReportsGraphs.prototype.addSubtitle = function(input, data, i, yOffset, curType) {
95
+ if (curType != 'lines' && curType != 'layers') {
96
+ return;
97
+ }
98
+
99
+ var subtitle = $('<div/>').attr('id', 'subtitle-' + i)
100
+ .css('position', 'absolute')
101
+ .css('top', yOffset + 'px');
102
+
103
+ // Reports position starts at 1
104
+ var position = i + 1;
105
+
106
+ // Add CSV link
107
+ var csvURL = this.reportsDataTables.buildCSVURL(position);
108
+ var csvLink = $('<a/>').attr('href', csvURL).text('Download data (CSV)');
109
+ subtitle.append(csvLink);
110
+
111
+ /*
112
+ subtitle.append("&nbsp;/&nbsp;");
113
+
114
+ // Add DataTables link
115
+ var modalBody = $('<div/>').attr('class', 'modal-body');
116
+ for (var jdx in data) {
117
+ if (!data[jdx].values || data[jdx].values.length == 0) {
118
+ continue;
119
+ }
120
+ this.reportsDataTables.build(data[jdx], i + parseInt(jdx), modalBody);
121
+ }
122
+
123
+ var modal = $('<div/>').attr('class', 'modal fade')
124
+ .attr('id', 'dataTablesModalWrapper-' + i)
125
+ .attr('tabindex', '-1')
126
+ .attr('role', 'dialog')
127
+ .attr('aria-labelledby', 'RawData')
128
+ .attr('aria-hidden', 'true')
129
+ .append($('<div/>').attr('class', 'modal-dialog')
130
+ .append($('<div/>').attr('class', 'modal-content')
131
+ .append(modalBody)));
132
+ subtitle.append(modal);
133
+ $('#dataTablesModalWrapper-' + i).modal();
134
+
135
+ var dataTablesLink = $('<a/>').text('View data').css('cursor', 'pointer');
136
+ dataTablesLink.click(function() {
137
+ $('#dataTablesModalWrapper-' + i).modal('toggle');
138
+ });
139
+ subtitle.append(dataTablesLink);
140
+ */
141
+
142
+ subtitle.append("&nbsp;|&nbsp;");
143
+
144
+ // Add style link
145
+ var layersOrLines = $.url().param('__layersOrLines' + position);
146
+ if (!layersOrLines || layersOrLines != 'layers') {
147
+ var layersOrLinesLink = $('<a/>').attr('href', this.reportsDataTables.reports.buildRefreshURL() + '&__layersOrLines' + position + '=layers').text('Switch to layers');
148
+ } else {
149
+ var layersOrLinesLink = $('<a/>').attr('href', this.reportsDataTables.reports.buildRefreshURL() + '&__layersOrLines' + position + '=lines').text('Switch to lines');
150
+ }
151
+ subtitle.append(layersOrLinesLink);
152
+
153
+ // Add smoothing links
154
+ var firstLink = true;
155
+ var smooth = $.url().param('smooth' + position);
156
+ if (smooth) {
157
+ firstLink ? subtitle.append("&nbsp;|&nbsp;") : subtitle.append("&nbsp;/&nbsp;");
158
+ firstLink = false;
159
+ subtitle.append($('<a/>').attr('href', this.reportsDataTables.reports.buildRefreshURLForNewSmooth(position)).text('Raw data'));
160
+ }
161
+ if (smooth != 'AVERAGE_WEEKLY') {
162
+ firstLink ? subtitle.append("&nbsp;|&nbsp;") : subtitle.append("&nbsp;/&nbsp;");
163
+ firstLink = false;
164
+ subtitle.append($('<a/>').attr('href', this.reportsDataTables.reports.buildRefreshURLForNewSmooth(position, 'AVERAGE_WEEKLY')).text('Weekly average'));
165
+ }
166
+ if (smooth != 'AVERAGE_MONTHLY') {
167
+ firstLink ? subtitle.append("&nbsp;|&nbsp;") : subtitle.append("&nbsp;/&nbsp;");
168
+ firstLink = false;
169
+ subtitle.append($('<a/>').attr('href', this.reportsDataTables.reports.buildRefreshURLForNewSmooth(position, 'AVERAGE_MONTHLY')).text('Monthly average'));
170
+ }
171
+ if (smooth != 'SUM_WEEKLY') {
172
+ firstLink ? subtitle.append("&nbsp;|&nbsp;") : subtitle.append("&nbsp;/&nbsp;");
173
+ firstLink = false;
174
+ subtitle.append($('<a/>').attr('href', this.reportsDataTables.reports.buildRefreshURLForNewSmooth(position, 'SUM_WEEKLY')).text('Weekly sum'));
175
+ }
176
+ if (smooth != 'SUM_MONTHLY') {
177
+ firstLink ? subtitle.append("&nbsp;|&nbsp;") : subtitle.append("&nbsp;/&nbsp;");
178
+ firstLink = false;
179
+ subtitle.append($('<a/>').attr('href', this.reportsDataTables.reports.buildRefreshURLForNewSmooth(position, 'SUM_MONTHLY')).text('Monthly sum'));
180
+ }
181
+
182
+ $('#charts').append(subtitle);
183
+ // Need to append the element first before being able to get the width
184
+ subtitle.css('left', (input.leftMargin + input.canvasWidth / 2 - subtitle.width() / 2) + 'px')
185
+ }
186
+
187
+ ReportsGraphs.prototype.drawAll = function(dataForAllReports) {
188
+ var input = new killbillGraph.KBInputGraphs(750, 400, 80, 180, 80, 80, 160, dataForAllReports);
189
+ this.doDrawAll(input);
190
+ }
@@ -0,0 +1,201 @@
1
+ function Reports() {
2
+ this.protocol = 'http';
3
+ this.host = '127.0.0.1';
4
+ this.port = 8080;
5
+ this.basePath = '/plugins/killbill-analytics/static/analytics.html';
6
+
7
+ this.startDate = moment().subtract('months', 3).format('YYYY[-]MM[-]DD');
8
+ this.endDate = moment().format('YYYY[-]MM[-]DD');
9
+ // Map position -> report names
10
+ this.reports = {};
11
+ // Map position -> smoothing function
12
+ this.smoothingFunctions = {};
13
+
14
+ // Standard sets of reports
15
+ this.ANALYTICS_REPORTS = {
16
+ reports: {
17
+ 1: ['trial_starts_count_daily'],
18
+ 2: ['cancellations_count_daily'],
19
+ 3: ['active_by_product_term_monthly'],
20
+ 4: ['invoices_balance_daily']
21
+ }
22
+ };
23
+ this.SYSTEM_REPORTS = {
24
+ reports: {
25
+ 1: ['system_report_payments_per_day'],
26
+ 2: ['system_report_notifications_per_queue_name'],
27
+ 3: ['system_report_notifications_per_queue_name_late'],
28
+ 4: ['system_report_payments'],
29
+ 5: ['system_report_control_tag_no_test']
30
+ }
31
+ };
32
+
33
+ // Debugging
34
+ this.loadFromFilePath = false;
35
+ }
36
+
37
+ Reports.prototype.init = function() {
38
+ var url = $.url();
39
+ // Infer Kill Bill's address by looking at the current address,
40
+ // except if we're loading the file directly (file:///).
41
+ if (url.attr('protocol') != 'file') {
42
+ this.protocol = url.attr('protocol');
43
+ this.host = url.attr('host');
44
+ this.port = url.attr('port');
45
+ } else {
46
+ this.loadFromFilePath = true;
47
+ }
48
+ this.basePath = url.attr('path');
49
+
50
+ var params = url.param();
51
+ for (var key in params) {
52
+ if (key == 'startDate') {
53
+ this.startDate = params[key];
54
+ } else if (key == 'endDate') {
55
+ this.endDate = params[key];
56
+ } else if (key.startsWith('smooth')) {
57
+ var position = key.split('smooth')[1];
58
+ this.smoothingFunctions[position] = params[key];
59
+ } else if (key.startsWith('report')) {
60
+ var position = key.split('report')[1];
61
+ if (!(params[key] instanceof Array)) {
62
+ this.reports[position] = [params[key]];
63
+ } else {
64
+ this.reports[position] = params[key];
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ Reports.prototype.hasReport = function(val) {
71
+ var found = false;
72
+
73
+ var that = this;
74
+ $.each(Object.keys(this.reports), function(i, position) {
75
+ $.each(that.reports[position], function(j, reportName) {
76
+ if (reportName === val) {
77
+ found = true;
78
+ return;
79
+ }
80
+ });
81
+ });
82
+
83
+ return found;
84
+ }
85
+
86
+ Reports.prototype.availableReports = function(callback) {
87
+ var available_report_path = Routes.kanaui_engine_available_reports_path({format: "json"});
88
+ var url = this.buildBaseURL(available_report_path);
89
+ this.doGet(url, function(allReports) { callback(allReports); });
90
+ }
91
+
92
+ Reports.prototype.getDataForReport = function(position, callback) {
93
+ var url = this.buildDataURL(position);
94
+
95
+ return this.doGet(url,
96
+ function(data) {
97
+ callback(position, data);
98
+ },
99
+ function(jqXHR, textStatus, errorThrown) {
100
+ if (jqXHR.responseText) {
101
+ try {
102
+ errors = $.parseJSON(jqXHR.responseText);
103
+ if (errors['message']) {
104
+ displayError('Error generating report nb. ' + position + ':\n' + errors['message']);
105
+ } else {
106
+ displayError('Error generating report nb. ' + position + ':\n' + errors);
107
+ }
108
+ } catch (err) {
109
+ displayError('Error generating report nb. ' + position + ':\n' + jqXHR.responseText);
110
+ }
111
+ } else {
112
+ if (errorThrown) {
113
+ displayError('Error generating report nb. ' + position + ':\n' + errorThrown);
114
+ } else {
115
+ displayError('Error generating report nb. ' + position + ':\n' + textStatus + ' (status '+ jqXHR.status + ')');
116
+ }
117
+ }
118
+ });
119
+ }
120
+
121
+ Reports.prototype.getDataForReports = function(callback) {
122
+ // Array of all deferreds
123
+ var futures = []
124
+ // Array of all the data, the index being the report position (starts at zero)
125
+ var futuresData = new Array(Object.keys(this.reports).length);
126
+
127
+ for (var position in this.reports) {
128
+ // Fetch the data
129
+ var future = this.getDataForReport(position, function(zePosition, reportsData) {
130
+ if (!(reportsData instanceof Array) || reportsData.length == 0 || reportsData[0].data.length == 0) {
131
+ log.debug('Report at position ' + (zePosition - 1) + ' has not data')
132
+ // Skip, to avoid confusing the graphing library
133
+ } else {
134
+ log.debug('Got data for report at position ' + (zePosition - 1));
135
+ log.trace(reportsData);
136
+ futuresData[zePosition - 1] = reportsData[0];
137
+ }
138
+ });
139
+ futures.push(future);
140
+ }
141
+
142
+ // Apply callback on join (and remove skipped reports, with no data)
143
+ $.when.apply(null, futures).done(function() { callback($.grep(futuresData, function(e) { return e; })); });
144
+ }
145
+
146
+ Reports.prototype.buildRefreshURLForNewSmooth = function(position, newSmooth) {
147
+ var newReports = $.extend(true, {}, this);
148
+ newReports.smoothingFunctions[position] = newSmooth;
149
+ return newReports.buildRefreshURL();
150
+ }
151
+
152
+ Reports.prototype.buildRefreshURL = function() {
153
+
154
+ console.log("buildRefreshURL : StartDate = " + this.startDate + "EndDate = " + this.endDate);
155
+
156
+ var newReports = this.reports;
157
+ var url = !this.loadFromFilePath ? this.buildBaseURL(this.basePath) : this.basePath;
158
+ url += '?startDate=' + this.startDate;
159
+ url += '&endDate=' + this.endDate;
160
+
161
+ for (var position in newReports) {
162
+ var joinKey = '&report' + position + '=';
163
+ url += joinKey + newReports[position].join(joinKey);
164
+ if (this.smoothingFunctions[position]) {
165
+ url += '&smooth' + position + '=' + this.smoothingFunctions[position];
166
+ }
167
+ }
168
+
169
+ return url;
170
+ };
171
+
172
+ Reports.prototype.buildDataURL = function(position, format) {
173
+ var reports_path = Routes.kanaui_engine_reports_path({format: "json"});
174
+ var url = this.buildBaseURL(reports_path);
175
+ url += '?format=' + (format ? format : 'json')
176
+ url += '&startDate=' + this.startDate;
177
+ url += '&endDate=' + this.endDate;
178
+ url += '&name=' + this.reports[position].join('&name=');
179
+ if (this.smoothingFunctions[position]) {
180
+ url += '&smooth=' + this.smoothingFunctions[position]
181
+ }
182
+
183
+ return url;
184
+ }
185
+
186
+ Reports.prototype.buildBaseURL = function(path) {
187
+ return this.protocol + '://' + this.host + ':' + this.port + path;
188
+ }
189
+
190
+ Reports.prototype.doGet = function(url, doneCallback, failCallback) {
191
+ var apiKey = $.url().param('apiKey') || 'bob';
192
+ var apiSecret = $.url().param('apiSecret') || 'lazar';
193
+
194
+ return $.ajax({
195
+ type: 'GET',
196
+ contentType: 'application/json',
197
+ headers: { 'X-Killbill-ApiKey': apiKey, 'X-Killbill-ApiSecret': apiSecret },
198
+ dataType: 'json',
199
+ url: url
200
+ }).done(doneCallback).fail(failCallback);
201
+ }