wakame-vdc-webui 10.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (281) hide show
  1. data/INSTALL.txt +21 -0
  2. data/LICENSE +202 -0
  3. data/NOTICE +1 -0
  4. data/README +256 -0
  5. data/Rakefile +42 -0
  6. data/app/controllers/accounts_controller.rb +15 -0
  7. data/app/controllers/application_controller.rb +5 -0
  8. data/app/controllers/dialog_controller.rb +80 -0
  9. data/app/controllers/home_controller.rb +5 -0
  10. data/app/controllers/host_pools_controller.rb +26 -0
  11. data/app/controllers/images_controller.rb +28 -0
  12. data/app/controllers/information_controller.rb +10 -0
  13. data/app/controllers/instances_controller.rb +59 -0
  14. data/app/controllers/keypairs_controller.rb +64 -0
  15. data/app/controllers/security_groups_controller.rb +59 -0
  16. data/app/controllers/sessions_controller.rb +25 -0
  17. data/app/controllers/snapshots_controller.rb +48 -0
  18. data/app/controllers/storage_pools_controller.rb +27 -0
  19. data/app/controllers/users_controller.rb +3 -0
  20. data/app/controllers/volumes_controller.rb +86 -0
  21. data/app/helpers/accounts_helper.rb +2 -0
  22. data/app/helpers/application_helper.rb +23 -0
  23. data/app/helpers/dialog_helper.rb +2 -0
  24. data/app/helpers/home_helper.rb +2 -0
  25. data/app/helpers/host_pools_helper.rb +2 -0
  26. data/app/helpers/images_helper.rb +2 -0
  27. data/app/helpers/information_helper.rb +2 -0
  28. data/app/helpers/instances_helper.rb +2 -0
  29. data/app/helpers/keypairs_helper.rb +2 -0
  30. data/app/helpers/security_groups_helper.rb +2 -0
  31. data/app/helpers/sessions_helper.rb +2 -0
  32. data/app/helpers/snapshots_helper.rb +2 -0
  33. data/app/helpers/storage_pools_helper.rb +2 -0
  34. data/app/helpers/users_helper.rb +2 -0
  35. data/app/helpers/volumes_helper.rb +2 -0
  36. data/app/models/account.rb +104 -0
  37. data/app/models/authz.rb +102 -0
  38. data/app/models/base_new.rb +311 -0
  39. data/app/models/dcmgr_resource/account.rb +5 -0
  40. data/app/models/dcmgr_resource/base.rb +51 -0
  41. data/app/models/dcmgr_resource/host_pool.rb +11 -0
  42. data/app/models/dcmgr_resource/image.rb +11 -0
  43. data/app/models/dcmgr_resource/instance.rb +37 -0
  44. data/app/models/dcmgr_resource/mock.rb +15 -0
  45. data/app/models/dcmgr_resource/netfilter_group.rb +29 -0
  46. data/app/models/dcmgr_resource/ssh_key_pair.rb +25 -0
  47. data/app/models/dcmgr_resource/storage_pool.rb +11 -0
  48. data/app/models/dcmgr_resource/volume.rb +48 -0
  49. data/app/models/dcmgr_resource/volume_snapshot.rb +35 -0
  50. data/app/models/information.rb +9 -0
  51. data/app/models/schema.rb +51 -0
  52. data/app/models/tag.rb +121 -0
  53. data/app/models/tag_mapping.rb +25 -0
  54. data/app/models/user.rb +46 -0
  55. data/app/views/accounts/index.html.erb +68 -0
  56. data/app/views/dialog/attach_volume.html.erb +13 -0
  57. data/app/views/dialog/create_and_edit_security_group.html.erb +32 -0
  58. data/app/views/dialog/create_snapshot.html.erb +7 -0
  59. data/app/views/dialog/create_ssh_keypair.html.erb +15 -0
  60. data/app/views/dialog/create_volume.html.erb +18 -0
  61. data/app/views/dialog/create_volume_from_snapshot.html.erb +7 -0
  62. data/app/views/dialog/delete_security_group.html.erb +4 -0
  63. data/app/views/dialog/delete_snapshot.html.erb +7 -0
  64. data/app/views/dialog/delete_ssh_keypair.html.erb +4 -0
  65. data/app/views/dialog/delete_volume.html.erb +7 -0
  66. data/app/views/dialog/detach_volume.html.erb +7 -0
  67. data/app/views/dialog/launch_instance.html.erb +70 -0
  68. data/app/views/dialog/reboot_instances.html.erb +7 -0
  69. data/app/views/dialog/start_instances.html.erb +8 -0
  70. data/app/views/dialog/stop_instances.html.erb +7 -0
  71. data/app/views/dialog/terminate_instances.html.erb +7 -0
  72. data/app/views/home/index.html.erb +55 -0
  73. data/app/views/host_pools/index.html.erb +103 -0
  74. data/app/views/images/index.html.erb +126 -0
  75. data/app/views/information/index.html.erb +25 -0
  76. data/app/views/instances/index.html.erb +134 -0
  77. data/app/views/keypairs/index.html.erb +104 -0
  78. data/app/views/layouts/_footer.html.erb +4 -0
  79. data/app/views/layouts/_header.html.erb +14 -0
  80. data/app/views/layouts/_informationarea.html.erb +18 -0
  81. data/app/views/layouts/_login_header.erb +4 -0
  82. data/app/views/layouts/_service_health.erb +27 -0
  83. data/app/views/layouts/_sidemenu.html.erb +58 -0
  84. data/app/views/layouts/application.html.erb +34 -0
  85. data/app/views/layouts/login.html.erb +25 -0
  86. data/app/views/security_groups/index.html.erb +114 -0
  87. data/app/views/sessions/new.html.erb +27 -0
  88. data/app/views/snapshots/index.html.erb +110 -0
  89. data/app/views/storage_pools/index.html.erb +98 -0
  90. data/app/views/volumes/index.html.erb +117 -0
  91. data/config.ru +4 -0
  92. data/config/application.rb +48 -0
  93. data/config/boot.rb +13 -0
  94. data/config/database.yml +20 -0
  95. data/config/environment.rb +5 -0
  96. data/config/environments/development.rb +28 -0
  97. data/config/environments/production.rb +49 -0
  98. data/config/environments/test.rb +35 -0
  99. data/config/initializers/backtrace_silencers.rb +7 -0
  100. data/config/initializers/dcmgr_gui.rb +14 -0
  101. data/config/initializers/inflections.rb +10 -0
  102. data/config/initializers/mime_types.rb +5 -0
  103. data/config/initializers/secret_token.rb +7 -0
  104. data/config/initializers/session_store.rb +8 -0
  105. data/config/locales/en.yml +5 -0
  106. data/config/routes.rb +109 -0
  107. data/db/seeds.rb +7 -0
  108. data/extras/authentication.rb +94 -0
  109. data/extras/util.rb +5 -0
  110. data/lib/tasks/dcmgr_gui.rake +51 -0
  111. data/public/404.html +26 -0
  112. data/public/422.html +26 -0
  113. data/public/500.html +26 -0
  114. data/public/favicon.ico +0 -0
  115. data/public/images/app_active.gif +0 -0
  116. data/public/images/app_passive.gif +0 -0
  117. data/public/images/body_bg.gif +0 -0
  118. data/public/images/btn_change.gif +0 -0
  119. data/public/images/btn_create_security_group.gif +0 -0
  120. data/public/images/btn_create_snapshot.gif +0 -0
  121. data/public/images/btn_create_volume.gif +0 -0
  122. data/public/images/btn_createkey.gif +0 -0
  123. data/public/images/btn_de_register.gif +0 -0
  124. data/public/images/btn_delete_security_group.gif +0 -0
  125. data/public/images/btn_delete_snapshot.gif +0 -0
  126. data/public/images/btn_delete_volume.gif +0 -0
  127. data/public/images/btn_deletekey.gif +0 -0
  128. data/public/images/btn_healthdetail.gif +0 -0
  129. data/public/images/btn_hide.gif +0 -0
  130. data/public/images/btn_launch.gif +0 -0
  131. data/public/images/btn_next.gif +0 -0
  132. data/public/images/btn_prev.gif +0 -0
  133. data/public/images/btn_refresh.gif +0 -0
  134. data/public/images/btn_register_new_ami.gif +0 -0
  135. data/public/images/btn_savechange.gif +0 -0
  136. data/public/images/btn_show.gif +0 -0
  137. data/public/images/btn_show_accesskey.png +0 -0
  138. data/public/images/bup_btn_healthdetail.gif +0 -0
  139. data/public/images/bup_btn_refresh.gif +0 -0
  140. data/public/images/clear.gif +0 -0
  141. data/public/images/content_bg.png +0 -0
  142. data/public/images/content_foot_bg.gif +0 -0
  143. data/public/images/content_head_bg.gif +0 -0
  144. data/public/images/footer_bg.gif +0 -0
  145. data/public/images/head_gradation_bg.gif +0 -0
  146. data/public/images/header_logo.gif +0 -0
  147. data/public/images/icon_blockstore.gif +0 -0
  148. data/public/images/icon_caution.gif +0 -0
  149. data/public/images/icon_health.gif +0 -0
  150. data/public/images/icon_images.gif +0 -0
  151. data/public/images/icon_information.gif +0 -0
  152. data/public/images/icon_instances.gif +0 -0
  153. data/public/images/icon_resource.gif +0 -0
  154. data/public/images/icon_resource01.gif +0 -0
  155. data/public/images/icon_resource02.gif +0 -0
  156. data/public/images/icon_resource03.gif +0 -0
  157. data/public/images/icon_resource04.gif +0 -0
  158. data/public/images/icon_rss.gif +0 -0
  159. data/public/images/icon_security.gif +0 -0
  160. data/public/images/icon_service.gif +0 -0
  161. data/public/images/icon_service_stat.gif +0 -0
  162. data/public/images/icon_stop.gif +0 -0
  163. data/public/images/icon_summary.gif +0 -0
  164. data/public/images/icon_ttl_accskey.gif +0 -0
  165. data/public/images/icon_ttl_detail.gif +0 -0
  166. data/public/images/icon_ttl_instance.gif +0 -0
  167. data/public/images/icon_ttl_personal_inf.gif +0 -0
  168. data/public/images/infra_active.gif +0 -0
  169. data/public/images/infra_passive.gif +0 -0
  170. data/public/images/lastelement_bg.gif +0 -0
  171. data/public/images/lastelement_bg.png +0 -0
  172. data/public/images/listicon_useast.gif +0 -0
  173. data/public/images/loader_ball.gif +0 -0
  174. data/public/images/loader_boxes.gif +0 -0
  175. data/public/images/loading.gif +0 -0
  176. data/public/images/mainarea_bottom_bg.gif +0 -0
  177. data/public/images/mainarea_content_bg.gif +0 -0
  178. data/public/images/mainarea_h3_bg.gif +0 -0
  179. data/public/images/mainarea_wide_bottom_bg.gif +0 -0
  180. data/public/images/mainarea_wide_content_bg.gif +0 -0
  181. data/public/images/mainarea_wide_h3_bg.gif +0 -0
  182. data/public/images/menu_list_header.gif +0 -0
  183. data/public/images/menu_list_header_current.gif +0 -0
  184. data/public/images/plat_active.gif +0 -0
  185. data/public/images/plat_passive.gif +0 -0
  186. data/public/images/regionselect_bg.gif +0 -0
  187. data/public/images/select_bg_126.gif +0 -0
  188. data/public/images/select_bg_139.gif +0 -0
  189. data/public/images/sidemenu_bg.gif +0 -0
  190. data/public/images/sidemenu_bottom.gif +0 -0
  191. data/public/images/sidemenu_top.gif +0 -0
  192. data/public/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  193. data/public/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  194. data/public/images/ui-bg_flat_10_000000_40x100.png +0 -0
  195. data/public/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  196. data/public/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  197. data/public/images/ui-bg_glass_55_fcf0ba_1x400.png +0 -0
  198. data/public/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  199. data/public/images/ui-bg_gloss-wave_100_ece8da_500x100.png +0 -0
  200. data/public/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  201. data/public/images/ui-bg_highlight-hard_100_f5f3e5_1x100.png +0 -0
  202. data/public/images/ui-bg_highlight-hard_100_fafaf4_1x100.png +0 -0
  203. data/public/images/ui-bg_highlight-hard_15_459e00_1x100.png +0 -0
  204. data/public/images/ui-bg_highlight-hard_95_cccccc_1x100.png +0 -0
  205. data/public/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  206. data/public/images/ui-bg_highlight-soft_25_67b021_1x100.png +0 -0
  207. data/public/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  208. data/public/images/ui-bg_highlight-soft_95_ffedad_1x100.png +0 -0
  209. data/public/images/ui-bg_inset-soft_15_2b2922_1x100.png +0 -0
  210. data/public/images/ui-icons_222222_256x240.png +0 -0
  211. data/public/images/ui-icons_228ef1_256x240.png +0 -0
  212. data/public/images/ui-icons_808080_256x240.png +0 -0
  213. data/public/images/ui-icons_847e71_256x240.png +0 -0
  214. data/public/images/ui-icons_8dc262_256x240.png +0 -0
  215. data/public/images/ui-icons_cd0a0a_256x240.png +0 -0
  216. data/public/images/ui-icons_eeeeee_256x240.png +0 -0
  217. data/public/images/ui-icons_ef8c08_256x240.png +0 -0
  218. data/public/images/ui-icons_ffd27a_256x240.png +0 -0
  219. data/public/images/ui-icons_ffffff_256x240.png +0 -0
  220. data/public/images/vtip_arrow.png +0 -0
  221. data/public/javascripts/controls.js +965 -0
  222. data/public/javascripts/dcmgr_gui/application.js +91 -0
  223. data/public/javascripts/dcmgr_gui/core.js +539 -0
  224. data/public/javascripts/dcmgr_gui/dashboard_panel.js +34 -0
  225. data/public/javascripts/dcmgr_gui/host_pool_panel.js +83 -0
  226. data/public/javascripts/dcmgr_gui/image_panel.js +242 -0
  227. data/public/javascripts/dcmgr_gui/instance_panel.js +197 -0
  228. data/public/javascripts/dcmgr_gui/security_group_panel.js +196 -0
  229. data/public/javascripts/dcmgr_gui/snapshot_panel.js +168 -0
  230. data/public/javascripts/dcmgr_gui/sshkeypair_panel.js +161 -0
  231. data/public/javascripts/dcmgr_gui/storage_pool_panel.js +99 -0
  232. data/public/javascripts/dcmgr_gui/volume_panel.js +311 -0
  233. data/public/javascripts/dragdrop.js +974 -0
  234. data/public/javascripts/effects.js +1123 -0
  235. data/public/javascripts/jquery-1.4.2.min.js +154 -0
  236. data/public/javascripts/jquery-ui-1.8.4.custom.min.js +763 -0
  237. data/public/javascripts/jquery.loadmask.min.js +10 -0
  238. data/public/javascripts/jquery.tmpl.js +486 -0
  239. data/public/javascripts/jsdeferred.jquery.js +385 -0
  240. data/public/javascripts/prototype.js +6001 -0
  241. data/public/javascripts/rails.js +175 -0
  242. data/public/robots.txt +5 -0
  243. data/public/stylesheets/common.css +1236 -0
  244. data/public/stylesheets/dialog.css +67 -0
  245. data/public/stylesheets/jquery-ui-1.8.4.custom.css +572 -0
  246. data/public/stylesheets/jquery.loadmask.css +40 -0
  247. data/public/stylesheets/reset.css +71 -0
  248. data/public/stylesheets/style.css +7 -0
  249. data/public/stylesheets/vtip.css +28 -0
  250. data/script/rails +6 -0
  251. data/test/functional/accounts_controller_test.rb +8 -0
  252. data/test/functional/dialog_controller_test.rb +8 -0
  253. data/test/functional/home_controller_test.rb +8 -0
  254. data/test/functional/host_pools_controller_test.rb +8 -0
  255. data/test/functional/images_controller_test.rb +8 -0
  256. data/test/functional/information_controller_test.rb +8 -0
  257. data/test/functional/instances_controller_test.rb +8 -0
  258. data/test/functional/keypairs_controller_test.rb +8 -0
  259. data/test/functional/security_groups_controller_test.rb +8 -0
  260. data/test/functional/sessions_controller_test.rb +8 -0
  261. data/test/functional/snapshots_controller_test.rb +8 -0
  262. data/test/functional/storage_pools_controller_test.rb +8 -0
  263. data/test/functional/users_controller_test.rb +8 -0
  264. data/test/functional/volumes_controller_test.rb +8 -0
  265. data/test/performance/browsing_test.rb +9 -0
  266. data/test/test_helper.rb +13 -0
  267. data/test/unit/helpers/accounts_helper_test.rb +4 -0
  268. data/test/unit/helpers/dialog_helper_test.rb +4 -0
  269. data/test/unit/helpers/home_helper_test.rb +4 -0
  270. data/test/unit/helpers/host_pools_helper_test.rb +4 -0
  271. data/test/unit/helpers/images_helper_test.rb +4 -0
  272. data/test/unit/helpers/information_helper_test.rb +4 -0
  273. data/test/unit/helpers/instances_helper_test.rb +4 -0
  274. data/test/unit/helpers/keypairs_helper_test.rb +4 -0
  275. data/test/unit/helpers/security_groups_helper_test.rb +4 -0
  276. data/test/unit/helpers/sessions_helper_test.rb +4 -0
  277. data/test/unit/helpers/snapshots_helper_test.rb +4 -0
  278. data/test/unit/helpers/storage_pools_helper_test.rb +4 -0
  279. data/test/unit/helpers/users_helper_test.rb +4 -0
  280. data/test/unit/helpers/volumes_helper_test.rb +4 -0
  281. metadata +399 -0
