foreman_inventory_upload 0.0.1.dev1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +1 -1
  3. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +39 -0
  4. data/app/controllers/foreman_inventory_upload/reports_controller.rb +13 -6
  5. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +4 -4
  6. data/app/helpers/foreman_inventory_upload_helper.rb +1 -1
  7. data/app/views/scripts/uploader.sh.erb +21 -10
  8. data/config/routes.rb +5 -5
  9. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +19 -0
  10. data/lib/foreman_inventory_upload/async/generate_report_job.rb +13 -9
  11. data/lib/foreman_inventory_upload/async/progress_output.rb +1 -1
  12. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +12 -17
  13. data/lib/foreman_inventory_upload/async/shell_process.rb +2 -1
  14. data/lib/foreman_inventory_upload/async/upload_report_job.rb +22 -17
  15. data/lib/foreman_inventory_upload/engine.rb +11 -1
  16. data/lib/foreman_inventory_upload/generators/archived_report.rb +2 -2
  17. data/lib/foreman_inventory_upload/generators/queries.rb +20 -11
  18. data/lib/foreman_inventory_upload/generators/slice.rb +26 -5
  19. data/lib/foreman_inventory_upload/version.rb +1 -1
  20. data/lib/foreman_inventory_upload.rb +15 -10
  21. data/lib/tasks/generator.rake +19 -5
  22. data/package.json +125 -0
  23. data/test/controllers/{statuses_controller_test.rb → accounts_controller_test.rb} +6 -7
  24. data/test/controllers/reports_controller_test.rb +3 -3
  25. data/test/controllers/uploads_controller_test.rb +3 -3
  26. data/test/unit/archived_report_generator_test.rb +4 -4
  27. data/test/unit/slice_generator_test.rb +75 -1
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +37 -0
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +74 -0
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +18 -0
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +65 -0
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListConstants.js +9 -0
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +0 -0
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +55 -0
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +8 -0
  36. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.fixtures.js +0 -0
  37. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js +16 -0
  38. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyStateHelper.js +0 -0
  39. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +13 -0
  40. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +26 -0
  41. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +7 -0
  42. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/index.js +1 -0
  43. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.fixtures.js +0 -0
  44. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.js +23 -0
  45. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorStateHelper.js +0 -0
  46. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +13 -0
  47. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
  48. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +18 -0
  49. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/index.js +1 -0
  50. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +1 -0
  51. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +41 -0
  52. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItemHelper.js +0 -0
  53. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +13 -0
  54. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +50 -0
  55. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/index.js +1 -0
  56. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
  57. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +7 -0
  58. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +43 -0
  59. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +29 -0
  60. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +14 -0
  61. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +78 -0
  62. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/index.js +1 -0
  63. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +16 -0
  64. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +13 -0
  65. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +20 -0
  66. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
  67. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +60 -0
  68. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +26 -0
  69. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +44 -0
  70. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +47 -0
  71. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +69 -0
  72. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +46 -0
  73. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +9 -0
  74. data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +27 -0
  75. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +50 -0
  76. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +146 -0
  77. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +19 -0
  78. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +87 -0
  79. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js +9 -0
  80. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardHelper.js +0 -0
  81. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js +68 -0
  82. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +17 -0
  83. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +25 -0
  84. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +39 -0
  85. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +16 -0
  86. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +64 -0
  87. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +45 -0
  88. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +36 -0
  89. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap +76 -0
  90. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap +44 -0
  91. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap +42 -0
  92. data/webpack/ForemanInventoryUpload/Components/Dashboard/dashboard.scss +0 -0
  93. data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +34 -0
  94. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.fixtures.js +0 -0
  95. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +22 -0
  96. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownloadHelper.js +0 -0
  97. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +13 -0
  98. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +25 -0
  99. data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +3 -0
  100. data/webpack/ForemanInventoryUpload/Components/FileDownload/index.js +1 -0
  101. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js +0 -0
  102. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +50 -0
  103. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js +0 -0
  104. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +13 -0
  105. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +64 -0
  106. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +10 -0
  107. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js +1 -0
  108. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +10 -0
  109. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +83 -0
  110. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainerHelper.js +0 -0
  111. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +26 -0
  112. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +89 -0
  113. data/webpack/ForemanInventoryUpload/Components/NavContainer/index.js +1 -0
  114. data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -0
  115. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +16 -0
  116. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +57 -0
  117. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js +0 -0
  118. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +14 -0
  119. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +45 -0
  120. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js +1 -0
  121. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss +0 -0
  122. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +18 -0
  123. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +57 -0
  124. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js +0 -0
  125. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +14 -0
  126. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +45 -0
  127. data/webpack/ForemanInventoryUpload/Components/ReportUpload/index.js +1 -0
  128. data/webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss +0 -0
  129. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +3 -0
  130. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +27 -0
  131. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRunHelper.js +0 -0
  132. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +14 -0
  133. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +25 -0
  134. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -0
  135. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +11 -0
  136. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.fixtures.js +0 -0
  137. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +56 -0
  138. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChartHelper.js +0 -0
  139. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +13 -0
  140. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
  141. data/webpack/ForemanInventoryUpload/Components/StatusChart/index.js +1 -0
  142. data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +8 -0
  143. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js +0 -0
  144. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js +31 -0
  145. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js +0 -0
  146. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +13 -0
  147. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +19 -0
  148. data/webpack/ForemanInventoryUpload/Components/TabBody/index.js +1 -0
  149. data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +3 -0
  150. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.fixtures.js +0 -0
  151. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.js +24 -0
  152. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainerHelper.js +0 -0
  153. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +13 -0
  154. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
  155. data/webpack/ForemanInventoryUpload/Components/TabContainer/index.js +1 -0
  156. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +8 -0
  157. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.fixtures.js +0 -0
  158. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.js +19 -0
  159. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooterHelper.js +0 -0
  160. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +13 -0
  161. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
  162. data/webpack/ForemanInventoryUpload/Components/TabFooter/index.js +1 -0
  163. data/webpack/ForemanInventoryUpload/Components/TabFooter/tabFooter.scss +0 -0
  164. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.fixtures.js +0 -0
  165. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +45 -0
  166. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeaderHelper.js +0 -0
  167. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +13 -0
  168. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/__snapshots__/TabHeader.test.js.snap +53 -0
  169. data/webpack/ForemanInventoryUpload/Components/TabHeader/index.js +1 -0
  170. data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +21 -0
  171. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.fixtures.js +10 -0
  172. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +112 -0
  173. data/webpack/ForemanInventoryUpload/Components/Terminal/TerminalHelper.js +6 -0
  174. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +35 -0
  175. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +98 -0
  176. data/webpack/ForemanInventoryUpload/Components/Terminal/index.js +1 -0
  177. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +31 -0
  178. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +15 -0
  179. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js +10 -0
  180. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +12 -0
  181. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +4 -0
  182. data/webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap +16 -0
  183. data/webpack/ForemanInventoryUpload/index.js +1 -0
  184. data/webpack/__mocks__/foremanReact/API.js +7 -0
  185. data/webpack/__mocks__/foremanReact/common/I18n.js +5 -0
  186. data/webpack/__mocks__/foremanReact/common/helpers.js +3 -0
  187. data/webpack/index.js +18 -0
  188. data/webpack/stories/ForemanInventoryUploadReducers.js +3 -0
  189. data/webpack/stories/configureStore.js +15 -0
  190. data/webpack/stories/decorators/index.js +1 -0
  191. data/webpack/stories/decorators/withCardsDecorator.js +14 -0
  192. data/webpack/stories/index.js +10 -0
  193. data/webpack/stories/index.scss +7 -0
  194. data/webpack/test_setup.js +6 -0
  195. metadata +205 -9
  196. data/app/controllers/foreman_inventory_upload/statuses_controller.rb +0 -41
