index.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // 添加分组
  2. function bindAddProjectGroup() {
  3. $("#addProjectGroupBtn").click(function () {
  4. doLoader("/projectGroup/page/add");
  5. });
  6. }
  7. // 修改分组
  8. function bindEditProjectGroup($projectGroupSelect) {
  9. $("#editProjectGroupBtn").click(function () {
  10. var $id = $projectGroupSelect.selectpicker('val');
  11. if (!isBlank($id)) {
  12. doLoader('/projectGroup/page/edit?id=' + $id);
  13. return;
  14. }
  15. bootGrowl("请选择分组", "danger");
  16. });
  17. }
  18. // 删除分组
  19. function bindRemoveProjectGroup($projectGroupSelect) {
  20. $("#removeProjectGroupBtn").click(function () {
  21. var $id = $projectGroupSelect.selectpicker('val');
  22. if (isBlank($id)) {
  23. bootGrowl("请选择分组", "danger");
  24. return;
  25. }
  26. BootstrapDialog.show({
  27. title: "提示",
  28. type: BootstrapDialog.TYPE_INFO,
  29. message: "确认删除分组?",
  30. size: BootstrapDialog.SIZE_NORMAL,
  31. buttons: [{
  32. label: "确定",
  33. action: function (dialog) {
  34. doPoster('/projectGroup/remove',{id: $id}, function (data) {
  35. if (data.success == true) {
  36. // 显示主页
  37. backIndexPage();
  38. bootGrowl(data.resultValue, "success");
  39. } else {
  40. bootGrowl(data.resultValue, "danger");
  41. }
  42. });
  43. dialog.close();
  44. }
  45. }, {
  46. label: "取消",
  47. action: function (dialog) {
  48. dialog.close();
  49. }
  50. }]
  51. });
  52. });
  53. }
  54. // 给分组下拉绑定事件
  55. function bindProjectGroupSelect($projectGroupSelect) {
  56. // 绑定选择事件
  57. $projectGroupSelect.on('change, changed.bs.select', function () {
  58. $.loadingT(true);
  59. doLoader("/index?projectGroupId=" + $(this).val());
  60. });
  61. }
  62. // 添加连接
  63. function bindAddConnector() {
  64. // 绑定添加连接按钮点击事件
  65. $("#indexAddConnectorBtn").click(function () {
  66. doLoader('/connector/page/add');
  67. });
  68. }
  69. // 编辑连接
  70. function bindEditConnector() {
  71. $(".connectorList .dbsyncer_block").click(function () {
  72. var $id = $(this).attr("id");
  73. doLoader('/connector/page/edit?id=' + $id);
  74. });
  75. }
  76. // 添加驱动
  77. function bindAddMapping() {
  78. $("#indexAddMappingBtn").click(function () {
  79. doLoader('/mapping/pageAdd');
  80. });
  81. }
  82. // 编辑驱动
  83. function bindEditMapping() {
  84. $(".mappingList .dbsyncer_block").click(function () {
  85. var $id = $(this).attr("id");
  86. doLoader('/mapping/page/edit?id=' + $id);
  87. });
  88. }
  89. // 查看驱动日志
  90. function bindQueryData() {
  91. $(".mappingList .queryData").click(function () {
  92. // 阻止触发click传递事件
  93. event.cancelBubble=true;
  94. var $menu = $('#menu > li');
  95. $menu.removeClass('active');
  96. $menu.find("a[url='/monitor']").parent().addClass('active');
  97. var $id = $(this).attr("id");
  98. doLoader('/monitor?id=' + $id);
  99. });
  100. }
  101. function bindConnectorDropdownMenu() {
  102. $(".connectorList .dropdown-menu li").click(function () {
  103. var $url = $(this).attr("url");
  104. // 如果当前为恢复状态
  105. BootstrapDialog.show({
  106. title: "警告",
  107. type: BootstrapDialog.TYPE_DANGER,
  108. message: "确认删除连接?",
  109. size: BootstrapDialog.SIZE_NORMAL,
  110. buttons: [{
  111. label: "确定",
  112. action: function (dialog) {
  113. doPost($url);
  114. dialog.close();
  115. }
  116. }, {
  117. label: "取消",
  118. action: function (dialog) {
  119. dialog.close();
  120. }
  121. }]
  122. });
  123. });
  124. }
  125. // 给驱动下拉菜单绑定事件
  126. function bindMappingDropdownMenu() {
  127. $(".mappingList .dropdown-menu li").click(function () {
  128. var $url = $(this).attr("url");
  129. var $confirm = $(this).attr("confirm");
  130. var $confirmMessage = $(this).attr("confirmMessage");
  131. if ("true" == $confirm) {
  132. // 如果当前为恢复状态
  133. BootstrapDialog.show({
  134. title: "警告",
  135. type: BootstrapDialog.TYPE_DANGER,
  136. message: $confirmMessage,
  137. size: BootstrapDialog.SIZE_NORMAL,
  138. buttons: [{
  139. label: "确定",
  140. action: function (dialog) {
  141. doPost($url);
  142. dialog.close();
  143. }
  144. }, {
  145. label: "取消",
  146. action: function (dialog) {
  147. dialog.close();
  148. }
  149. }]
  150. });
  151. return;
  152. }
  153. doPost($url);
  154. });
  155. }
  156. function doPost(url) {
  157. doPoster(url, null, function(data){
  158. if (data.success == true) {
  159. // 显示主页
  160. backIndexPage();
  161. bootGrowl(data.resultValue, "success");
  162. } else {
  163. bootGrowl(data.resultValue, "danger");
  164. }
  165. });
  166. }
  167. $(function () {
  168. // 初始化select插件
  169. initSelectIndex($(".select-control"), 1);
  170. bindAddProjectGroup();
  171. var $projectGroupSelect = $("#projectGroup");
  172. bindEditProjectGroup($projectGroupSelect);
  173. bindRemoveProjectGroup($projectGroupSelect);
  174. bindProjectGroupSelect($projectGroupSelect);
  175. bindAddConnector();
  176. bindEditConnector();
  177. bindAddMapping();
  178. bindEditMapping();
  179. bindQueryData();
  180. bindConnectorDropdownMenu();
  181. bindMappingDropdownMenu();
  182. });