codecharta-visualization 1.86.0 → 1.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/Dockerfile +1 -1
  2. package/app/app.module.ts +30 -6
  3. package/app/codeCharta/codeCharta.component.html +0 -2
  4. package/app/codeCharta/codeCharta.component.ts +2 -0
  5. package/app/codeCharta/codeCharta.model.ts +8 -5
  6. package/app/codeCharta/codeCharta.service.spec.ts +41 -50
  7. package/app/codeCharta/codeCharta.service.ts +33 -32
  8. package/app/codeCharta/e2e/url.e2e.ts +1 -1
  9. package/app/codeCharta/services/ajs-upgraded-providers.ts +13 -0
  10. package/app/codeCharta/state/angular-redux/effects/createEffect.spec.ts +37 -0
  11. package/app/codeCharta/state/angular-redux/effects/createEffect.ts +25 -0
  12. package/app/codeCharta/state/angular-redux/effects/effects.module.ts +36 -0
  13. package/app/codeCharta/state/angular-redux/ofType.ts +11 -0
  14. package/app/codeCharta/state/angular-redux/state.ts +12 -0
  15. package/app/codeCharta/state/angular-redux/store.ts +1 -1
  16. package/app/codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/addBlacklistItemsIfNotResultsInEmptyMap.effect.spec.ts +60 -0
  17. package/app/codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/addBlacklistItemsIfNotResultsInEmptyMap.effect.ts +56 -0
  18. package/app/codeCharta/state/effects/addBlacklistItemsIfNotResultsInEmptyMap/resultsInEmptyMap.ts +22 -0
  19. package/app/codeCharta/state/effects/nodeContextMenu/excludeButton/excludeButton.component.html +3 -0
  20. package/app/codeCharta/state/effects/nodeContextMenu/excludeButton/excludeButton.component.ts +26 -0
  21. package/app/codeCharta/state/effects/nodeContextMenu/flattenButtons/flattenButtons.component.html +13 -0
  22. package/app/codeCharta/state/effects/nodeContextMenu/flattenButtons/flattenButtons.component.spec.ts +55 -0
  23. package/app/codeCharta/state/effects/nodeContextMenu/flattenButtons/flattenButtons.component.ts +34 -0
  24. package/app/codeCharta/state/effects/nodeContextMenu/flattenButtons/flattenButtons.module.ts +11 -0
  25. package/app/codeCharta/state/effects/nodeContextMenu/focusButtons/focusButtons.component.html +24 -0
  26. package/app/codeCharta/state/effects/nodeContextMenu/focusButtons/focusButtons.component.spec.ts +55 -0
  27. package/app/codeCharta/state/effects/nodeContextMenu/focusButtons/focusButtons.component.ts +38 -0
  28. package/app/codeCharta/state/effects/nodeContextMenu/focusButtons/focusButtons.module.ts +13 -0
  29. package/app/codeCharta/state/effects/nodeContextMenu/focusButtons/isNodeFocused.pipe.spec.ts +31 -0
  30. package/app/codeCharta/state/effects/nodeContextMenu/focusButtons/isNodeFocused.pipe.ts +25 -0
  31. package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.component.html +6 -0
  32. package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.component.spec.ts +64 -0
  33. package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.component.ts +39 -0
  34. package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.module.ts +11 -0
  35. package/app/codeCharta/state/effects/nodeContextMenu/markFolderRow/markFolderRow.component.html +22 -0
  36. package/app/codeCharta/state/effects/nodeContextMenu/markFolderRow/markFolderRow.component.scss +31 -0
  37. package/app/codeCharta/state/effects/nodeContextMenu/markFolderRow/markFolderRow.component.spec.ts +35 -0
  38. package/app/codeCharta/state/effects/nodeContextMenu/markFolderRow/markFolderRow.component.ts +30 -0
  39. package/app/codeCharta/state/effects/nodeContextMenu/markFolderRow/markFolderRow.module.ts +11 -0
  40. package/app/codeCharta/state/effects/nodeContextMenu/markFolderRow/selectors/markFolderItems.selector.spec.ts +17 -0
  41. package/app/codeCharta/state/effects/nodeContextMenu/markFolderRow/selectors/markFolderItems.selector.ts +29 -0
  42. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/nodeContextMenu.e2e.ts +4 -16
  43. package/app/codeCharta/{ui → state/effects}/nodeContextMenu/nodeContextMenu.po.ts +1 -1
  44. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenu.service.spec.ts +78 -0
  45. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenu.service.ts +72 -0
  46. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/lastPartOfNodePath.pipe.spec.ts +11 -0
  47. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/lastPartOfNodePath.pipe.ts +8 -0
  48. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.html +17 -0
  49. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.scss +34 -0
  50. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.spec.ts +49 -0
  51. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.ts +19 -0
  52. package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.module.ts +18 -0
  53. package/app/codeCharta/state/effects/nodeContextMenu/openNodeContextMenu.effect.spec.ts +32 -0
  54. package/app/codeCharta/state/effects/nodeContextMenu/openNodeContextMenu.effect.ts +33 -0
  55. package/app/codeCharta/state/effects/nodeContextMenu/rightClickedCodeMapNode.selector.ts +8 -0
  56. package/app/codeCharta/state/effects/unfocusNodesOnLoadingMap.effect.spec.ts +47 -0
  57. package/app/codeCharta/state/effects/unfocusNodesOnLoadingMap.effect.ts +18 -0
  58. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/areAllNecessaryRenderDataAvailable.selector.ts +30 -0
  59. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/utils/areDynamicSettingsAvailable.spec.ts +36 -0
  60. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/utils/areDynamicSettingsAvailable.ts +10 -0
  61. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/utils/areMetricsAvailable.spec.ts +13 -0
  62. package/app/codeCharta/state/selectors/allNecessaryRenderDataAvailable/utils/areMetricsAvailable.ts +8 -0
  63. package/app/codeCharta/state/store/appSettings/appSettings.actions.ts +2 -0
  64. package/app/codeCharta/state/store/appSettings/appSettings.reducer.ts +2 -0
  65. package/app/codeCharta/state/store/appSettings/invertArea/invertArea.actions.ts +32 -0
  66. package/app/codeCharta/state/store/appSettings/invertArea/invertArea.reducer.spec.ts +26 -0
  67. package/app/codeCharta/state/store/appSettings/invertArea/invertArea.reducer.ts +12 -0
  68. package/app/codeCharta/state/store/appSettings/invertArea/invertArea.selector.ts +3 -0
  69. package/app/codeCharta/state/store/appSettings/isLoadingMap/isLoadingMap.reducer.spec.ts +14 -3
  70. package/app/codeCharta/state/store/appSettings/isLoadingMap/isLoadingMap.reducer.ts +41 -6
  71. package/app/codeCharta/state/store/appStatus/appStatus.reducer.ts +3 -1
  72. package/app/codeCharta/state/store/appStatus/appStatus.selector.ts +3 -0
  73. package/app/codeCharta/state/store/appStatus/rightClickedNodeData/rightClickedNodeData.actions.ts +23 -0
  74. package/app/codeCharta/state/store/appStatus/rightClickedNodeData/rightClickedNodeData.reducer.ts +15 -0
  75. package/app/codeCharta/state/store/appStatus/rightClickedNodeData/rightClickedNodeData.selector.ts +4 -0
  76. package/app/codeCharta/state/store/dynamicSettings/dynamicSettings.splitter.ts +2 -2
  77. package/app/codeCharta/state/store/dynamicSettings/focusedNodePath/currentFocused.selector.ts +8 -0
  78. package/app/codeCharta/state/store/dynamicSettings/focusedNodePath/focusedNodePath.actions.ts +27 -7
  79. package/app/codeCharta/state/store/dynamicSettings/focusedNodePath/focusedNodePath.reducer.spec.ts +27 -11
  80. package/app/codeCharta/state/store/dynamicSettings/focusedNodePath/focusedNodePath.reducer.ts +11 -5
  81. package/app/codeCharta/state/store/dynamicSettings/focusedNodePath/focusedNodePath.selector.ts +4 -0
  82. package/app/codeCharta/state/store/dynamicSettings/focusedNodePath/focusedNodePath.service.spec.ts +2 -2
  83. package/app/codeCharta/state/store/dynamicSettings/focusedNodePath/focusedNodePath.service.ts +1 -1
  84. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.actions.ts +33 -2
  85. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.reducer.spec.ts +17 -1
  86. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.reducer.ts +3 -1
  87. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.service.spec.ts +1 -19
  88. package/app/codeCharta/state/store/fileSettings/blacklist/blacklist.service.ts +5 -28
  89. package/app/codeCharta/state/store/fileSettings/markedPackages/markedPackages.actions.ts +9 -10
  90. package/app/codeCharta/state/store/fileSettings/markedPackages/markedPackages.reducer.spec.ts +37 -7
  91. package/app/codeCharta/state/store/fileSettings/markedPackages/markedPackages.reducer.ts +7 -3
  92. package/app/codeCharta/state/store/fileSettings/markedPackages/util/findIndexOfMarkedPackageOrParent.spec.ts +39 -0
  93. package/app/codeCharta/state/store/fileSettings/markedPackages/util/findIndexOfMarkedPackageOrParent.ts +19 -0
  94. package/app/codeCharta/state/store/lookUp/idToNode/idToNode.selector.ts +4 -0
  95. package/app/codeCharta/state/store/lookUp/lookUp.selector.ts +3 -0
  96. package/app/codeCharta/state/store/metricData/nodeMetricData/nodeMetricData.service.ts +0 -4
  97. package/app/codeCharta/state/store/state.actions.ts +3 -1
  98. package/app/codeCharta/state/store/state.splitter.spec.ts +4 -4
  99. package/app/codeCharta/state/store/store.ts +5 -1
  100. package/app/codeCharta/state/store.service.spec.ts +21 -8
  101. package/app/codeCharta/state/store.service.ts +3 -31
  102. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.component.html +3 -1
  103. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.component.scss +6 -2
  104. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.component.ts +1 -1
  105. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.module.ts +3 -0
  106. package/app/codeCharta/ui/areaSettingsPanel/areaSettingsPanel.po.ts +4 -4
  107. package/app/codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component.html +1 -0
  108. package/app/codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component.scss +26 -0
  109. package/app/codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component.spec.ts +29 -0
  110. package/app/codeCharta/ui/areaSettingsPanel/invertAreaOption/invertAreaOption.component.ts +24 -0
  111. package/app/codeCharta/ui/artificialIntelligence/__snapshots__/artificialIntelligence.component.spec.ts.snap +13 -16
  112. package/app/codeCharta/ui/artificialIntelligence/artificialIntelligence.component.html +4 -4
  113. package/app/codeCharta/ui/artificialIntelligence/artificialIntelligence.component.scss +0 -4
  114. package/app/codeCharta/ui/artificialIntelligence/artificialIntelligence.component.spec.ts +82 -52
  115. package/app/codeCharta/ui/artificialIntelligence/artificialIntelligence.component.ts +41 -101
  116. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/aggregationType.pipe.spec.ts +19 -0
  117. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/{aggregationSymbol.pipe.ts → aggregationType.pipe.ts} +4 -4
  118. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/attributeTypeSelector.component.html +4 -12
  119. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/attributeTypeSelector.component.scss +11 -20
  120. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/attributeTypeSelector.component.spec.ts +8 -15
  121. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/attributeTypeSelector.module.ts +2 -2
  122. package/app/codeCharta/ui/codeMap/__snapshots__/codeMap.arrow.service.spec.ts.snap +2 -2
  123. package/app/codeCharta/ui/codeMap/codeMap.actions.service.ts +1 -40
  124. package/app/codeCharta/ui/codeMap/codeMap.mouseEvent.service.ts +8 -16
  125. package/app/codeCharta/ui/codeMap/codeMap.preRender.service.spec.ts +1 -9
  126. package/app/codeCharta/ui/codeMap/codeMap.preRender.service.ts +9 -32
  127. package/app/codeCharta/ui/codeMap/rendering/codeMapMesh.ts +1 -0
  128. package/app/codeCharta/ui/colorPicker/colorPicker.component.html +16 -7
  129. package/app/codeCharta/ui/colorPicker/colorPicker.component.spec.ts +55 -16
  130. package/app/codeCharta/ui/colorPicker/colorPicker.component.ts +32 -1
  131. package/app/codeCharta/ui/colorPicker/colorPicker.module.ts +3 -1
  132. package/app/codeCharta/ui/customConfigs/customConfigs.component.html +29 -11
  133. package/app/codeCharta/ui/customConfigs/customConfigs.component.scss +1 -0
  134. package/app/codeCharta/ui/customConfigs/customConfigs.component.spec.ts +123 -2
  135. package/app/codeCharta/ui/customConfigs/customConfigs.component.ts +56 -2
  136. package/app/codeCharta/ui/dialog/dialog.addCustomConfigSettings.component.html +2 -2
  137. package/app/codeCharta/ui/dialog/dialog.changelog.component.html +1 -1
  138. package/app/codeCharta/ui/dialog/dialog.changelog.component.scss +15 -0
  139. package/app/codeCharta/ui/dialog/dialog.changelog.component.spec.ts +15 -15
  140. package/app/codeCharta/ui/dialog/dialog.changelog.component.ts +2 -1
  141. package/app/codeCharta/ui/dialog/dialog.globalSettings.e2e.ts +1 -1
  142. package/app/codeCharta/ui/dialog/dialog.globalSettings.po.ts +1 -1
  143. package/app/codeCharta/ui/dialog/dialog.service.spec.ts +68 -0
  144. package/app/codeCharta/ui/dialog/dialog.service.ts +38 -17
  145. package/app/codeCharta/ui/dialogs/dialogs.ts +3 -0
  146. package/app/codeCharta/ui/dialogs/errorDialog/errorDialog.component.html +7 -0
  147. package/app/codeCharta/ui/dialogs/errorDialog/errorDialog.component.ts +9 -0
  148. package/app/codeCharta/ui/edgeChooser/edgeChooser.e2e.ts +3 -2
  149. package/app/codeCharta/ui/fileChooser/fileChooser.e2e.ts +5 -6
  150. package/app/codeCharta/ui/filePanel/filePanel.component.html +24 -106
  151. package/app/codeCharta/ui/filePanel/filePanel.component.scss +12 -57
  152. package/app/codeCharta/ui/filePanel/filePanel.component.spec.ts +40 -72
  153. package/app/codeCharta/ui/filePanel/filePanel.component.ts +29 -81
  154. package/app/codeCharta/ui/filePanel/filePanel.module.ts +13 -1
  155. package/app/codeCharta/ui/filePanel/filePanel.po.ts +6 -24
  156. package/app/codeCharta/ui/filePanel/filePanelDeltaSelector/filePanelDeltaSelector.component.html +23 -0
  157. package/app/codeCharta/ui/filePanel/filePanelDeltaSelector/filePanelDeltaSelector.component.ts +18 -0
  158. package/app/codeCharta/ui/filePanel/filePanelFileSelector/filePanelFileSelector.component.html +18 -0
  159. package/app/codeCharta/ui/filePanel/filePanelFileSelector/filePanelFileSelector.component.ts +16 -0
  160. package/app/codeCharta/ui/filePanel/filePanelStateButtons/filePanelStateButtons.component.html +18 -0
  161. package/app/codeCharta/ui/filePanel/filePanelStateButtons/filePanelStateButtons.component.ts +11 -0
  162. package/app/codeCharta/ui/labelledColorPicker/labelledColorPicker.component.html +21 -13
  163. package/app/codeCharta/ui/labelledColorPicker/labelledColorPicker.component.spec.ts +11 -24
  164. package/app/codeCharta/ui/labelledColorPicker/labelledColorPicker.component.ts +1 -40
  165. package/app/codeCharta/ui/labelledColorPicker/labelledColorPicker.module.ts +1 -2
  166. package/app/codeCharta/ui/legendPanel/legendMarkedPackages/legendMarkedPackages.component.ts +2 -2
  167. package/app/codeCharta/ui/mapTreeView/mapTreeView.level.e2e.ts +8 -6
  168. package/app/codeCharta/ui/mapTreeView/mapTreeView.level.po.ts +1 -1
  169. package/app/codeCharta/ui/mapTreeView/mapTreeViewLevel/mapTreeViewLevel.component.html +1 -1
  170. package/app/codeCharta/ui/mapTreeView/mapTreeViewLevel/mapTreeViewLevel.component.spec.ts +6 -16
  171. package/app/codeCharta/ui/mapTreeView/mapTreeViewLevel/mapTreeViewLevel.component.ts +15 -11
  172. package/app/codeCharta/ui/ribbonBar/ribbonBar.component.html +3 -3
  173. package/app/codeCharta/ui/ribbonBar/ribbonBar.e2e.ts +3 -3
  174. package/app/codeCharta/ui/searchBar/searchBar.component.html +5 -0
  175. package/app/codeCharta/ui/searchBar/searchBar.component.scss +11 -0
  176. package/app/codeCharta/ui/searchBar/searchBar.component.spec.ts +10 -0
  177. package/app/codeCharta/ui/searchBar/searchBar.component.ts +1 -1
  178. package/app/codeCharta/ui/sortingOption/sortingOption.component.spec.ts +1 -1
  179. package/app/codeCharta/ui/toolBar/toolBar.component.html +1 -1
  180. package/app/codeCharta/ui/toolBar/toolBar.component.scss +1 -1
  181. package/app/codeCharta/ui/ui.ts +2 -6
  182. package/app/codeCharta/util/algorithm/streetLayout/strip/strip.ts +2 -2
  183. package/app/codeCharta/util/algorithm/streetLayout/treeMap.ts +1 -1
  184. package/app/codeCharta/util/algorithm/treeMapLayout/treeMapGenerator.spec.ts +2 -2
  185. package/app/codeCharta/util/algorithm/treeMapLayout/treeMapGenerator.ts +14 -7
  186. package/app/codeCharta/util/algorithm/treeMapLayout/treeMapHelper.spec.ts +2 -2
  187. package/app/codeCharta/util/algorithm/treeMapLayout/treeMapHelper.ts +1 -1
  188. package/app/codeCharta/util/customConfigBuilder.ts +2 -1
  189. package/app/codeCharta/util/customConfigHelper.spec.ts +155 -60
  190. package/app/codeCharta/util/customConfigHelper.ts +33 -3
  191. package/app/codeCharta/util/dataMocks.ts +8 -4
  192. package/app/codeCharta/util/fileExtensionCalculator.ts +1 -1
  193. package/app/codeCharta/util/fileValidator.spec.ts +69 -182
  194. package/app/codeCharta/util/fileValidator.ts +61 -37
  195. package/app/codeCharta/util/reduxHelper.ts +11 -0
  196. package/app/material/material.module.ts +17 -1
  197. package/conf/webpack.loaders.js +4 -1
  198. package/dist/webpack/bundle.js +5925 -1896
  199. package/dist/webpack/bundle.js.map +1 -1
  200. package/package.json +7 -6
  201. package/app/codeCharta/state/store/dynamicSettings/focusedNodePath/focusedNodePath.splitter.ts +0 -8
  202. package/app/codeCharta/ui/attributeSideBar/attributeTypeSelector/aggregationSymbol.pipe.spec.ts +0 -19
  203. package/app/codeCharta/ui/codeMap/codeMap.actions.service.spec.ts +0 -147
  204. package/app/codeCharta/ui/nodeContextMenu/markFolderColorPicker/markFolderColorPicker.component.html +0 -5
  205. package/app/codeCharta/ui/nodeContextMenu/markFolderColorPicker/markFolderColorPicker.component.scss +0 -13
  206. package/app/codeCharta/ui/nodeContextMenu/markFolderColorPicker/markFolderColorPicker.component.ts +0 -30
  207. package/app/codeCharta/ui/nodeContextMenu/markFolderColorPicker/markFolderColorPicker.module.ts +0 -13
  208. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.component.html +0 -68
  209. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.component.scss +0 -52
  210. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.component.spec.ts +0 -571
  211. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.component.ts +0 -318
  212. package/app/codeCharta/ui/nodeContextMenu/nodeContextMenu.module.ts +0 -13
  213. package/app/codeCharta/ui/unfocusButton/unfocusButton.component.html +0 -15
  214. package/app/codeCharta/ui/unfocusButton/unfocusButton.component.scss +0 -5
  215. package/app/codeCharta/ui/unfocusButton/unfocusButton.component.spec.ts +0 -106
  216. package/app/codeCharta/ui/unfocusButton/unfocusButton.component.ts +0 -62
  217. package/app/codeCharta/ui/unfocusButton/unfocusButton.module.ts +0 -7
