home.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <link rel="stylesheet" type="text/css" href="/ops/pages/home/css/home.css" />
  2. <script src="/jq/prologui/dist/vendors/echarts/dist/echarts.js"></script>
  3. <script src="/jq/prologui/dist/vendors/echarts/dist/echarts.js"></script>
  4. <div id="home" home>
  5. <div class="plg-tab-container ">
  6. <div class="home-grid">
  7. <div class="home-grid-item">
  8. <div class="plg-flex">
  9. <i class="home-icon-a"></i>
  10. <div class="home-grid-item-wrap">
  11. <div class="title">
  12. <h3>登记服务</h3>
  13. </div>
  14. <div class="v-count value">0</div>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="home-grid-item">
  19. <div class="plg-flex">
  20. <i class="home-icon-d"></i>
  21. <div class="home-grid-item-wrap">
  22. <div class="title">
  23. <h3>登记接口</h3>
  24. </div>
  25. <div class="v-count value">0</div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="home-grid-item">
  30. <div class="plg-flex">
  31. <i class="home-icon-b"></i>
  32. <div class="home-grid-item-wrap">
  33. <div class="title">
  34. <h3>在线服务</h3>
  35. </div>
  36. <div class="v-count value">0</div>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="home-grid-item">
  41. <div class="plg-flex">
  42. <i class="home-icon-c"></i>
  43. <div class="home-grid-item-wrap">
  44. <div class="title">
  45. <h3>在线实例</h3>
  46. </div>
  47. <div class="v-count value">0</div>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="home-grid-item user-map">
  52. <div class="plg-flex" style="flex-direction: column;align-items:normal">
  53. <div class="title">
  54. <h3>用户状态</h3>
  55. </div>
  56. <div id="userMap" class="plg-flex-item"></div>
  57. </div>
  58. </div>
  59. <div class="home-grid-item port-map">
  60. <div class="plg-flex" style="flex-direction: column;align-items:normal">
  61. <div class="title">
  62. <h3>接口分布</h3>
  63. </div>
  64. <div id="portMap" class="plg-flex-item"></div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <script>
  71. (function () {
  72. //页面全部加载完成
  73. var dataList = [
  74. {
  75. color: '#ffb800',
  76. value: 0,
  77. name: '末激活'
  78. },
  79. {
  80. color: '#1e9fff',
  81. value: 0,
  82. name: '正常'
  83. },
  84. {
  85. color: '#ff5722',
  86. value: 0,
  87. name: '冻结'
  88. },
  89. ]
  90. $(document).ready(function () {
  91. /*4个模块*/
  92. var dom = document.querySelectorAll(".v-count");
  93. [APIS.home.service(), APIS.home.entry(), APIS.home.regService(), APIS.home.reginstance()]
  94. .forEach(function (item, index) {
  95. Prolog.ajax({
  96. url: item,
  97. type: "get",
  98. success: function (resolve) {
  99. if (resolve.success) {
  100. var sp = 10;
  101. var tiem = setInterval(function () {
  102. if (dom[index].innerText == resolve.data) return clearInterval(tiem)
  103. dom[index].innerText = Number(dom[index].innerText) + 1;
  104. }, sp += 10)
  105. }
  106. }
  107. })
  108. })
  109. /*用户状态*/
  110. Prolog.ajax({
  111. url: APIS.home.userStatus(),
  112. type: "get",
  113. success: function (resolve) {
  114. if (resolve.success) {
  115. var n = 0;
  116. resolve.data.forEach(function (item) {
  117. n += item.count;
  118. switch (item.status) {
  119. case 0: dataList[0].value = item.count
  120. return
  121. case 1: dataList[1].value = item.count
  122. return
  123. case 2: dataList[2].value = item.count
  124. return
  125. }
  126. })
  127. var userMapOption = {
  128. title: {
  129. text: n,
  130. subtext: '全部',
  131. x: 'center',
  132. y: 'center',
  133. textStyle: {
  134. fontSize: 30,
  135. fontWeight: 'normal',
  136. color: "#666",
  137. },
  138. subtextStyle: {
  139. color: '#666',
  140. fontSize: 16
  141. },
  142. },
  143. grid: {
  144. bottom: 130,
  145. left: 0,
  146. right: '10%'
  147. },
  148. legend: {
  149. show: false,
  150. orient: 'vertical',
  151. top: "middle",
  152. right: "5%",
  153. textStyle: {
  154. color: '#f2f2f2',
  155. fontSize: 25,
  156. },
  157. icon: 'roundRect'
  158. },
  159. series: [
  160. // 主要展示层的
  161. {
  162. radius: ['35%', '71%'],
  163. center: ['50%', '50%'],
  164. type: 'pie',
  165. itemStyle: {
  166. normal: {
  167. color: function (params) {
  168. return dataList[params.dataIndex].color
  169. }
  170. }
  171. },
  172. labelLine: {
  173. normal: {
  174. show: true,
  175. length: 20,
  176. length2: 40,
  177. lineStyle: {
  178. color: '#d3d3d3'
  179. },
  180. align: 'right'
  181. },
  182. color: "#000",
  183. emphasis: {
  184. show: true
  185. }
  186. },
  187. label: {
  188. normal: {
  189. formatter: function (params) {
  190. var str = '';
  191. switch (params.name) {
  192. case '末激活':
  193. str = '\n{nameStyle|末激活 }' + '{a|' + params.value + '}';
  194. break;
  195. case '正常':
  196. str = '\n{nameStyle|正常 }' + '{b|' + params.value + '}';
  197. break;
  198. case '冻结':
  199. str = '\n{nameStyle|冻结 }' + '{c|' + params.value + '}';
  200. break;
  201. }
  202. return str
  203. },
  204. padding: [0, 0],
  205. height: 40,
  206. rich: {
  207. nameStyle: {
  208. fontSize: 14,
  209. color: "#555",
  210. align: 'left'
  211. },
  212. a: {
  213. align: 'left',
  214. fontSize: 20,
  215. color: dataList[0].color,
  216. },
  217. b: {
  218. fontSize: 20,
  219. align: 'left',
  220. color: dataList[1].color,
  221. },
  222. c: {
  223. fontSize: 20,
  224. align: 'left',
  225. color: dataList[2].color,
  226. },
  227. }
  228. }
  229. },
  230. data: [
  231. {
  232. value: dataList[0].value,
  233. name: '末激活'
  234. },
  235. {
  236. value: dataList[1].value,
  237. name: '正常',
  238. },
  239. {
  240. value: dataList[2].value,
  241. name: '冻结'
  242. }
  243. ],
  244. },
  245. // 边框的设置
  246. {
  247. radius: ['65%', '71%'],
  248. center: ['50%', '50%'],
  249. type: 'pie',
  250. label: {
  251. normal: {
  252. show: false
  253. },
  254. emphasis: {
  255. show: false
  256. }
  257. },
  258. labelLine: {
  259. normal: {
  260. show: false
  261. },
  262. emphasis: {
  263. show: false
  264. }
  265. },
  266. animation: false,
  267. tooltip: {
  268. show: false
  269. },
  270. itemStyle: {
  271. normal: {
  272. color: 'rgba(250,250,250,0.5)'
  273. }
  274. },
  275. data: [{
  276. value: 1,
  277. }],
  278. }
  279. ]
  280. };
  281. echarts.init(document.getElementById("userMap")).setOption(userMapOption);
  282. }
  283. }
  284. });
  285. /*接口分布*/
  286. Prolog.ajax({
  287. url: APIS.home.distribute(),
  288. type: "get",
  289. success: function (resolve) {
  290. if (resolve.success) {
  291. var jkdata= resolve.data;
  292. var workOption = {
  293. tooltip: {
  294. show: true,
  295. trigger: 'axis',
  296. axisPointer: {
  297. animation: false
  298. },
  299. axisPointer: {
  300. type: 'cross',
  301. label: {
  302. backgroundColor: "#6a7985"
  303. }
  304. }
  305. },
  306. grid: {
  307. top: '10%',
  308. left: '2%',
  309. right: '5%',
  310. bottom: '5%',
  311. containLabel: true,
  312. borderWidth: 0,
  313. },
  314. xAxis: [{
  315. type: 'category',
  316. boundaryGap: true,
  317. axisLine: {
  318. show: true,
  319. lineStyle: {
  320. color: 'rgba(0,0,0,0)'
  321. }
  322. },
  323. splitLine: {
  324. show: true,
  325. lineStyle: {
  326. color: 'rgba(0,0,0,0.1)',
  327. }
  328. },
  329. data: (function () {
  330. var res =[];
  331. jkdata.filter(function(item){
  332. return res.push(item.serviceName)
  333. });
  334. return res
  335. })(),
  336. axisLabel: {
  337. //rotate :45,
  338. show: true,
  339. textStyle: {
  340. color: '#666'
  341. }
  342. }
  343. }],
  344. yAxis: [{
  345. type: 'value',
  346. min: 0,
  347. // max: 100,
  348. name: "数量",
  349. position: "left",
  350. nameTextStyle: {
  351. color: "#666"
  352. },
  353. axisLine: {
  354. show: true,
  355. lineStyle: {
  356. color: 'rgba(0,0,0,0.1)'
  357. }
  358. },
  359. axisLabel: {
  360. show: true,
  361. textStyle: {
  362. color: '#666'
  363. }
  364. }
  365. }],
  366. series: [{
  367. // name: 'CPU占用率',
  368. type: 'bar',
  369. // barWidth:20,
  370. animation: true,
  371. areaStyle: {
  372. color: 'rgba(51, 204, 255,0.6)'
  373. },
  374. color: 'rgb(51, 204, 255)',
  375. data: (function(){
  376. var res =[];
  377. jkdata.filter(function(item){
  378. return res.push(item.count)
  379. });
  380. return res
  381. })(),
  382. smooth: true,
  383. boundaryGap: true,
  384. },
  385. ]
  386. };
  387. echarts.init(document.getElementById("portMap")).setOption(workOption);
  388. }
  389. }
  390. })
  391. })
  392. // Promise.resolve(UserDom).then(function(element){
  393. // debugger
  394. // })
  395. // window.addEventListener('DOMContentLoaded', (event) => {
  396. // console.log('DOM fully loaded and parsed');
  397. // debugger
  398. // });
  399. // addEventListener("load",function(){
  400. // console.log("load")
  401. // debugger
  402. // })
  403. })()
  404. </script>