server.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <!-- 配置服务器 -->
  2. <div class="plg-tab-container">
  3. <div class="plg-flex" style="height: 100%;">
  4. <div class="flex_item" id="settingSever">
  5. 配置服务器
  6. </div>
  7. </div>
  8. </div>
  9. <style>
  10. .label-form-right .dhxform_txt_label2 {
  11. text-align: right;
  12. padding-right: 5px !important;
  13. }
  14. </style>
  15. <script>
  16. (function () {
  17. window.global_fun.setServer = {};
  18. var res_opts = {
  19. fixedLast: true,
  20. renderer: "settingSever",
  21. url: APIS.settings.server.serverinfo(),
  22. type: "get",
  23. params: {
  24. pageSize: 15
  25. }
  26. // pageNum: "pageNo",//设置分页参数页码key值,默认为pageNum
  27. };
  28. (res_opts.pagebar = {
  29. buttons: [{ text: PLG_BUTTON.value.delBtn(), className: "layui-btn-danger plg-btn-height-auto", name: "delBtn" }]
  30. }),
  31. (res_opts.columns = [
  32. {
  33. name: "id",
  34. id: "id",
  35. hidden: true
  36. },
  37. {
  38. name: "服务名称",
  39. id: "servername",
  40. align: "left",
  41. type: "ro",
  42. width: 400,
  43. render: function (v) {
  44. return `<b style="color:#2F4056">${v}</b>`;
  45. }
  46. },
  47. {
  48. type: "SSH端口",
  49. id: "sshport",
  50. hidden: true
  51. },
  52. {
  53. name: "IP地址",
  54. id: "serverhost",
  55. align: "center",
  56. type: "ro",
  57. width: 150
  58. },
  59. {
  60. name: "采集器安装",
  61. id: "collector",
  62. align: "center",
  63. type: "ro",
  64. width: 150,
  65. render: function (v) {
  66. return v ? `<i class="layui-badge-dot layui-bg-blue"></i> 已安装` : `<i class="layui-badge-dot"></i> 末安装`;
  67. }
  68. },
  69. {
  70. name: "说明",
  71. id: "description",
  72. align: "left",
  73. type: "ro"
  74. },
  75. {
  76. id: "op",
  77. name: "操作",
  78. type: "button",
  79. width: 120,
  80. align: "center",
  81. render: function (v, d) {
  82. return "修改^global_fun.setServer.editClick,删除^global_fun.setServer.deleteClick";
  83. }
  84. }
  85. ]);
  86. res_opts.toolbar = [
  87. {
  88. type: "row",
  89. blockOffset: 0,
  90. className: "layui-col-md12",
  91. list: [
  92. {
  93. type: "row",
  94. className: "layui-col-md6",
  95. blockOffset: 0,
  96. list: [
  97. {
  98. className: "layui-col-md4",
  99. type: "input",
  100. name: "servername",
  101. label: "服务器名称:",
  102. placeholder: "输入服务名称"
  103. },
  104. {
  105. className: "layui-col-md4",
  106. type: "input",
  107. name: "serverhost",
  108. label: "IP地址:",
  109. placeholder: "输入IP地址"
  110. },
  111. {
  112. type: "button",
  113. className: "left",
  114. name: "selectAllBtn",
  115. value: PLG_BUTTON.value.searchBtn()
  116. },
  117. {
  118. type: "button",
  119. name: "resetBtn",
  120. className: "left",
  121. value: PLG_BUTTON.value.resetBtn()
  122. }
  123. ]
  124. },
  125. {
  126. type: "block",
  127. className: "layui-col-md6 right",
  128. blockOffset: 0,
  129. list: [
  130. {
  131. type: "button",
  132. name: "addBtn",
  133. value: PLG_BUTTON.value.addBtn() + "服务器"
  134. }
  135. ]
  136. }
  137. ]
  138. }
  139. ];
  140. res_opts.formData = [
  141. {
  142. type: "row",
  143. list: [
  144. {
  145. type: "settings",
  146. labelWidth: 120,
  147. position: "label-left",
  148. labelAlign: "right"
  149. },
  150. {
  151. type: "hidden",
  152. name: "id",
  153. label: "id"
  154. },
  155. {
  156. type: "input",
  157. name: "servername",
  158. label: "服务名称:",
  159. required: true,
  160. validate: "NotEmpty",
  161. placeholder: _t("请输入服务名")
  162. },
  163. {
  164. type: "input",
  165. name: "serverhost",
  166. label: "服务器IP:",
  167. required: true,
  168. validate: "NotEmpty,ValidIPv4",
  169. placeholder: _t("请输入接口地址")
  170. },
  171. {
  172. type: "input",
  173. name: "sshport",
  174. label: "SSH端口",
  175. required: true,
  176. width: 100,
  177. validate: "NotEmpty,NotNegativeNume",
  178. placeholder: _t("请输入端口")
  179. },
  180. {
  181. type: "input",
  182. name: "username",
  183. label: "服务器登录用户名:",
  184. required: true,
  185. validate: "NotEmpty",
  186. placeholder: _t("请输入用户名")
  187. },
  188. {
  189. type: "password",
  190. name: "password",
  191. label: "服务器登录密码:",
  192. required: true,
  193. validate: "NotEmpty",
  194. placeholder: _t("请输入密码")
  195. },
  196. { type: "input", name: "description", label: "说明:", rows: 3, labelTop: -20, placeholder: "请填写这个服务器是干什么用的" },
  197. {
  198. type: "block",
  199. name: "isAotuCollector",
  200. blockOffset: 0,
  201. list: [
  202. {
  203. type: "label",
  204. className: "label-form-right",
  205. label: "采集器安装:",
  206. position: "label-right"
  207. },
  208. { type: "newcolumn" },
  209. {
  210. type: "block",
  211. blockOffset: 0,
  212. list: [
  213. {
  214. type: "settings",
  215. labelWidth: 50,
  216. position: "label-left",
  217. labelAlign: "left"
  218. },
  219. { type: "radio", name: "_hasCollector", label: "已安装", value: true, position: "label-right" },
  220. { type: "newcolumn" },
  221. {
  222. type: "radio",
  223. name: "_hasCollector",
  224. label: "未安装",
  225. checked: true,
  226. value: false,
  227. position: "label-right"
  228. }
  229. ]
  230. }
  231. ]
  232. },
  233. {
  234. type: "block",
  235. hidden: false,
  236. blockOffset: 0,
  237. name: "_content",
  238. list: [
  239. {
  240. type: "label",
  241. className: "label-form-right",
  242. label: "自动安装采集器:",
  243. position: "label-right"
  244. },
  245. { type: "newcolumn" },
  246. {
  247. type: "block",
  248. blockOffset: 0,
  249. list: [
  250. {
  251. type: "settings",
  252. labelWidth: 50,
  253. position: "label-left",
  254. labelAlign: "left"
  255. },
  256. {
  257. type: "radio",
  258. name: "isAotuCollector",
  259. label: "是",
  260. value: true,
  261. position: "label-right"
  262. },
  263. { type: "newcolumn" },
  264. {
  265. type: "radio",
  266. value: false,
  267. name: "isAotuCollector",
  268. label: "否",
  269. checked: true,
  270. position: "label-right"
  271. }
  272. ]
  273. }
  274. ]
  275. }
  276. ]
  277. }
  278. ];
  279. var res_inst = new AdminPlant({
  280. instance: new PlgGrid(setConfig(res_opts)).loadData(),
  281. rowDblClickedEdit: false,
  282. addBtnUrl: APIS.settings.server.serverinfo(),
  283. editBtnUrl: APIS.settings.server.serverinfo()
  284. //delBtnUrl: APIS.settings.server.serverinfo(),
  285. // downBtnUrl: APIS.settings.server.download(),
  286. // importBtnUrl: APIS.settings.server.import(),
  287. }).init();
  288. res_inst.PlgGridInstance.on("onchange", function (name) {});
  289. res_inst.showDialogSaveBtn(function (gridForm, data) {
  290. data.isAotuCollector = !!data.isAotuCollector;
  291. delete data._hasCollector;
  292. delete data._content;
  293. return data;
  294. });
  295. res_inst.showDialogAfter(function (gridForm) {
  296. gridForm.on("onChange", function (name, value) {
  297. if (name == "_hasCollector") {
  298. if (value) {
  299. gridForm.hideItem("_content");
  300. gridForm.setItemValue("isAotuCollector", false);
  301. } else {
  302. gridForm.showItem("_content");
  303. }
  304. } else if (name == "isAotuCollector") {
  305. //如果没有安装
  306. if (!gridForm.isItemHidden("_hasCollector")) {
  307. //是否安装
  308. gridForm.setItemValue("isAotuCollector", value);
  309. }
  310. }
  311. });
  312. });
  313. window.global_fun.setServer.editClick = function (id) {
  314. res_inst.PlgGridInstance.selectRowById(id);
  315. res_inst.editBtn();
  316. };
  317. window.global_fun.setServer.deleteClick = function (id) {
  318. res_inst.PlgGridInstance.selectRowById(id);
  319. res_inst.delBtnUrl = APIS.settings.server.serverinfo() + "/" + id;
  320. res_inst.delBtn("DELETE", null);
  321. };
  322. })();
  323. </script>