data/package.json ADDED
@@ -0,0 +1,125 @@
1
+ {
2
+ "name": "foreman_inventory_upload",
3
+ "version": "0.0.1",
4
+ "description": "Inventory Upload =============",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "lint": "./node_modules/.bin/eslint -c .eslintrc webpack/",
8
+ "test": "node node_modules/.bin/jest --no-cache",
9
+ "test:watch": "node node_modules/.bin/jest --watchAll",
10
+ "test:current": "node node_modules/.bin/jest --watch",
11
+ "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
12
+ "storybook": "start-storybook -p 6006",
13
+ "storybook:build": "node --max_old_space_size=2048 ./node_modules/.bin/build-storybook --config-dir .storybook --output-dir .storybook-dist",
14
+ "storybook:deploy": "surge --project .storybook-dist"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/theforeman/foreman_inventory_upload.git"
19
+ },
20
+ "bugs": {
21
+ "url": "http://projects.theforeman.org/projects/foreman_inventory_upload/issues"
22
+ },
23
+ "optionalDependencies": {
24
+ "babel-plugin-module-resolver": "^3.2.0"
25
+ },
26
+ "devDependencies": {
27
+ "@storybook/addon-actions": "^5.0.1",
28
+ "@storybook/addon-knobs": "^5.0.1",
29
+ "@storybook/react": "^5.0.1",
30
+ "babel-cli": "^6.10.1",
31
+ "babel-core": "^6.26.3",
32
+ "babel-eslint": "^8.2.3",
33
+ "babel-jest": "^23.6.0",
34
+ "babel-loader": "^7.1.1",
35
+ "babel-plugin-dynamic-import-node": "^2.0.0",
36
+ "babel-plugin-lodash": "^3.3.4",
37
+ "babel-plugin-syntax-dynamic-import": "^6.18.0",
38
+ "babel-plugin-transform-class-properties": "^6.24.1",
39
+ "babel-plugin-transform-object-assign": "^6.8.0",
40
+ "babel-plugin-transform-object-rest-spread": "^6.8.0",
41
+ "babel-preset-env": "^1.7.0",
42
+ "babel-preset-react": "^6.5.0",
43
+ "coveralls": "^3.0.0",
44
+ "enzyme": "^3.4.0",
45
+ "enzyme-adapter-react-16": "^1.4.0",
46
+ "enzyme-to-json": "^3.2.1",
47
+ "eslint": "^4.10.0",
48
+ "eslint-import-resolver-babel-module": "^4.0.0",
49
+ "eslint-plugin-patternfly-react": "0.2.0",
50
+ "identity-obj-proxy": "^3.0.0",
51
+ "jed": "^1.1.1",
52
+ "jest-cli": "^23.6.0",
53
+ "jest-prop-type-error": "^1.1.0",
54
+ "node-sass": "^4.5.0",
55
+ "patternfly": "^3.58.0",
56
+ "prettier": "^1.13.5",
57
+ "raf": "^3.4.0",
58
+ "react-redux-test-utils": "^0.1.1",
59
+ "react-remarkable": "^1.1.3",
60
+ "sass-loader": "^6.0.7",
61
+ "stylelint": "^9.3.0",
62
+ "stylelint-config-standard": "^18.0.0",
63
+ "surge": "^0.20.3"
64
+ },
65
+ "dependencies": {
66
+ "babel-polyfill": "^6.26.0",
67
+ "classnames": "^2.2.5",
68
+ "lodash": "^4.17.10",
69
+ "patternfly-react": "^2.19.1",
70
+ "prop-types": "^15.6.0",
71
+ "react": "^16.4.0",
72
+ "react-dom": "^16.4.0",
73
+ "react-intl": "^2.8.0",
74
+ "react-redux": "^5.0.6",
75
+ "redux": "^3.6.0",
76
+ "redux-thunk": "^2.2.0",
77
+ "reselect": "^3.0.1",
78
+ "seamless-immutable": "^7.1.2",
79
+ "urijs": "^1.18.10",
80
+ "uuid": "^3.0.1"
81
+ },
82
+ "jest": {
83
+ "automock": true,
84
+ "verbose": true,
85
+ "testMatch": [
86
+ "**/*.test.js"
87
+ ],
88
+ "testURL": "http://localhost/",
89
+ "collectCoverage": true,
90
+ "collectCoverageFrom": [
91
+ "webpack/**/*.js",
92
+ "!webpack/index.js",
93
+ "!webpack/test_setup.js",
94
+ "!webpack/**/bundle*",
95
+ "!webpack/stories/**",
96
+ "!webpack/**/*stories.js"
97
+ ],
98
+ "coverageReporters": [
99
+ "lcov"
100
+ ],
101
+ "unmockedModulePathPatterns": [
102
+ "webpack/",
103
+ "react",
104
+ "node_modules/"
105
+ ],
106
+ "moduleNameMapper": {
107
+ "^.+\\.(png|gif|css|scss)$": "identity-obj-proxy"
108
+ },
109
+ "globals": {
110
+ "__testing__": true
111
+ },
112
+ "transform": {
113
+ "^.+\\.js$": "babel-jest"
114
+ },
115
+ "moduleDirectories": [
116
+ "node_modules",
117
+ "webpack"
118
+ ],
119
+ "setupFiles": [
120
+ "raf/polyfill",
121
+ "jest-prop-type-error",
122
+ "./webpack/test_setup.js"
123
+ ]
124
+ }
125
+ }
@@ -1,25 +1,24 @@
1
1
  require 'test_plugin_helper'