@@ -0,0 +1,91 @@
1
+ // Place your application-specific JavaScript functions and classes here
2
+ // This file is automatically included by javascript_include_tag :defaults
3
+
4
+ //<![CDATA[
5
+ jQuery(function($){
6
+
7
+ //サイドメニュー開閉関数
8
+ var regionpos = 0;
9
+ $('#regionselect').click(function () {
10
+ if(regionpos==0){regionpos+=33;}else{regionpos=0;}
11
+ $('#regionselect').css("background-position","0px -"+regionpos+"px");
12
+ $('#regionmenu').toggle();
13
+ });
14
+
15
+ $('#regionmenu li a').click(function () {
16
+ if(regionpos==0){regionpos+=33;}else{regionpos=0;}
17
+ $('#regionselect').css("background-position","0px -"+regionpos+"px");
18
+ $('#regionselect').html($(this).html());
19
+ $('#regionmenu').toggle();
20
+ });
21
+
22
+ //maincontent開閉関数
23
+ $('.showhide').click(function(){
24
+ $(this).parent().next().toggle();//開閉
25
+ //backgroundの切り替え
26
+ var imgurl = $(this).css("background-image");
27
+ var img = imgurl.match(/.+\/images\/(btn_[a-z]+\.gif)/);
28
+ if(img[1] == "btn_hide.gif"){
29
+ $(this).css("background-image","url(images/btn_show.gif)");
30
+ $(this).css("background-repeat","no-repeat");
31
+ }else{
32
+ $(this).css("background-image","url(images/btn_hide.gif)");
33
+ $(this).css("background-repeat","no-repeat");
34
+ }
35
+ });
36
+
37
+ //InstanceActionsメニュー開閉関数
38
+ var instancepos = 0;
39
+ $('#instanceaction').click(function () {
40
+ if(instancepos==0){instancepos+=26;}else{instancepos=0;}
41
+ $('#instanceaction').css("background-position","0px -"+instancepos+"px");
42
+ $('#actionlist').toggle();
43
+ });
44
+
45
+ $('#actionlist li a').click(function () {
46
+ if(instancepos==0){instancepos+=26;}else{instancepos=0;}
47
+ $('#instanceaction').css("background-position","0px -"+instancepos+"px");
48
+ $('#instanceaction').html($(this).html());
49
+ $('#actionlist').toggle();
50
+ });
51
+
52
+ //VolumeActionsメニュー開閉関数
53
+ var volumepos = 0;
54
+ $('#volumeaction').click(function () {
55
+ if(volumepos==0){volumepos+=26;}else{volumepos=0;}
56
+ $('#volumeaction').css("background-position","0px -"+volumepos+"px");
57
+ $('#volumelist').toggle();
58
+ });
59
+
60
+ $('#volumelist li a').click(function () {
61
+ if(volumepos==0){volumepos+=26;}else{volumepos=0;}
62
+ $('#volumeaction').css("background-position","0px -"+volumepos+"px");
63
+ $('#volumeaction').html($(this).html());
64
+ $('#volumelist').toggle();
65
+ });
66
+
67
+ //ReservedInstancesメニュー開閉関数
68
+ var rsvinstancepos = 0;
69
+ $('#reservedinstance').click(function () {
70
+ if(rsvinstancepos==0){rsvinstancepos+=26;}else{rsvinstancepos=0;}
71
+ $('#reservedinstance').css("background-position","0px -"+rsvinstancepos+"px");
72
+ $('#rsvinstancelist').toggle();
73
+ });
74
+
75
+ $('#rsvinstancelist li a').click(function () {
76
+ if(rsvinstancepos==0){rsvinstancepos+=26;}else{rsvinstancepos=0;}
77
+ $('#reservedinstance').css("background-position","0px -"+rsvinstancepos+"px");
78
+ $('#reservedinstance').html($(this).html());
79
+ $('#rsvinstancelist').toggle();
80
+ });
81
+
82
+ $('#accounts_account_uuid').live('change',function() {
83
+ $(this).parent('form').submit();
84
+ return false;
85
+ });
86
+
87
+ //global
88
+ dcmgrGUI = new DcmgrGUI;
89
+ dcmgrGUI.initialize();
90
+ });
91
+ //]]>
@@ -0,0 +1,539 @@
1
+ var DcmgrGUI = function(){};
2
+
3
+ //Refarence:http://wp.serpere.info/archives/1091
4
+ DcmgrGUI.Class = (function() {
5
+ function subclass() {}
6
+ return {
7
+ create: function(parent) {
8
+ function klass() {
9
+ this.initialize.apply(this, arguments);
10
+ }
11
+
12
+ var index = 0;
13
+ if(jQuery.isFunction(parent)) {
14
+ index = 1;
15
+ subclass.prototype = parent.prototype;
16
+ klass.prototype = new subclass;
17
+ }
18
+ for(; index < arguments.length; ++index) {
19
+ jQuery.extend(klass.prototype, arguments[index]);
20
+ }
21
+ return klass;
22
+ }
23
+ }
24
+ })();
25
+
26
+ DcmgrGUI.Filter = DcmgrGUI.Class.create({
27
+ initialize: function(){
28
+ this.filters = [];
29
+ },
30
+ add: function(filter){
31
+ this.filters.push(filter);
32
+ },
33
+ execute: function(data){
34
+ this.apply(0,data);
35
+ },
36
+ apply: function(index,data){
37
+ if (this.filters[index] && typeof this.filters[index] === "function") {
38
+ this.filters[index](data);
39
+ var next_index = index + 1;
40
+ if (this.filters[next_index]) {
41
+ this.apply(next_index,data);
42
+ } else {
43
+ return data;
44
+ };
45
+ }
46
+ }
47
+ });
48
+
49
+ DcmgrGUI.Converter = {};
50
+ DcmgrGUI.Converter.fromMBtoGB = function(data){
51
+ return Math.ceil(data/1024) + 'GB';
52
+ };
53
+
54
+ DcmgrGUI.Pagenate = DcmgrGUI.Class.create({
55
+ initialize: function(params) {
56
+ this.element = $('#pagenate');
57
+ this.view = $("#viewPagenate").text();
58
+ this.total = params.total;
59
+ this.page_count = this.getPageCount(params['total'],params['row']);
60
+ this.current_page = 1;
61
+ this.row = params['row'];
62
+ this.start = this.getStartCount();
63
+ this.offset = this.getOffsetCount();
64
+ $('.prev').bind("click",{obj: this},this.updatePage);
65
+ $('.next').bind("click",{obj: this},this.updatePage);
66
+
67
+ this.renderPagenate();
68
+ },
69
+ getPageCount: function(total,row){
70
+ return Math.ceil(total / row)
71
+ },
72
+ changeTotal: function(total){
73
+ this.total = total;
74
+ this.page_count = this.getPageCount(this.total,this.row)
75
+ this.renderPagenate();
76
+ },
77
+ renderPagenate: function(){
78
+ this.start = this.getStartCount();
79
+ this.offset = this.getOffsetCount();
80
+ var html = this.start + ' to ' + this.offset + ' of ' + this.total;
81
+ $("#viewPagenate").html(html+' '+this.view);
82
+ },
83
+ updatePage: function(event){
84
+
85
+ var self = event.data.obj;
86
+ var name = $(this).attr('class');
87
+
88
+ if(self.current_page >= 1 && self.current_page < self.page_count) {
89
+ if(name === 'next'){
90
+ self.next_page = self.current_page +1;
91
+ self.current_page = self.next_page;
92
+ }
93
+ }
94
+
95
+ if(self.current_page > 1 && self.current_page <= self.page_count){
96
+ if(name === 'prev'){
97
+ self.prev_page = self.current_page -1;
98
+ self.current_page = self.prev_page;
99
+ }
100
+ }
101
+ self.renderPagenate();
102
+ self.element.trigger('dcmgrGUI.updatePagenate');
103
+ },
104
+ getOffsetCount: function(){
105
+ var count = (this.current_page * this.row);
106
+
107
+ if (this.total < count) {
108
+ return this.total;
109
+ } else {
110
+ return count;
111
+ }
112
+ },
113
+ getStartCount: function(){
114
+ if (this.current_page === 1) {
115
+ var start = 1;
116
+ } else {
117
+ var start = ((this.current_page -1) * this.row) + 1;
118
+ }
119
+ return start;
120
+ }
121
+ });
122
+
123
+ DcmgrGUI.Dialog = DcmgrGUI.Class.create({
124
+ initialize: function(params) {
125
+ this.target = $(params['target']);
126
+ this.element = $('<div></div>')
127
+ this.path_prefix = '/dialog';
128
+ this.path = this.path_prefix + params['path'];
129
+ this.width = params['width'];
130
+ this.height = params['height'];
131
+ this.title = params['title'];
132
+ this.button = params['button'];
133
+ this.callback = params['callback'] ||null;
134
+ },
135
+ open: function(params){
136
+ //multi select action
137
+ if(params){
138
+ if(params.ids.length == 0){
139
+ return false;
140
+ }
141
+ this.create(params);
142
+ }else{
143
+ //new create action
144
+ this.create();
145
+ }
146
+ this.content.dialog('open');
147
+ },
148
+ disabledButton: function(buttonName,disabled){
149
+ var widget = this.content
150
+ .dialog('widget')
151
+ .find(".ui-button-text:contains('"+ buttonName +"')")
152
+ .parent();
153
+ if( widget ) {
154
+ widget.button("option", "disabled", disabled);
155
+ }
156
+ },
157
+ close: function(){
158
+ this.content.dialog('close');
159
+ },
160
+ create: function(params){
161
+ this.content = this.element
162
+ .load(this.path,params,this.callback)
163
+ .dialog({
164
+ title: this.title,
165
+ disable: false,
166
+ autoOpen: false,
167
+ bgiframe: true,
168
+ width: this.width,
169
+ height: this.height,
170
+ modal: true,
171
+ resizable: true,
172
+ closeOnEscape: true,
173
+ closeText: 'hide',
174
+ draggable:false,
175
+ buttons: this.button
176
+ });
177
+ }
178
+ });
179
+
180
+ DcmgrGUI.ContentBase = DcmgrGUI.Class.create({
181
+ initialize: function(params){
182
+ if (params.element_id) {
183
+ this.element = $(params.element_id);
184
+ } else {
185
+ this.element = $('<div></div>');
186
+ }
187
+
188
+ this.template = params.template_id;
189
+ this.events = this.events||[];
190
+ //prototype.register_event function add to call before initialize function
191
+ this.bind_events();
192
+ this.filter = new DcmgrGUI.Filter();
193
+ },
194
+ update:function(request,async){
195
+ this.request = request;
196
+ this.async = async;
197
+ var self = this;
198
+
199
+ $("#list_load_mask").mask("Loading...");
200
+ self.element.trigger('dcmgrGUI.beforeUpdate');
201
+ $.ajax({
202
+ async: async||true,
203
+ url: request.url,
204
+ dataType: "json",
205
+ data: request.data,
206
+ success: function(json,status,xhr){
207
+ self.filter.execute(json);
208
+ self.element.trigger('dcmgrGUI.contentChange',[{"data":json,"self":self}]);
209
+ self.element.trigger('dcmgrGUI.afterUpdate',[{"data":json,"self":self}]);
210
+ },
211
+ complete: function(xhr, status) {
212
+ $("#list_load_mask").unmask();
213
+ },
214
+ error: function(xhr, status, error){
215
+ alert('Dcmgr connection '+status);
216
+ }
217
+ });
218
+ },
219
+ register_event:function(name,handler){
220
+ this.events = this.events||[]
221
+ this.events.push({
222
+ "name":name,
223
+ "handler":handler
224
+ })
225
+ },bind_events:function(){
226
+ for(var i in this.events){
227
+ this.element.bind(this.events[i].name,this.events[i].handler);
228
+ }
229
+ }
230
+ });
231
+
232
+ DcmgrGUI.Util = {};
233
+ DcmgrGUI.Util.getPagePath = function(path,page,format){
234
+ var format = format||'json';
235
+ return path + page + '.' + format;
236
+ }
237
+ DcmgrGUI.Util.setfillData = function(maxrows,json){
238
+ var fillCount = maxrows-json.length;
239
+ var emptyObj = [];
240
+ for (var key in json[0]) {
241
+ emptyObj.key = ''
242
+ }
243
+ for(var i=0;i<fillCount;i++){
244
+ json.push(emptyObj);
245
+ }
246
+ return json;
247
+ }
248
+
249
+ DcmgrGUI.Util.getLoadingImage = function(type){
250
+ switch(type) {
251
+ case "ball":
252
+ var image = 'loader_ball.gif'
253
+ break;
254
+
255
+ case "boxes":
256
+ var image = 'loader_boxes.gif'
257
+ break;
258
+
259
+ default:
260
+ var image = 'loader_ball.gif'
261
+ break;
262
+ }
263
+ return '<img src="images/'+image+'" />';
264
+ }
265
+
266
+
267
+ DcmgrGUI.Util.getPagenateData = function(start,limit){
268
+ return "start=" + start + "&" + "limit=" + limit;
269
+ }
270
+
271
+ DcmgrGUI.List = DcmgrGUI.Class.create(DcmgrGUI.ContentBase, {
272
+ initialize: function(params){
273
+ DcmgrGUI.ContentBase.prototype.initialize(params);
274
+ this.checked_list = {};
275
+ this.detail_template = {};
276
+ this.maxrow = params.maxrow
277
+ this.page = params.page
278
+
279
+ var self = this;
280
+
281
+ this.element.bind('dcmgrGUI.afterUpdate',function(event){
282
+
283
+ var bg;
284
+ var kids;
285
+
286
+ $("table").find('td').hover(
287
+ function () {
288
+ //Mouse over
289
+ bg = $(this).parent().css("background-color");
290
+ kids = $(this).parent().children();
291
+ kids.css("background-color","#82c9d9");
292
+ },
293
+ function () {
294
+ //Mouse over
295
+ kids.css("background-color",bg);
296
+ }
297
+ );
298
+
299
+ self.element.find("[type='checkbox']").each(function(key,value){
300
+ var id = $(value).val();
301
+ if(self.checked_list[id]){
302
+ $(event.target).find("[type='checkbox']").each(function(){
303
+ if($(this).val() === id){
304
+ $(this).attr('checked',true);
305
+ }
306
+ })
307
+ }
308
+ })
309
+ });
310
+
311
+ this.element.bind('dcmgrGUI.updateList',function(event,params){
312
+ self.update(params.request,true)
313
+ });
314
+
315
+ },
316
+ setDetailTemplate:function(template){
317
+ this.detail_template = template;
318
+ },
319
+ getCheckedInstanceIds:function(checked_list){
320
+ var ids = []
321
+ for(var id in this.checked_list){
322
+ ids.push(id);
323
+ }
324
+ return {
325
+ 'ids':ids
326
+ }
327
+ },
328
+ checkRadioButton:function(id){
329
+ $('#'+id).attr("checked", true);
330
+ },
331
+ setData:function(json){
332
+ var rows = []
333
+ if(!json){
334
+ rows = this.getEmptyData()
335
+ }else{
336
+ $.each(json,function(key,value){
337
+ rows.push(value.result)
338
+ });
339
+ }
340
+ var row = this.maxrow || 10;
341
+ var data = {
342
+ rows:DcmgrGUI.Util.setfillData(row,rows)
343
+ };
344
+ this.element.html('');
345
+ if(data.rows){
346
+ $( this.template )
347
+ .tmpl( data )
348
+ .appendTo( this.element );
349
+ }
350
+ },
351
+ clearCheckedList:function(){
352
+ this.checked_list = {}
353
+ },
354
+ changeStatus:function(state){
355
+ $.each(this.checked_list,function(id,obj){
356
+ obj.element.find('.state').html(state);
357
+ $('#detail').find('#'+id).find('.state').html(state);
358
+ });
359
+ },
360
+ currentChecked:function(){
361
+ var id = this.element.find("[type='radio']:checked").val();
362
+ if( id ){
363
+ return id;
364
+ }else{
365
+ return null;
366
+ }
367
+ },
368
+ singleCheckList:function(params){
369
+ var self = this;
370
+ this.element.find("[type='radio']").each(function(key,value){
371
+ $(this).click(function(){
372
+ var check_id = $(this).val();
373
+
374
+ if($(this).is(':checked')){
375
+ var c_detail = new DcmgrGUI.Detail({
376
+ template_id:params.template_id
377
+ });
378
+
379
+ c_detail.element.bind('dcmgrGUI.contentChange',function(event,params){
380
+ var data = { item:params.data }
381
+
382
+ //initialize
383
+ if(!params.data){
384
+ data.item = self.getEmptyData();
385
+ }
386
+
387
+ if(data.item){
388
+ $('#detail').html($( c_detail.template ).tmpl(data));
389
+ }
390
+ });
391
+
392
+ c_detail.update({
393
+ url:DcmgrGUI.Util.getPagePath(params.detail_path,check_id)
394
+ },true);
395
+
396
+ }else{
397
+ $('#detail').html('');
398
+ }
399
+ });
400
+ });
401
+ },
402
+ multiCheckList:function(params){
403
+ var self = this;
404
+ this.element.find("[type='checkbox']").each(function(key,value){
405
+ $(this).click(function(){
406
+ var check_id = $(this).val();
407
+
408
+ if($(this).is(':checked')){
409
+
410
+ //step1:onclick checkbox and generate detail object
411
+ self.checked_list[check_id] = {
412
+ //+1 is to remove table header
413
+ element:$(self.element.find('tr')[key+1]),
414
+ c_detail:new DcmgrGUI.Detail({
415
+ //id is to search element key
416
+ id:check_id,
417
+ template_id:params.template_id
418
+ })
419
+ }
420
+
421
+ //step2:bind event dcmgrGUI.contentChange
422
+ self.checked_list[check_id].c_detail.element.bind('dcmgrGUI.contentChange',function(event,params){
423
+ if(self.checked_list[check_id]){
424
+
425
+ //step4:marge data in template
426
+ var data = { item:params.data }
427
+
428
+ //initialize
429
+ if(!params.data){
430
+ data.item = self.checked_list[check_id].c_detail.getEmptyData();
431
+ }
432
+
433
+ if (self.detail_template.filter) {
434
+ self.detail_template.filter.execute(data);
435
+ };
436
+ self.checked_list[check_id].c_detail.filter.execute(data);
437
+
438
+ if(data.item){
439
+ $( self.checked_list[check_id].c_detail.template )
440
+ .tmpl(data)
441
+ .appendTo( $('#detail') );
442
+ }
443
+ }
444
+ });
445
+
446
+ //step3:update detail
447
+ self.checked_list[check_id].c_detail.update({
448
+ url:DcmgrGUI.Util.getPagePath(params.detail_path,check_id)
449
+ },true);
450
+
451
+ }else{
452
+ //remove detail
453
+ if(self.checked_list[check_id]){
454
+ $($('#detail').find('#'+check_id)).remove();
455
+ delete self.checked_list[check_id]
456
+ }
457
+
458
+ }
459
+ });
460
+ })
461
+ }
462
+ });
463
+
464
+ DcmgrGUI.Detail = DcmgrGUI.Class.create(DcmgrGUI.ContentBase, {
465
+ });
466
+
467
+ DcmgrGUI.Refresh = DcmgrGUI.Class.create({
468
+ initialize: function(){
469
+ this.element = $('.refresh');
470
+ var self = this;
471
+ self.element.live('click',function(){
472
+ self.element.trigger('dcmgrGUI.refresh');
473
+ })
474
+ },
475
+ });
476
+
477
+ DcmgrGUI.ItemSelector = DcmgrGUI.Class.create({
478
+
479
+ initialize: function(params) {
480
+
481
+ this.left_select_id = params.left_select_id;
482
+ this.right_select_id = params.right_select_id;
483
+ this.data = params.data;
484
+
485
+ this.leftSelectionsArray = [];
486
+ var dataSize = this.data.length;
487
+ for(var i = 0;i < dataSize ;i++) {
488
+ var html = '<option id="'+i+'" value="'+ this.data[i]['value'] +'">'+ this.data[i]['name'] +'</option>';
489
+ this.leftSelectionsArray[i] = $(html);
490
+ }
491
+ this.rightSelectionsArray = this.emptyArray(this.data.length);
492
+
493
+ this.refreshOptions(this.left_select_id,this.leftSelectionsArray);
494
+ },
495
+ refreshOptions: function(select_id,selectionsArray){
496
+ var selectionsSize = selectionsArray.length;
497
+ $(select_id).html('');
498
+ for(var i = 0;i < selectionsSize ;i++) {
499
+ if(selectionsArray[i] !== null ){
500
+ $(select_id).append(selectionsArray[i]);
501
+ }
502
+ }
503
+ },
504
+ emptyArray: function(size) {
505
+ var data = [];
506
+ for(var i = 0;i < size ;i++) {
507
+ data[i] = null;
508
+ }
509
+ return data;
510
+ },
511
+ leftToRight: function() {
512
+ var self = this;
513
+ $(this.left_select_id).find('option:selected').each(function(){
514
+ var index = $(this).attr('id');
515
+ self.leftSelectionsArray[index] = null;
516
+ self.rightSelectionsArray[index] = this;
517
+ $(this).remove();
518
+ });
519
+
520
+ this.refreshOptions(this.right_select_id,this.rightSelectionsArray);
521
+ },
522
+ rightToLeft: function() {
523
+ var self = this;
524
+ $(this.right_select_id).find('option:selected').each(function(){
525
+ var index = $(this).attr('id');
526
+ self.leftSelectionsArray[index] = this;
527
+ self.rightSelectionsArray[index] = null;
528
+ $(this).remove();
529
+ });
530
+
531
+ this.refreshOptions(this.left_select_id,this.leftSelectionsArray);
532
+ }
533
+ });
534
+
535
+ DcmgrGUI.prototype = {
536
+ initialize:function(){
537
+ $.deferred.define();
538
+ }
539
+ }