pipeline.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* eslint-disable max-len */
  2. /* eslint-disable import/no-extraneous-dependencies */
  3. /* eslint-disable @typescript-eslint/no-var-requires */
  4. const router = require('express').Router();
  5. const Mock = require('mockjs');
  6. const wrapper = require('../wrapper');
  7. const { Random } = Mock;
  8. router.delete('', (req, res) => {
  9. res.json(wrapper('success'));
  10. });
  11. router.get('', (req, res) => {
  12. res.json(wrapper({
  13. configJson: JSON.stringify([
  14. {
  15. name: 'java-image-build',
  16. active: true,
  17. configs: {
  18. repoUrl: '#todo',
  19. branchName: '#todo',
  20. jarName: '#todo',
  21. },
  22. },
  23. {
  24. name: 'k8s-namespace',
  25. active: true,
  26. configs: {
  27. },
  28. },
  29. {
  30. name: 'k8s-deployment',
  31. active: true,
  32. configs: {
  33. port: '#todo',
  34. },
  35. },
  36. {
  37. name: 'k8s-service',
  38. active: true,
  39. configs: {
  40. },
  41. },
  42. {
  43. name: 'k8s-ingress',
  44. active: true,
  45. configs: {
  46. },
  47. },
  48. ]),
  49. id: req.params.pipelineId,
  50. }));
  51. });
  52. router.post('', (req, res) => {
  53. res.json(wrapper('success'));
  54. });
  55. router.get('/templates', (req, res) => {
  56. res.json(wrapper(['Java', 'MySQL', 'Node', 'Go', 'Android']));
  57. });
  58. router.put('/config', (req, res) => {
  59. res.json(wrapper('success'));
  60. });
  61. router.get('/record/list', (req, res) => {
  62. res.json(wrapper(
  63. Mock.mock(
  64. {
  65. 'data|10': [{
  66. 'id|+5': 101,
  67. pipelineId: 100,
  68. 'result|1': ['成功', '失败', '执行中', '无执行记录'],
  69. startTime: Random.datetime(),
  70. username: 'hkshu12',
  71. }],
  72. },
  73. ).data,
  74. ));
  75. });
  76. router.get('/record', (req, res) => {
  77. res.json(wrapper(
  78. Mock.mock({
  79. 'id|+5': 101,
  80. pipelineId: 100,
  81. 'result|1': ['成功', '失败', '执行中'],
  82. startTime: Random.datetime(),
  83. username: 'hkshu12',
  84. }).data,
  85. ));
  86. });
  87. router.get('/record/details', (req, res) => {
  88. res.json(wrapper(`2021-03-16 00:01:58.621 INFO 20584 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
  89. 2021-03-16 00:01:58.622 INFO 20584 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
  90. 2021-03-16 00:01:58.634 INFO 20584 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
  91. 2021-03-16 00:01:58.641 INFO 20584 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
  92. 2021-03-16 00:01:58.974 INFO 20584 --- [ main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
  93. 2021-03-16 00:01:58.975 INFO 20584 --- [ main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
  94. 2021-03-16 00:01:58.993 INFO 20584 --- [ main] s.devcloud.web.DevcloudWebApplication : Started DevcloudWebApplication in 6.659 seconds (JVM running for 8.913)
  95. 2021-03-16 00:12:39.211 INFO 20584 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
  96. 2021-03-16 00:12:39.211 INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
  97. 2021-03-16 00:12:39.222 INFO 20584 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 11 ms`));
  98. });
  99. router.get('/list', (req, res) => {
  100. res.json(wrapper(
  101. Mock.mock(
  102. {
  103. 'data|10': [{
  104. 'id|+1': 100,
  105. name: Random.cname(),
  106. 'result|1': ['成功', '失败', '执行中', '无执行记录'],
  107. startTime: Random.datetime(),
  108. username: 'hkshu12',
  109. }],
  110. },
  111. ).data,
  112. ));
  113. });
  114. module.exports = router;