2
2
 
3
- class StatusesControllerTest < ActionController::TestCase
4
- tests ForemanInventoryUpload::StatusesController
3
+ class AccountsControllerTest < ActionController::TestCase
4
+ tests ForemanInventoryUpload::AccountsController
5
5
 
6
6
  include FolderIsolation
7
7
 
8
8
  test 'Returns statuses for each process type' do
9
- configuration = RedhatAccess::TelemetryConfiguration.new(enable_telemetry: true, portal_user: 'test')
10
- configuration.save!
9
+ test_org = FactoryBot.create(:organization)
11
10
 
12
- generate_label = ForemanInventoryUpload::Async::GenerateReportJob.output_label('test')
11
+ generate_label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(test_org.id)
13
12
  generate_output = ForemanInventoryUpload::Async::ProgressOutput.register(generate_label)
14
13
  generate_output.status = 'generate_status_test'
15
- upload_label = ForemanInventoryUpload::Async::UploadReportJob.output_label('test')
14
+ upload_label = ForemanInventoryUpload::Async::UploadReportJob.output_label(test_org.id)
16
15
  upload_output = ForemanInventoryUpload::Async::ProgressOutput.register(upload_label)
17
16
  upload_output.status = 'upload_status_test'
18
17
 
19
18
  get :index, session: set_session_user