@@ -0,0 +1,24 @@
1
+ import "./invertAreaOption.component.scss"
2
+ import { Component, Inject, OnInit } from "@angular/core"
3
+ import { Store } from "../../../state/angular-redux/store"
4
+ import { invertAreaSelector } from "../../../state/store/appSettings/invertArea/invertArea.selector"
5
+ import { Observable } from "rxjs"
6
+ import { toggleInvertingArea } from "../../../state/store/appSettings/invertArea/invertArea.actions"
7
+
8
+ @Component({
9
+ selector: "cc-invert-area-option",
10
+ template: require("./invertAreaOption.component.html")
11
+ })
12
+ export class InvertAreaOptionComponent implements OnInit {
13
+ isInvertedArea$: Observable<boolean>
14
+
15
+ constructor(@Inject(Store) private store: Store) {}
16
+
17
+ ngOnInit(): void {
18
+ this.isInvertedArea$ = this.store.select(invertAreaSelector)
19
+ }
20
+
21
+ toggleInvertingArea() {
22
+ this.store.dispatch(toggleInvertingArea())
23
+ }
24
+ }
@@ -9,38 +9,26 @@ Object {
9
9
  }
10
10
  `;
11
11
 
12
- exports[`ArtificialIntelligenceController on files selection changed should clear and calculate risk profile for Java map 1`] = `
13
- Object {
14
- "highRisk": 37,
15
- "lowRisk": 46,
16
- "moderateRisk": 17,
17
- "veryHighRisk": 0,
18
- }
19
- `;
20
-
21
- exports[`ArtificialIntelligenceController on files selection changed should create custom config suggestions sorted by outlierCustomConfigId 1`] = `
12
+ exports[`ArtificialIntelligenceController on files selection changed should calculate suspicious metrics sorted by isOutlier 1`] = `
22
13
  Array [
23
14
  Object {
24
15
  "from": 365,
25
- "generalCustomConfigId": "mocked",
16
+ "isOutlier": true,
26
17
  "max": 0,
27
18
  "metric": "loc",
28
19
  "min": 0,
29
- "outlierCustomConfigId": "mocked",
30
20
  "to": 554,
31
21
  },
32
22
  Object {
33
23
  "from": 29,
34
- "generalCustomConfigId": "mocked",
24
+ "isOutlier": true,
35
25
  "max": 0,
36
26
  "metric": "functions",
37
27
  "min": 0,
38
- "outlierCustomConfigId": "mocked",
39
28
  "to": 44,
40
29
  },
41
30
  Object {
42
31
  "from": 48,
43
- "generalCustomConfigId": "mocked",
44
32
  "max": 0,
45
33
  "metric": "mcc",
46
34
  "min": 0,
@@ -49,8 +37,17 @@ Array [
49
37
  ]
50
38
  `;