20
19
 
21
20
  assert_response :success
22
- actual = JSON.parse(response.body)['statuses']['test']
21
+ actual = JSON.parse(response.body)['accounts'][test_org.id.to_s]
23
22
  assert_equal 'generate_status_test', actual['generate_report_status']
24
23
  assert_equal 'upload_status_test', actual['upload_report_status']
25
24
  end
@@ -5,14 +5,14 @@ class ReportsControllerTest < ActionController::TestCase
5
5
 
6
6
  test 'Returns latest report generation status' do
7
7
  progress_output = mock('progress_output')
8
- test_portal_user = 'test_portal_user'
8
+ test_org = FactoryBot.create(:organization)
9
9
  ForemanInventoryUpload::Async::ProgressOutput
10
10
  .expects(:get)
11
- .with(ForemanInventoryUpload::Async::GenerateReportJob.output_label(test_portal_user))
11
+ .with(ForemanInventoryUpload::Async::GenerateReportJob.output_label(test_org.id))
12
12
  .returns(progress_output)
13
13
  progress_output.expects(:full_output).returns('test output')
14
14
 
15
- get :last, params: { portal_user: test_portal_user }, session: set_session_user
15
+ get :last, params: { organization_id: test_org.id }, session: set_session_user
16
16
 
17
17
  assert_response :success
18
18
  actual = JSON.parse(response.body)
@@ -5,14 +5,14 @@ class UploadsControllerTest < ActionController::TestCase
5
5
 
6
6
  test 'Returns latest upload status' do
7
7
  progress_output = mock('progress_output')
8
- test_portal_user = 'test_portal_user'
8
+ test_org = FactoryBot.create(:organization)
9
9
  ForemanInventoryUpload::Async::ProgressOutput
10
10
  .expects(:get)
11
- .with(ForemanInventoryUpload::Async::UploadReportJob.output_label(test_portal_user))
11
+ .with(ForemanInventoryUpload::Async::UploadReportJob.output_label(test_org.id))
12
12
  .returns(progress_output)
13
13
  progress_output.expects(:full_output).returns('test output')
14
14
 
15
- get :last, params: { portal_user: test_portal_user }, session: set_session_user
15
+ get :last, params: { organization_id: test_org.id }, session: set_session_user
16
16
 
17
17
  assert_response :success
18
18
  actual = JSON.parse(response.body)
@@ -32,7 +32,7 @@ class ArchivedReportGeneratorTest < ActiveSupport::TestCase
32
32
  'dmi::bios::relase_date',
33
33
  'distribution::name',
34
34
  'uname::release',
35
- 'lscpu::flags'
35
+ 'lscpu::flags',
36
36
  ]
37
37
  end
38
38
 
@@ -46,13 +46,13 @@ class ArchivedReportGeneratorTest < ActiveSupport::TestCase
46
46
 
47
47
  test 'generates a report for a single host' do
48
48
  batches = Host.where(id: @host.id).in_batches
49
- portal_user = 'test_portal_user'
49
+ test_org = FactoryBot.create(:organization)
50
50
 
51
- ForemanInventoryUpload::Generators::Queries.expects(:for_report).with(portal_user).returns(batches)
51
+ ForemanInventoryUpload::Generators::Queries.expects(:for_org).with(test_org.id).returns(batches)
52
52
  Dir.mktmpdir do |tmpdir|
53
53
  target = File.join(tmpdir, 'test.tar.gz')
54
54
  generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
55
- generator.render(portal_user)
55
+ generator.render(organization: test_org.id)
56
56
 
57
57
  files = Dir["#{tmpdir}/*"]
58
58
  assert_equal "#{tmpdir}/test.tar.gz", files.first
@@ -32,7 +32,7 @@ class ReportGeneratorTest < ActiveSupport::TestCase
32
32
  'dmi::bios::relase_date',
33
33
  'distribution::name',
34
34
  'uname::release',
35
- 'lscpu::flags'
35
+ 'lscpu::flags',
36
36
  ]
37
37
  end
38
38
 
@@ -57,4 +57,78 @@ class ReportGeneratorTest < ActiveSupport::TestCase
57
57
  assert_equal @host.fqdn, actual_host['fqdn']
58
58
  assert_equal '1234', actual_host['account']
59
59
  end
60
+
61
+ test 'generates a report with satellite facts' do
62
+ Foreman.expects(:instance_id).returns('satellite-id')
63
+ batch = Host.where(id: @host.id).in_batches.first
64
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice-123')
65
+
66
+ json_str = generator.render
67
+ actual = JSON.parse(json_str.join("\n"))
68
+
69
+ facts = actual['hosts'].first['facts'].first
70
+ assert_equal 'satellite', facts['namespace']
71
+ satellite_facts = facts['facts']
72
+ assert_equal 'satellite-id', satellite_facts['satellite_instance_id']
73
+ assert_equal @host.organization_id, satellite_facts['organization_id']
74
+
75
+ version = satellite_facts['satellite_version']
76
+ if defined?(ForemanThemeSatellite)
77
+ assert_equal ForemanThemeSatellite::SATELLITE_VERSION, version
78
+ else
79
+ assert_nil version
80
+ end
81
+ end
82
+
83
+ test 'generates a report for a host with hypervisor' do
84
+ hypervisor_host = FactoryBot.create(
85
+ :host,
86
+ :with_subscription,
87
+ :with_content,
88
+ content_view: @host.content_view,
89
+ lifecycle_environment: @host.lifecycle_environment,
90
+ organization: @host.organization
91
+ )
92
+
93
+ @host.subscription_facet.hypervisor_host = hypervisor_host
94
+ @host.save!
95
+
96
+ batch = Host.where(id: @host.id).in_batches.first
97
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
98
+
99
+ json_str = generator.render
100
+ actual = JSON.parse(json_str.join("\n"))
101
+
102
+ assert_equal 'slice_123', actual['report_slice_id']
103
+ assert_not_nil(actual_host = actual['hosts'].first)
104
+ assert_equal @host.name, actual_host['display_name']
105
+ assert_equal @host.fqdn, actual_host['fqdn']
106
+ assert_not_nil(host_facts = actual_host['facts']&.first)
107
+ assert_equal 'satellite', host_facts['namespace']
108
+ assert_not_nil(fact_values = host_facts['facts'])
109
+ assert_equal hypervisor_host.name, fact_values['virtual_host_name']
110
+ assert_equal hypervisor_host.subscription_facet.uuid, fact_values['virtual_host_uuid']
111
+ end
112
+
113
+ test 'generates a report with system purpose' do
114
+ @host.subscription_facet.purpose_usage = 'test_usage'
115
+ @host.subscription_facet.purpose_role = 'test_role'
116
+ @host.subscription_facet.save!
117
+
118
+ batch = Host.where(id: @host.id).in_batches.first
119
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
120
+
121
+ json_str = generator.render
122
+ actual = JSON.parse(json_str.join("\n"))
123
+
124
+ assert_equal 'slice_123', actual['report_slice_id']
125
+ assert_not_nil(actual_host = actual['hosts'].first)
126
+ assert_equal @host.name, actual_host['display_name']
127
+ assert_equal @host.fqdn, actual_host['fqdn']
128
+ assert_not_nil(host_facts = actual_host['facts']&.first)
129
+ assert_equal 'satellite', host_facts['namespace']
130
+ assert_not_nil(fact_values = host_facts['facts'])
131
+ assert_equal 'test_usage', fact_values['system_purpose_usage']
132
+ assert_equal 'test_role', fact_values['system_purpose_role']
133
+ end
60
134
  end