51
39
 
52
- exports[`ArtificialIntelligenceController on files selection changed should create custom config suggestions sorted by outlierCustomConfigId 2`] = `
40
+ exports[`ArtificialIntelligenceController on files selection changed should calculate suspicious metrics sorted by isOutlier 2`] = `
53
41
  Array [
54
42
  "rloc (real lines of code)",
55
43
  ]
56
44
  `;
45
+
46
+ exports[`ArtificialIntelligenceController on files selection changed should clear and calculate risk profile for Java map 1`] = `
47
+ Object {
48
+ "highRisk": 37,
49
+ "lowRisk": 46,
50
+ "moderateRisk": 17,
51
+ "veryHighRisk": 0,
52
+ }
53
+ `;
@@ -43,8 +43,8 @@
43
43
  <ul class="suspicious-metrics">
44
44
  <li class="suspicious-metric" ng-repeat="item in $ctrl._viewModel.suspiciousMetricSuggestionLinks">
45
45
  <md-button
46
- class="metric-button {{ item.outlierCustomConfigId.length > 0 ? 'high-risk' : '' }}"
47
- ng-click="$ctrl.applyCustomConfig(item.generalCustomConfigId)"
46
+ class="metric-button"
47
+ ng-click="$ctrl.applySuspiciousMetric(item, false)"
48
48
  title="Apply Map Configuration to show files with suspicious metric {{
49
49
  item.metric
50
50
  }} and high risk or very high risk depending on selection"
@@ -54,8 +54,8 @@
54
54
 
55
55
  <md-button
56
56
  class="risk-button"
57
- ng-click="$ctrl.applyCustomConfig(item.outlierCustomConfigId)"
58
- ng-show="item.outlierCustomConfigId.length > 0"
57
+ ng-click="$ctrl.applySuspiciousMetric(item, true)"
58
+ ng-show="item.isOutlier"
59
59
  title="Show very high risk files"
60
60
  >
61
61
  <i class="fa fa-exclamation-triangle"></i>
@@ -68,10 +68,6 @@
68
68
  padding: 0 12px;
69
69
  text-transform: none;
70
70
  margin: 0;
71
-
72
- &.high-risk {
73
- border-radius: 5px 0 0 5px;
74
- }
75
71
  }
76
72
 
77
73
  .risk-button {
@@ -2,27 +2,26 @@ import "./artificialIntelligence.module"
2
2
  import { instantiateModule, getService } from "../../../../mocks/ng.mockhelper"
3
3
  import { IRootScopeService } from "angular"
4
4
  import { StoreService } from "../../state/store.service"
5
- import { ThreeOrbitControlsService } from "../codeMap/threeViewer/threeOrbitControlsService"
6
- import { ThreeCameraService } from "../codeMap/threeViewer/threeCameraService"
7
5
  import { ArtificialIntelligenceController } from "./artificialIntelligence.component"
8
6
  import { FilesService } from "../../state/store/files/files.service"
9
- import { CustomConfig } from "../../model/customConfig/customConfig.api.model"
10
- import { CustomConfigHelper } from "../../util/customConfigHelper"
11
7
  import { setFiles } from "../../state/store/files/files.actions"
12
- import { FILE_STATES, FILE_STATES_JAVA, FILE_STATES_UNSELECTED } from "../../util/dataMocks"
13
- import { setState } from "../../state/store/state.actions"
8
+ import { FILE_STATES, FILE_STATES_JAVA, FILE_STATES_UNSELECTED, STATE } from "../../util/dataMocks"
14
9
  import { klona } from "klona"
15
- import { BlacklistType } from "../../codeCharta.model"
10
+ import { BlacklistType, ColorRange } from "../../codeCharta.model"
16
11
  import { BlacklistService } from "../../state/store/fileSettings/blacklist/blacklist.service"
17
12
  import { ExperimentalFeaturesEnabledService } from "../../state/store/appSettings/enableExperimentalFeatures/experimentalFeaturesEnabled.service"
18
13
  import { setExperimentalFeaturesEnabled } from "../../state/store/appSettings/enableExperimentalFeatures/experimentalFeaturesEnabled.actions"
14
+ import { setColorRange } from "../../state/store/dynamicSettings/colorRange/colorRange.actions"
15
+ import { setColorMetric } from "../../state/store/dynamicSettings/colorMetric/colorMetric.actions"
16
+ import { setHeightMetric } from "../../state/store/dynamicSettings/heightMetric/heightMetric.actions"
17
+ import { setAreaMetric } from "../../state/store/dynamicSettings/areaMetric/areaMetric.actions"
18
+ import { setMapColors } from "../../state/store/appSettings/mapColors/mapColors.actions"
19
+ import { setState } from "../../state/store/state.actions"
19
20
 
20
21
  describe("ArtificialIntelligenceController", () => {
21
22
  let artificialIntelligenceController: ArtificialIntelligenceController
22
23
  let $rootScope: IRootScopeService
23
24
  let storeService: StoreService
24
- let threeOrbitControlsService: ThreeOrbitControlsService
25
- let threeCameraService: ThreeCameraService
26
25
 
27
26
  beforeEach(() => {
28
27
  restartSystem()
@@ -34,19 +33,12 @@ describe("ArtificialIntelligenceController", () => {
34
33
 
35
34
  $rootScope = getService<IRootScopeService>("$rootScope")
36
35
  storeService = getService<StoreService>("storeService")
37
- threeOrbitControlsService = getService<ThreeOrbitControlsService>("storeService")
38
- threeCameraService = getService<ThreeCameraService>("storeService")
39
36
 
40
37
  storeService.dispatch(setFiles(FILE_STATES))
41
38
  }
42
39
 
43
40
  function rebuildController() {
44
- artificialIntelligenceController = new ArtificialIntelligenceController(
45
- $rootScope,
46
- storeService,
47
- threeOrbitControlsService,
48
- threeCameraService
49
- )
41
+ artificialIntelligenceController = new ArtificialIntelligenceController($rootScope, storeService)
50
42
 
51
43
  // Overwrite debounce with original function, otherwise calculate() will not be called
52
44
  artificialIntelligenceController["debounceCalculation"] = artificialIntelligenceController["calculate"]
@@ -83,7 +75,7 @@ describe("ArtificialIntelligenceController", () => {
83
75
  artificialIntelligenceController["getMostFrequentLanguage"] = jest.fn()
84
76
  artificialIntelligenceController["clearRiskProfile"] = jest.fn()
85
77
  artificialIntelligenceController["calculateRiskProfile"] = jest.fn()
86
- artificialIntelligenceController["createCustomConfigSuggestions"] = jest.fn()
78
+ artificialIntelligenceController["calculateSuspiciousMetrics"] = jest.fn()
87
79
  artificialIntelligenceController["fileState"] = FILE_STATES_JAVA[0]
88
80
 
89
81
  storeService.dispatch(setExperimentalFeaturesEnabled(false))
@@ -92,14 +84,14 @@ describe("ArtificialIntelligenceController", () => {
92
84
  expect(artificialIntelligenceController["getMostFrequentLanguage"]).not.toHaveBeenCalled()
93
85
  expect(artificialIntelligenceController["clearRiskProfile"]).not.toHaveBeenCalled()
94
86
  expect(artificialIntelligenceController["calculateRiskProfile"]).not.toHaveBeenCalled()
95
- expect(artificialIntelligenceController["createCustomConfigSuggestions"]).not.toHaveBeenCalled()
87
+ expect(artificialIntelligenceController["calculateSuspiciousMetrics"]).not.toHaveBeenCalled()
96
88
  })
97
89
 
98
90
  it("should calculate suspicious metrics when experimental features are enabled", function () {
99
91
  artificialIntelligenceController["getMostFrequentLanguage"] = jest.fn().mockReturnValue("java")
100
92
  artificialIntelligenceController["clearRiskProfile"] = jest.fn()
101
93
  artificialIntelligenceController["calculateRiskProfile"] = jest.fn()
102
- artificialIntelligenceController["createCustomConfigSuggestions"] = jest.fn()
94
+ artificialIntelligenceController["calculateSuspiciousMetrics"] = jest.fn()
103
95
  artificialIntelligenceController["fileState"] = FILE_STATES_JAVA[0]
104
96
 
105
97
  storeService.dispatch(setExperimentalFeaturesEnabled(true))
@@ -109,28 +101,72 @@ describe("ArtificialIntelligenceController", () => {
109
101
  expect(artificialIntelligenceController["_viewModel"].analyzedProgrammingLanguage).toBe("java")
110
102
  expect(artificialIntelligenceController["clearRiskProfile"]).toHaveBeenCalled()
111
103
  expect(artificialIntelligenceController["calculateRiskProfile"]).toHaveBeenCalled()
112
- expect(artificialIntelligenceController["createCustomConfigSuggestions"]).toHaveBeenCalled()
104
+ expect(artificialIntelligenceController["calculateSuspiciousMetrics"]).toHaveBeenCalled()
113
105
  })
114
106
  })
115
107
 
116
- describe("apply custom Config", () => {
117
- it("should call store.dispatch", () => {
118
- const customConfigStub = {
119
- stateSettings: {
120
- dynamicSettings: {
121
- margin: 1,
122
- colorRange: { from: 1, to: 2 }
123
- }
124
- }
125
- } as CustomConfig
108
+ describe("apply suspicious metric", () => {
109
+ it("should call store.dispatch with all needed states for desired suspicious metric view", () => {
110
+ storeService.dispatch(setState(STATE))
111
+ const testMetricSuggestionParameters = {
112
+ metric: "loc",
113
+ from: 365,
114
+ to: 554,
115
+ max: 0,
116
+ min: 0,
117
+ isOutlier: undefined
118
+ }
119
+
120
+ const colorRange: ColorRange = {
121
+ from: testMetricSuggestionParameters.from,
122
+ to: testMetricSuggestionParameters.to,
123
+ max: 0,
124
+ min: 0
125
+ }
126
126
 
127
- CustomConfigHelper.getCustomConfigSettings = jest.fn().mockReturnValue(customConfigStub)
127
+ artificialIntelligenceController["_viewModel"].suspiciousMetricSuggestionLinks = [testMetricSuggestionParameters]
128
128
  storeService.dispatch = jest.fn()
129
- threeOrbitControlsService.setControlTarget = jest.fn()
129
+ artificialIntelligenceController.applySuspiciousMetric(testMetricSuggestionParameters, false)
130
130
 
131
- artificialIntelligenceController.applyCustomConfig("CustomConfig1")
131
+ expect(storeService.dispatch).toHaveBeenCalledWith(setAreaMetric("rloc"))
132
+ expect(storeService.dispatch).toHaveBeenCalledWith(setHeightMetric("loc"))
133
+ expect(storeService.dispatch).toHaveBeenCalledWith(setColorMetric("loc"))
134
+ expect(storeService.dispatch).toHaveBeenCalledWith(setColorRange(colorRange))
135
+ expect(storeService.dispatch).toHaveBeenCalledWith(setMapColors(STATE.appSettings.mapColors))
136
+ })
132
137
 
133
- expect(storeService.dispatch).toHaveBeenCalledWith(setState(customConfigStub.stateSettings))
138
+ it("should call store.dispatch with all needed states for desired very high risk metric view", () => {
139
+ storeService.dispatch(setState(STATE))
140
+ const mapColors = { ...STATE.appSettings.mapColors }
141
+ mapColors.positive = "#ffffff"
142
+ mapColors.neutral = "#ffffff"
143
+ mapColors.negative = "#A900C0"
144
+
145
+ const testMetricSuggestionParameters = {
146
+ metric: "loc",
147
+ from: 365,
148
+ to: 554,
149
+ max: 0,
150
+ min: 0,
151
+ isOutlier: true
152
+ }
153
+
154
+ const colorRange: ColorRange = {
155
+ from: testMetricSuggestionParameters.from,
156
+ to: testMetricSuggestionParameters.to,
157
+ max: 0,
158
+ min: 0
159
+ }
160
+
161
+ artificialIntelligenceController["_viewModel"].suspiciousMetricSuggestionLinks = [testMetricSuggestionParameters]
162
+ storeService.dispatch = jest.fn()
163
+ artificialIntelligenceController.applySuspiciousMetric(testMetricSuggestionParameters, true)
164
+
165
+ expect(storeService.dispatch).toHaveBeenCalledWith(setAreaMetric("rloc"))
166
+ expect(storeService.dispatch).toHaveBeenCalledWith(setHeightMetric("loc"))
167
+ expect(storeService.dispatch).toHaveBeenCalledWith(setColorMetric("loc"))
168
+ expect(storeService.dispatch).toHaveBeenCalledWith(setColorRange(colorRange))
169
+ expect(storeService.dispatch).toHaveBeenCalledWith(setMapColors(mapColors))
134
170
  })
135
171
  })
136
172
 
@@ -141,7 +177,7 @@ describe("ArtificialIntelligenceController", () => {
141
177
  expect(artificialIntelligenceController["getMostFrequentLanguage"]).not.toHaveBeenCalled()
142
178
  })
143
179
 
144
- it("should not calculate risk profile and suggest custom configs on empty main programming language", () => {
180
+ it("should not calculate risk profile and suspicious metrics on empty main programming language", () => {
145
181
  artificialIntelligenceController["clearRiskProfile"] = jest.fn()
146
182
  artificialIntelligenceController["calculateRiskProfile"] = jest.fn()
147
183
  artificialIntelligenceController["createCustomConfigSuggestions"] = jest.fn()
@@ -155,7 +191,7 @@ describe("ArtificialIntelligenceController", () => {
155
191
 
156
192
  it("should clear and calculate risk profile for Java map", () => {
157
193
  artificialIntelligenceController["clearRiskProfile"] = jest.fn()
158
- artificialIntelligenceController["createCustomConfigSuggestions"] = jest.fn()
194
+ artificialIntelligenceController["calculateSuspiciousMetrics"] = jest.fn()
159
195
 
160
196
  storeService.dispatch(setExperimentalFeaturesEnabled(true))
161
197
  artificialIntelligenceController.onFilesSelectionChanged(FILE_STATES_JAVA)
@@ -163,7 +199,7 @@ describe("ArtificialIntelligenceController", () => {
163
199
  expect(artificialIntelligenceController["_viewModel"].analyzedProgrammingLanguage).toBe("java")
164
200
  expect(artificialIntelligenceController["clearRiskProfile"]).toHaveBeenCalled()
165
201
  expect(artificialIntelligenceController["_viewModel"].riskProfile).toMatchSnapshot()
166
- expect(artificialIntelligenceController["createCustomConfigSuggestions"]).toHaveBeenCalled()
202
+ expect(artificialIntelligenceController["calculateSuspiciousMetrics"]).toHaveBeenCalled()
167
203
  })
168
204
 
169
205
  it("should calculate risk profile and should not exceed 100 percent", () => {
@@ -182,7 +218,7 @@ describe("ArtificialIntelligenceController", () => {
182
218
  expect(sumOfRiskPercentage).toEqual(100)
183
219
  })
184
220
 
185
- it("should create custom config suggestions sorted by outlierCustomConfigId", () => {
221
+ it("should calculate suspicious metrics sorted by isOutlier", () => {
186
222
  artificialIntelligenceController["clearRiskProfile"] = jest.fn()
187
223
  artificialIntelligenceController["calculateRiskProfile"] = jest.fn()
188
224
 
@@ -193,18 +229,12 @@ describe("ArtificialIntelligenceController", () => {
193
229
  expect(artificialIntelligenceController["clearRiskProfile"]).toHaveBeenCalled()
194
230
  expect(artificialIntelligenceController["calculateRiskProfile"]).toHaveBeenCalled()
195
231
 
196
- artificialIntelligenceController["_viewModel"].suspiciousMetricSuggestionLinks[0].generalCustomConfigId = "mocked"
197
- artificialIntelligenceController["_viewModel"].suspiciousMetricSuggestionLinks[0].outlierCustomConfigId = "mocked"
198
- artificialIntelligenceController["_viewModel"].suspiciousMetricSuggestionLinks[1].generalCustomConfigId = "mocked"
199
- artificialIntelligenceController["_viewModel"].suspiciousMetricSuggestionLinks[1].outlierCustomConfigId = "mocked"
200
- artificialIntelligenceController["_viewModel"].suspiciousMetricSuggestionLinks[2].generalCustomConfigId = "mocked"
201
-
202
232
  expect(artificialIntelligenceController["_viewModel"].suspiciousMetricSuggestionLinks).toMatchSnapshot()
203
233
  expect(artificialIntelligenceController["_viewModel"].unsuspiciousMetrics).toMatchSnapshot()
204
234
  })
205
235
 
206
236
  it("should calculate risk profile for not excluded files only", () => {
207
- artificialIntelligenceController["createCustomConfigSuggestions"] = jest.fn()
237
+ artificialIntelligenceController["calculateSuspiciousMetrics"] = jest.fn()
208
238
 
209
239
  const codeMapNodeToExclude = FILE_STATES_JAVA[0].file.map.children[0].children[0]
210
240
 
@@ -220,11 +250,11 @@ describe("ArtificialIntelligenceController", () => {
220
250
 
221
251
  expect(artificialIntelligenceController["_viewModel"].analyzedProgrammingLanguage).toBe("java")
222
252
  expect(artificialIntelligenceController["_viewModel"].riskProfile).toMatchSnapshot()
223
- expect(artificialIntelligenceController["createCustomConfigSuggestions"]).toHaveBeenCalled()
253
+ expect(artificialIntelligenceController["calculateSuspiciousMetrics"]).toHaveBeenCalled()
224
254
  })
225
255
 
226
256
  it("should calculate risk profile but skip files with missing metrics", () => {
227
- artificialIntelligenceController["createCustomConfigSuggestions"] = jest.fn()
257
+ artificialIntelligenceController["calculateSuspiciousMetrics"] = jest.fn()
228
258
 
229
259
  const FILE_STATES_MISSING_METRICS = klona(FILE_STATES_JAVA)
230
260
  for (const codeMapNode of FILE_STATES_MISSING_METRICS[0].file.map.children) {
@@ -238,12 +268,12 @@ describe("ArtificialIntelligenceController", () => {
238
268
 
239
269
  expect(artificialIntelligenceController["_viewModel"].analyzedProgrammingLanguage).toBe("java")
240
270
  expect(artificialIntelligenceController["_viewModel"].riskProfile).toBeUndefined()
241
- expect(artificialIntelligenceController["createCustomConfigSuggestions"]).toHaveBeenCalled()
271
+ expect(artificialIntelligenceController["calculateSuspiciousMetrics"]).toHaveBeenCalled()
242
272
  })
243
273
 
244
- it("should calculate risk profile and add custom configs for maps with other programming languages", () => {
274
+ it("should calculate risk profile and suspicious metrics for maps with other programming languages", () => {
245
275
  artificialIntelligenceController["calculateRiskProfile"] = jest.fn()
246
- artificialIntelligenceController["createCustomConfigSuggestions"] = jest.fn()
276
+ artificialIntelligenceController["calculateSuspiciousMetrics"] = jest.fn()
247
277
 
248
278
  const FILE_STATES_OTHER = klona(FILE_STATES_JAVA)
249
279
  for (const codeMapNode of FILE_STATES_OTHER[0].file.map.children) {
@@ -257,7 +287,7 @@ describe("ArtificialIntelligenceController", () => {
257
287
 
258
288
  expect(artificialIntelligenceController["_viewModel"].analyzedProgrammingLanguage).toBe("other")
259
289
  expect(artificialIntelligenceController["calculateRiskProfile"]).toHaveBeenCalled()
260
- expect(artificialIntelligenceController["createCustomConfigSuggestions"]).toHaveBeenCalled()
290
+ expect(artificialIntelligenceController["calculateSuspiciousMetrics"]).toHaveBeenCalled()
261
291
  })
262
292
  })
263
293
 
@@ -3,19 +3,13 @@ import debounce from "lodash.debounce"
3
3
  import { FilesSelectionSubscriber, FilesService } from "../../state/store/files/files.service"
4
4
  import { FileState } from "../../model/files/files"
5
5
  import { IRootScopeService } from "angular"
6
- import { buildCustomConfigFromState } from "../../util/customConfigBuilder"
7
- import { CustomConfigHelper } from "../../util/customConfigHelper"
8
6
  import { StoreService } from "../../state/store.service"
9
- import { klona } from "klona"
10
- import { CustomConfig, CustomConfigMapSelectionMode } from "../../model/customConfig/customConfig.api.model"
11
7
  import { pushSorted } from "../../util/nodeDecorator"
12
- import { BlacklistItem, BlacklistType, CodeMapNode, ColorRange, NodeType, State } from "../../codeCharta.model"
8
+ import { BlacklistItem, BlacklistType, CodeMapNode, ColorRange, NodeType } from "../../codeCharta.model"
13
9
  import { hierarchy } from "d3-hierarchy"
14
10
  import { getVisibleFileStates } from "../../model/files/files.helper"
15
11
  import { metricThresholds } from "./artificialIntelligence.metricThresholds"
16
- import { defaultMapColors } from "../../state/store/appSettings/mapColors/mapColors.actions"
17
- import { ThreeOrbitControlsService } from "../codeMap/threeViewer/threeOrbitControlsService"
18
- import { ThreeCameraService } from "../codeMap/threeViewer/threeCameraService"
12
+ import { defaultMapColors, setMapColors } from "../../state/store/appSettings/mapColors/mapColors.actions"
19
13
  import { BlacklistService, BlacklistSubscriber } from "../../state/store/fileSettings/blacklist/blacklist.service"
20
14
  import { isPathBlacklisted } from "../../util/codeMapHelper"
21
15
  import {
@@ -24,6 +18,10 @@ import {
24
18
  } from "../../state/store/appSettings/enableExperimentalFeatures/experimentalFeaturesEnabled.service"
25
19
  import { metricDescriptions } from "../../util/metric/metricDescriptions"
26
20
  import percentRound from "percent-round"
21
+ import { setColorRange } from "../../state/store/dynamicSettings/colorRange/colorRange.actions"
22
+ import { setHeightMetric } from "../../state/store/dynamicSettings/heightMetric/heightMetric.actions"
23
+ import { setColorMetric } from "../../state/store/dynamicSettings/colorMetric/colorMetric.actions"
24
+ import { setAreaMetric } from "../../state/store/dynamicSettings/areaMetric/areaMetric.actions"
27
25
 
28
26
  interface MetricValues {
29
27
  [metric: string]: number[]
@@ -39,8 +37,7 @@ interface MetricSuggestionParameters {
39
37
  metric: string
40
38
  from: number
41
39
  to: number
42
- generalCustomConfigId: string
43
- outlierCustomConfigId?: string
40
+ isOutlier?: boolean
44
41
  }
45
42
 
46
43
  export class ArtificialIntelligenceController
@@ -56,7 +53,6 @@ export class ArtificialIntelligenceController
56
53
  highRisk: number
57
54
  veryHighRisk: number
58
55
  }
59
- isHighRiskFilesModeEnabled: boolean
60
56
  } = {
61
57
  analyzedProgrammingLanguage: undefined,
62
58
  suspiciousMetricSuggestionLinks: [],
@@ -66,20 +62,14 @@ export class ArtificialIntelligenceController
66
62
  moderateRisk: 0,
67
63
  highRisk: 0,
68
64
  veryHighRisk: 0
69
- },
70
- isHighRiskFilesModeEnabled: false
65
+ }
71
66
  }
72
67
 
73
68
  private debounceCalculation: () => void
74
69
  private fileState: FileState
75
70
  private blacklist: BlacklistItem[] = []
76
71
 
77
- constructor(
78
- private $rootScope: IRootScopeService,
79
- private storeService: StoreService,
80
- private threeOrbitControlsService: ThreeOrbitControlsService,
81
- private threeCameraService: ThreeCameraService
82
- ) {
72
+ constructor(private $rootScope: IRootScopeService, private storeService: StoreService) {
83
73
  "ngInject"
84
74
  FilesService.subscribe(this.$rootScope, this)
85
75
  BlacklistService.subscribe(this.$rootScope, this)
@@ -96,8 +86,32 @@ export class ArtificialIntelligenceController
96
86
  }
97
87
  }
98
88
 
99
- applyCustomConfig(configId: string) {
100
- CustomConfigHelper.applyCustomConfig(configId, this.storeService, this.threeCameraService, this.threeOrbitControlsService)
89
+ applySuspiciousMetric(metric: MetricSuggestionParameters, isOutlier: boolean) {
90
+ if (this._viewModel.suspiciousMetricSuggestionLinks.includes(metric)) {
91
+ const mapColors = { ...this.storeService.getState().appSettings.mapColors }
92
+ const colorRange: ColorRange = {
93
+ from: metric.from,
94
+ to: metric.to,
95
+ max: 0,
96
+ min: 0
97
+ }
98
+
99
+ if (metric.isOutlier === isOutlier) {
100
+ mapColors.positive = "#ffffff"
101
+ mapColors.neutral = "#ffffff"
102
+ mapColors.negative = "#A900C0"
103
+ } else {
104
+ mapColors.positive = defaultMapColors.positive
105
+ mapColors.neutral = defaultMapColors.neutral
106
+ mapColors.negative = defaultMapColors.negative
107
+ }
108
+
109
+ this.storeService.dispatch(setAreaMetric("rloc"))
110
+ this.storeService.dispatch(setHeightMetric(metric.metric))
111
+ this.storeService.dispatch(setColorMetric(metric.metric))
112
+ this.storeService.dispatch(setColorRange(colorRange))
113
+ this.storeService.dispatch(setMapColors(mapColors))
114
+ }
101
115
  }
102
116
 
103
117
  onBlacklistChanged(blacklist: BlacklistItem[]) {
@@ -132,7 +146,7 @@ export class ArtificialIntelligenceController
132
146
 
133
147
  if (mainProgrammingLanguage !== undefined) {
134
148
  this.calculateRiskProfile(this.fileState, mainProgrammingLanguage, "mcc")
135
- this.createCustomConfigSuggestions(this.fileState, mainProgrammingLanguage)
149
+ this.calculateSuspiciousMetrics(this.fileState, mainProgrammingLanguage)
136
150
  }
137
151
  }
138
152
 
@@ -198,43 +212,23 @@ export class ArtificialIntelligenceController
198
212
  }
199
213
  }
200
214
 
201
- private createCustomConfigSuggestions(fileState: FileState, programmingLanguage) {
215
+ private calculateSuspiciousMetrics(fileState: FileState, programmingLanguage) {
202
216
  const metricValues = this.getSortedMetricValues(fileState, programmingLanguage)
203
217
  const metricAssessmentResults = this.findGoodAndBadMetrics(metricValues, programmingLanguage)
204
-
205
218
  const noticeableMetricSuggestionLinks = new Map<string, MetricSuggestionParameters>()
206
- const newCustomConfigs: CustomConfig[] = []
207
219
 
208
220
  for (const [metricName, colorRange] of metricAssessmentResults.suspiciousMetrics) {
209
- const suspiciousMetricConfig = this.createOrUpdateCustomConfig(
210
- `Suspicious Files - Metric ${metricName.toUpperCase()} - (AI)`,
211
- this.prepareOverviewConfigState(metricName, colorRange.from, colorRange.to),
212
- fileState
213
- )
214
-
215
- newCustomConfigs.push(suspiciousMetricConfig)
216
-
217
221
  noticeableMetricSuggestionLinks.set(metricName, {
218
222
  metric: metricName,
219
- ...colorRange,
220
- generalCustomConfigId: suspiciousMetricConfig.id
223
+ ...colorRange
221
224
  })
222
225
 
223
226
  const outlierThreshold = metricAssessmentResults.outliersThresholds.get(metricName)
224
227
  if (outlierThreshold > 0) {
225
- const highRiskMetricConfig = this.createOrUpdateCustomConfig(
226
- `Very High Risk Files - Metric ${metricName.toUpperCase()} - (AI)`,
227
- this.prepareOutlierConfigState(metricName, outlierThreshold - 1, outlierThreshold),
228
- fileState
229
- )
230
-
231
- newCustomConfigs.push(highRiskMetricConfig)
232
-
233
- noticeableMetricSuggestionLinks.get(metricName).outlierCustomConfigId = highRiskMetricConfig.id
228
+ noticeableMetricSuggestionLinks.get(metricName).isOutlier = true
234
229
  }
235
230
  }
236
231
 
237
- CustomConfigHelper.addCustomConfigs(newCustomConfigs)
238
232
  this._viewModel.suspiciousMetricSuggestionLinks = [...noticeableMetricSuggestionLinks.values()].sort(
239
233
  this.compareSuspiciousMetricSuggestionLinks
240
234
  )
@@ -242,8 +236,8 @@ export class ArtificialIntelligenceController
242
236
  }
243
237
 
244
238
  private compareSuspiciousMetricSuggestionLinks(a: MetricSuggestionParameters, b: MetricSuggestionParameters): number {
245
- if (a.outlierCustomConfigId && !b.outlierCustomConfigId) return -1
246
- if (!a.outlierCustomConfigId && b.outlierCustomConfigId) return 1
239
+ if (a.isOutlier && !b.isOutlier) return -1
240
+ if (!a.isOutlier && b.isOutlier) return 1
247
241
  return 0
248
242
  }
249
243
 
@@ -284,60 +278,6 @@ export class ArtificialIntelligenceController
284
278
  return metricAssessmentResults
285
279
  }
286
280
 
287
- private createOrUpdateCustomConfig(configName: string, state: State, fileState: FileState) {
288
- const customConfig = CustomConfigHelper.getCustomConfigByName(
289
- CustomConfigMapSelectionMode.SINGLE,
290
- [fileState.file.fileMeta.fileName],
291
- configName
292
- )
293
-
294
- // If it exists, create a fresh one with current thresholds
295
- if (customConfig !== null) {
296
- CustomConfigHelper.deleteCustomConfig(customConfig.id)
297
- }
298
-
299
- return buildCustomConfigFromState(configName, state)
300
- }
301
-
302
- private prepareOverviewConfigState(metricName: string, colorRangeFrom: number, colorRangeTo: number) {
303
- const state = klona(this.storeService.getState())
304
-
305
- // Just use rloc as area metric
306
- state.dynamicSettings.areaMetric = "rloc"
307
-
308
- // Use bad metric as height and color metric
309
- state.dynamicSettings.heightMetric = metricName
310
- state.dynamicSettings.colorMetric = metricName
311
- state.dynamicSettings.colorRange.from = colorRangeFrom
312
- state.dynamicSettings.colorRange.to = colorRangeTo
313
-
314
- state.appSettings.mapColors.positive = defaultMapColors.positive
315
- state.appSettings.mapColors.neutral = defaultMapColors.neutral
316
- state.appSettings.mapColors.negative = defaultMapColors.negative
317
-
318
- return state
319
- }
320
-
321
- private prepareOutlierConfigState(metricName: string, colorRangeFrom: number, colorRangeTo: number) {
322
- const state = klona(this.storeService.getState())
323
-
324
- // just use rloc as area metric
325
- state.dynamicSettings.areaMetric = "rloc"
326
-
327
- // use bad metric as height and color metric
328
- state.dynamicSettings.heightMetric = metricName
329
- state.dynamicSettings.colorMetric = metricName
330
-
331
- state.dynamicSettings.colorRange.to = colorRangeTo
332
- state.dynamicSettings.colorRange.from = colorRangeFrom
333
-
334
- state.appSettings.mapColors.positive = "#ffffff"
335
- state.appSettings.mapColors.neutral = "#ffffff"
336
- state.appSettings.mapColors.negative = "#A900C0"
337
-
338
- return state
339
- }
340
-
341
281
  private getSortedMetricValues(fileState: FileState, programmingLanguage): MetricValues {
342
282
  const metricValues: MetricValues = {}
343
283
 
@@ -0,0 +1,19 @@
1
+ import { AttributeTypeValue } from "../../../codeCharta.model"
2
+ import { AggregationTypePipePipe } from "./aggregationType.pipe"
3
+
4
+ describe("aggregationSymbolPipe", () => {
5
+ it("should map `AttributeTypeValue.relative` to median", () => {
6
+ const getAttributeTypeOfNodesByMetricSelector = () => AttributeTypeValue.relative
7
+ expect(new AggregationTypePipePipe().transform("some-metric-name", getAttributeTypeOfNodesByMetricSelector)).toBe("median")
8
+ })
9
+
10
+ it("should map `AttributeTypeValue.absolute` to sum", () => {
11
+ const getAttributeTypeOfNodesByMetricSelector = () => AttributeTypeValue.absolute
12
+ expect(new AggregationTypePipePipe().transform("some-metric-name", getAttributeTypeOfNodesByMetricSelector)).toBe("sum")
13
+ })
14
+
15
+ it("should default to sum", () => {
16
+ const getAttributeTypeOfNodesByMetricSelector = () => "" as AttributeTypeValue
17
+ expect(new AggregationTypePipePipe().transform("some-metric-name", getAttributeTypeOfNodesByMetricSelector)).toBe("sum")
18
+ })
19
+ })
@@ -3,16 +3,16 @@ import { Pipe, PipeTransform } from "@angular/core"
3
3
  import { AttributeTypeValue } from "../../../codeCharta.model"
4
4
  import { GetAttributeTypeOfNodesByMetric } from "../../../state/selectors/getAttributeTypeOfNodesByMetric.selector"
5
5
 
6
- @Pipe({ name: "aggregationSymbolPipe" })
7
- export class AggregationSymbolPipe implements PipeTransform {
6
+ @Pipe({ name: "aggregationTypePipe" })
7
+ export class AggregationTypePipePipe implements PipeTransform {
8
8
  transform(metricName: string, getAttributeTypeOfNodesByMetricSelector: GetAttributeTypeOfNodesByMetric): string {
9
9
  const type = getAttributeTypeOfNodesByMetricSelector(metricName)
10
10
  switch (type) {
11
11
  case AttributeTypeValue.relative:
12
- return "x͂"
12
+ return "median"
13
13
  case AttributeTypeValue.absolute:
14
14
  default:
15
- return "Σ"
15
+ return "sum"
16
16
  }
17
17
  }
18
18
  }