@@ -0,0 +1,37 @@
1
+ import { noop } from 'patternfly-react';
2
+
3
+ export const API_SUCCESS_RESPONSE = {
4
+ Account1: {
5
+ label: 'test_org1',
6
+ upload_report_status: 'running',
7
+ generate_report_status: 'running',
8
+ },
9
+ Account2: {
10
+ label: 'test_org2',
11
+ upload_report_status: 'unknown',
12
+ generate_report_status: 'failure',
13
+ },
14
+ Account3: {
15
+ label: 'test_org3',
16
+ upload_report_status: 'success',
17
+ generate_report_status: 'running',
18
+ },
19
+ };
20
+
21
+ export const accounts = API_SUCCESS_RESPONSE;
22
+
23
+ export const pollingProcessID = 0;
24
+
25
+ export const error = 'some-error';
26
+
27
+ export const accountID = 'user@redhat.com';
28
+
29
+ export const processStatusName = 'upload_report_status';
30
+
31
+ export const props = {
32
+ accounts,
33
+ fetchAccountsStatus: noop,
34
+ startAccountStatusPolling: noop,
35
+ stopAccountStatusPolling: noop,
36
+ pollingProcessID,
37
+ };
@@ -0,0 +1,74 @@
1
+ import React, { Component } from 'react';
2
+ import { ListView, noop } from 'patternfly-react';
3
+ import PropTypes from 'prop-types';
4
+ import ListItem from './Components/ListItem';
5
+ import EmptyState from './Components/EmptyState';
6
+ import ErrorState from './Components/ErrorState';
7
+ import './accountList.scss';
8
+
9
+ class AccountList extends Component {
10
+ componentDidMount() {
11
+ const { fetchAccountsStatus, startAccountStatusPolling } = this.props;
12
+ fetchAccountsStatus();
13
+ const pollingProcessID = setInterval(fetchAccountsStatus, 5000);
14
+ startAccountStatusPolling(pollingProcessID);
15
+ }
16
+
17
+ componentWillUnmount() {
18
+ const { stopAccountStatusPolling, pollingProcessID } = this.props;
19
+ stopAccountStatusPolling(pollingProcessID);
20
+ }
21
+
22
+ render() {
23
+ const { accounts, error } = this.props;
24
+ const accountIds = Object.keys(accounts);
25
+
26
+ if (error) {
27
+ return <ErrorState error={error} />;
28
+ }
29
+
30
+ if (accountIds.length === 0) {
31
+ return <EmptyState />;
32
+ }
33
+ const items = accountIds.map((accountID, index) => {
34
+ const account = accounts[accountID];
35
+ return (
36
+ <ListItem
37
+ key={index}
38
+ accountID={accountID}
39
+ account={account}
40
+ initExpanded={index === 0}
41
+ />
42
+ );
43
+ });
44
+ return <ListView className="account_list">{items}</ListView>;
45
+ }
46
+ }
47
+
48
+ AccountList.propTypes = {
49
+ fetchAccountsStatus: PropTypes.func,
50
+ startAccountStatusPolling: PropTypes.func,
51
+ stopAccountStatusPolling: PropTypes.func,
52
+ pollingProcessID: PropTypes.number,
53
+ account: PropTypes.shape({
54
+ generate_report_status: PropTypes.string,
55
+ upload_report_status: PropTypes.string,
56
+ }),
57
+ accounts: PropTypes.object,
58
+ error: PropTypes.string,
59
+ };
60
+
61
+ AccountList.defaultProps = {
62
+ fetchAccountsStatus: noop,
63
+ startAccountStatusPolling: noop,
64
+ stopAccountStatusPolling: noop,
65
+ pollingProcessID: 0,
66
+ account: {
67
+ generate_report_status: 'unknown',
68
+ upload_report_status: 'unknown',
69
+ },
70
+ accounts: {},
71
+ error: '',
72
+ };
73
+
74
+ export default AccountList;
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { withKnobs } from '@storybook/addon-knobs';
4
+ import { Provider } from 'react-redux';
5
+ import configureStore from '../../../stories/configureStore';
6
+ import AccountList from './AccountList';
7
+
8
+ const store = configureStore();
9
+
10
+ storiesOf('Account list', module)
11
+ .addDecorator(withKnobs)
12
+ .add('Account list', () => (
13
+ <div style={{ margin: '20px' }}>
14
+ <Provider store={store}>
15
+ <AccountList />
16
+ </Provider>
17
+ </div>
18
+ ));
@@ -0,0 +1,65 @@
1
+ import API from 'foremanReact/API';
2
+ import {
3
+ INVENTORY_ACCOUNT_STATUS_POLLING,
4
+ INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
5
+ INVENTORY_ACCOUNT_STATUS_POLLING_START,
6
+ INVENTORY_ACCOUNT_STATUS_POLLING_STOP,
7
+ INVENTORY_PROCESS_RESTART,
8
+ } from './AccountListConstants';
9
+
10
+ export const fetchAccountsStatus = () => async dispatch => {
11
+ try {
12
+ const {
13
+ data: { accounts },
14
+ } = await API.get('accounts');
15
+ dispatch({
16
+ type: INVENTORY_ACCOUNT_STATUS_POLLING,
17
+ payload: {
18
+ accounts,
19
+ },
20
+ });
21
+ } catch (error) {
22
+ dispatch({
23
+ type: INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
24
+ payload: {
25
+ error: error.message,
26
+ },
27
+ });
28
+ }
29
+ };
30
+
31
+ export const startAccountStatusPolling = pollingProcessID => ({
32
+ type: INVENTORY_ACCOUNT_STATUS_POLLING_START,
33
+ payload: {
34
+ pollingProcessID,
35
+ },
36
+ });
37
+
38
+ export const stopAccountStatusPolling = pollingProcessID => dispatch => {
39
+ clearInterval(pollingProcessID);
40
+ dispatch({
41
+ type: INVENTORY_ACCOUNT_STATUS_POLLING_STOP,
42
+ });
43
+ };
44
+
45
+ export const restartProcess = (accountID, activeTab) => dispatch => {
46
+ let processController = null;
47
+ let processStatusName = null;
48
+
49
+ if (activeTab === 'uploading') {
50
+ processController = 'uploads';
51
+ processStatusName = 'upload_report_status';
52
+ } else {
53
+ processController = 'reports';
54
+ processStatusName = 'generate_report_status';
55
+ }
56
+
57
+ API.post(`${accountID}/${processController}`);
58
+ dispatch({
59
+ type: INVENTORY_PROCESS_RESTART,
60
+ payload: {
61
+ accountID,
62
+ processStatusName,
63
+ },
64
+ });
65
+ };
@@ -0,0 +1,9 @@
1
+ export const INVENTORY_ACCOUNT_STATUS_POLLING =
2
+ 'INVENTORY_ACCOUNT_STATUS_POLLING';
3
+ export const INVENTORY_ACCOUNT_STATUS_POLLING_ERROR =
4
+ 'INVENTORY_ACCOUNT_STATUS_POLLING_ERROR';
5
+ export const INVENTORY_ACCOUNT_STATUS_POLLING_START =
6
+ 'INVENTORY_ACCOUNT_STATUS_POLLING_START';
7
+ export const INVENTORY_ACCOUNT_STATUS_POLLING_STOP =
8
+ 'INVENTORY_ACCOUNT_STATUS_POLLING_STOP';
9
+ export const INVENTORY_PROCESS_RESTART = 'INVENTORY_PROCESS_RESTART';
@@ -0,0 +1,55 @@
1
+ import Immutable from 'seamless-immutable';
2
+ import {
3
+ INVENTORY_ACCOUNT_STATUS_POLLING,
4
+ INVENTORY_ACCOUNT_STATUS_POLLING_ERROR,
5
+ INVENTORY_ACCOUNT_STATUS_POLLING_START,
6
+ INVENTORY_PROCESS_RESTART,
7
+ } from './AccountListConstants';
8
+
9
+ const initialState = Immutable({
10
+ accounts: {},
11
+ pollingProcessID: 0,
12
+ error: null,
13
+ });
14
+
15
+ export default (state = initialState, action) => {
16
+ const {
17
+ payload: {
18
+ pollingProcessID,
19
+ error,
20
+ accounts,
21
+ accountID,
22
+ processStatusName,
23
+ } = {},
24
+ } = action;
25
+
26
+ switch (action.type) {
27
+ case INVENTORY_ACCOUNT_STATUS_POLLING:
28
+ return state.merge({
29
+ ...state,
30
+ accounts,
31
+ error: null,
32
+ });
33
+ case INVENTORY_ACCOUNT_STATUS_POLLING_ERROR:
34
+ return state.merge({
35
+ ...state,
36
+ accounts: {},
37
+ error,
38
+ });
39
+ case INVENTORY_ACCOUNT_STATUS_POLLING_START:
40
+ return state.merge({
41
+ ...state,
42
+ pollingProcessID,
43
+ });
44
+ case INVENTORY_PROCESS_RESTART:
45
+ return state.setIn(['accounts'], {
46
+ ...state.accounts,
47
+ [accountID]: {
48
+ ...state.accounts[accountID],
49
+ [processStatusName]: 'Restarting...',
50
+ },
51
+ });
52
+ default:
53
+ return state;
54
+ }
55
+ };
@@ -0,0 +1,8 @@
1
+ import { selectForemanInventoryUpload } from '../../ForemanInventoryUploadSelectors';
2
+
3
+ export const selectAccountsList = state =>
4
+ selectForemanInventoryUpload(state).accountsList;
5
+ export const selectAccounts = state => selectAccountsList(state).accounts;
6
+ export const selectPollingProcessID = state =>
7
+ selectAccountsList(state).pollingProcessID;
8
+ export const selectError = state => selectAccountsList(state).error;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { EmptyState, Spinner } from 'patternfly-react';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
4
+ import './emptyState.scss';
5
+
6
+ const inventoryEmptyState = () => (
7
+ <EmptyState>
8
+ <Spinner loading inline size="lg" />
9
+ <EmptyState.Title>
10
+ {__('Fetching data about your accounts')}
11
+ </EmptyState.Title>
12
+ <EmptyState.Info>{__('Loading')}...</EmptyState.Info>
13
+ </EmptyState>
14
+ );
15
+
16
+ export default inventoryEmptyState;
@@ -0,0 +1,13 @@
1
+ import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import EmptyState from '../EmptyState';
4
+
5
+ const fixtures = {
6
+ 'render without Props': {},
7
+ /** fixtures, props for the component */
8
+ };
9
+
10
+ describe('EmptyState', () => {
11
+ describe('rendering', () =>
12
+ testComponentSnapshotsWithFixtures(EmptyState, fixtures));
13
+ });
@@ -0,0 +1,26 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`EmptyState rendering render without Props 1`] = `
4
+ <EmptyState
5
+ className=""
6
+ >
7
+ <Spinner
8
+ className=""
9
+ inline={true}
10
+ inverse={false}
11
+ loading={true}
12
+ size="lg"
13
+ />
14
+ <EmptyStateTitle
15
+ className=""
16
+ >
17
+ Fetching data about your accounts
18
+ </EmptyStateTitle>
19
+ <EmptyStateInfo
20
+ className=""
21
+ >
22
+ Loading
23
+ ...
24
+ </EmptyStateInfo>
25
+ </EmptyState>
26
+ `;
@@ -0,0 +1,7 @@
1
+ .blank-slate-pf {
2
+ margin-top: 100px;
3
+
4
+ .spinner {
5
+ float: none;
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ export { default } from './EmptyState';