Skip to content

Commit bb76dc1

Browse files
Merge pull request #6888 from davidwatkins73/waltz-6887-flow-details-auth-rating-filter
flow details auth rating filter
2 parents 7787b87 + f568cac commit bb76dc1

6 files changed

Lines changed: 144 additions & 16 deletions

File tree

waltz-ng/client/data-flow/components/svelte/flow-detail-tab/FlowDetailPanel.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import {filters, resetFlowDetailsStore, selectedLogicalFlow, selectedPhysicalFlow} from "./flow-details-store";
99
import PhysicalFlowTable from "./PhysicalFlowTable.svelte";
1010
import {mkFlowDetails} from "./flow-detail-utils";
11-
import {mkAssessmentFilters} from "./filters/filter-utils";
11+
import {getAssessmentFilters} from "./filters/filter-utils";
1212
import SelectedFlowDetailPanel from "./SelectedFlowDetailPanel.svelte";
1313
import {onMount} from "svelte";
1414
import DataExtractLink from "../../../../common/svelte/DataExtractLink.svelte";
@@ -18,7 +18,6 @@
1818
export let parentEntityRef;
1919
2020
function filterFlows(allFlows, filters) {
21-
console.log("ff", {allFlows, filters})
2221
return _
2322
.chain(allFlows)
2423
.map(d => Object.assign(d, {visible: _.every(filters, f => f.test(d))}))
@@ -35,6 +34,8 @@
3534
let mappedDataTypes = [];
3635
let assessmentFilters = [];
3736
let dataTypes = [];
37+
let allDataTypes = [];
38+
let flowClassifications = [];
3839
let allFlows = [];
3940
let physicalFlows = [];
4041
let logicalFlows = [];
@@ -71,7 +72,7 @@
7172
7273
const mappedDataTypeIds = _.map(mappedDataTypes, d => d.dataTypeId);
7374
dataTypes = reduceToSelectedNodesOnly(allDataTypes, mappedDataTypeIds);
74-
assessmentFilters = mkAssessmentFilters(flowView);
75+
assessmentFilters = getAssessmentFilters(flowView);
7576
allFlows = mkFlowDetails(flowView, parentEntityRef);
7677
}
7778
}
@@ -89,6 +90,7 @@
8990
<div class="flow-detail-table">
9091
<FlowDetailFilters {dataTypes}
9192
{assessmentFilters}
93+
{flowClassifications}
9294
{physicalFlows}/>
9395
9496
<LogicalFlowTable {logicalFlows}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<script>
2+
import {
3+
mkClassificationFilterId,
4+
mkClassificationFilter,
5+
FilterKinds
6+
} from "./filter-utils";
7+
import _ from "lodash";
8+
import {filters, updateFilters} from "../flow-details-store";
9+
import RatingIndicatorCell
10+
from "../../../../../ratings/components/rating-indicator-cell/RatingIndicatorCell.svelte";
11+
12+
13+
export let flowClassifications = [];
14+
15+
function selectClassification(classification) {
16+
17+
const filterId = mkClassificationFilterId();
18+
19+
const existingFilter = _.find($filters, f => f.id === filterId);
20+
21+
const existingClassifications = _.get(existingFilter, "classifications", []);
22+
23+
const newClassifications = _.some(existingClassifications, r => _.isEqual(r, classification.code))
24+
? _.filter(existingClassifications, d => !_.isEqual(d, classification.code))
25+
: _.concat(existingClassifications, [classification.code]);
26+
27+
const newFilter = mkClassificationFilter(filterId, newClassifications)
28+
29+
updateFilters(filterId, newFilter);
30+
}
31+
32+
33+
function isSelected(filters, fcCode){
34+
const classificationFilter = _.find(
35+
filters,
36+
f => f.id === mkClassificationFilterId());
37+
return _.some(
38+
_.get(classificationFilter, "classifications", []),
39+
selectedFcCode => fcCode === selectedFcCode);
40+
}
41+
42+
function onClearFilters() {
43+
$filters = _.reject($filters, f => f.kind === FilterKinds.FLOW_CLASSIFICATION);
44+
}
45+
46+
$: hasFilters = _.some($filters, f => f.kind === FilterKinds.FLOW_CLASSIFICATION);
47+
48+
</script>
49+
50+
<div class="help-block"
51+
style="padding-top: 1em;">
52+
Filters the flows based upon their classification ratings.
53+
</div>
54+
<div style="display: flex; padding-top: 1em; padding-bottom: 1em">
55+
<table class="table table-condensed table table-hover">
56+
<thead>
57+
<tr>
58+
<th>
59+
Flow Classification
60+
</th>
61+
<th>
62+
{#if hasFilters}
63+
<button class="btn-skinny"
64+
style="font-weight: lighter"
65+
on:click={onClearFilters}>
66+
Clear
67+
</button>
68+
{/if}
69+
</th>
70+
</tr>
71+
</thead>
72+
<tbody>
73+
{#each _.orderBy(flowClassifications, d => d.name) as fc}
74+
<tr class="clickable"
75+
class:selected={isSelected($filters, fc.code)}
76+
on:click={() => selectClassification(fc)}>
77+
<td>
78+
<RatingIndicatorCell {...fc}/>
79+
</td>
80+
<td>
81+
{fc.description}
82+
</td>
83+
</tr>
84+
{/each}
85+
</tbody>
86+
</table>
87+
</div>
88+
89+
<style>
90+
91+
.selected {
92+
background-color: #eefaee !important;
93+
}
94+
95+
</style>

waltz-ng/client/data-flow/components/svelte/flow-detail-tab/filters/FlowDetailFilters.svelte

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ import AssessmentFilters from "./AssessmentFilters.svelte";
88
import InboundOutboundFilters from "./InboundOutboundFilters.svelte";
99
import PhysicalFlowAttributeFilters from "./PhysicalFlowAttributeFilters.svelte";
1010
import DataTypeFilters from "./DataTypeFilters.svelte";
11+
import FlowClassificationFilters from "./FlowClassificationFilters.svelte";
1112
1213
export let dataTypes = [];
1314
export let assessmentFilters = [];
1415
export let physicalFlows = [];
16+
export let flowClassifications = [];
17+
18+
19+
$: classificationFilter = _.find($filters, d => d.kind === FilterKinds.FLOW_CLASSIFICATION);
20+
$: directionFilter = _.find($filters, d => d.kind === FilterKinds.DIRECTION);
1521
1622
</script>
1723

@@ -28,8 +34,8 @@ export let physicalFlows = [];
2834

2935
<details class="filter-set" style="margin-top: 1em">
3036
<summary>
31-
<Icon name="random"/> Flow Direction & Classification
32-
{#if _.some($filters, d => d.kind === FilterKinds.DIRECTION) && _.find($filters, d => d.kind === FilterKinds.DIRECTION).direction !== Directions.ALL}
37+
<Icon name="random"/> Flow Direction
38+
{#if !_.isEqual(_.get(directionFilter, ["direction"], Directions.ALL), Directions.ALL)}
3339
<span style="color: darkorange"
3440
title="Flows have been filtered by direction">
3541
<Icon name="exclamation-circle"/>
@@ -39,6 +45,19 @@ export let physicalFlows = [];
3945
<InboundOutboundFilters/>
4046
</details>
4147

48+
<details class="filter-set" style="margin-top: 1em">
49+
<summary>
50+
<Icon name="shield"/> Flow Classification
51+
{#if !_.isEmpty(_.get(classificationFilter, ["classifications"], []))}
52+
<span style="color: darkorange"
53+
title="Flows have been filtered by classification">
54+
<Icon name="exclamation-circle"/>
55+
</span>
56+
{/if}
57+
</summary>
58+
<FlowClassificationFilters {flowClassifications}/>
59+
</details>
60+
4261
<details class="filter-set">
4362
<summary>
4463
<Icon name="qrcode"/> Data Types

waltz-ng/client/data-flow/components/svelte/flow-detail-tab/filters/filter-utils.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ export const FilterKinds = {
66
DATA_TYPE: "DATA_TYPE",
77
ASSESSMENT: "ASSESSMENT",
88
PHYSICAL_FLOW_ATTRIBUTE: "PHYSICAL_FLOW_ATTRIBUTE",
9-
SELECTED_LOGICAL: "SELECTED_LOGICAL"
9+
SELECTED_LOGICAL: "SELECTED_LOGICAL",
10+
FLOW_CLASSIFICATION: "FLOW_CLASSIFICATION"
1011
}
1112

12-
export function mkAssessmentFilters(flowView) {
13+
export function getAssessmentFilters(flowView) {
1314

1415
const ratingSchemeItemsById = _.keyBy(flowView.ratingSchemeItems, d => d.id);
1516
const definitions = _.compact(_.concat(
@@ -57,6 +58,10 @@ export function mkDefinitionFilterId(definitionId) {
5758
return `ASSESSMENT_DEFINITION_${definitionId}`;
5859
}
5960

61+
export function mkClassificationFilterId() {
62+
return `FLOW_CLASSIFICATION`;
63+
}
64+
6065
export function mkDataTypeFilterId() {
6166
return "DATA_TYPE";
6267
}
@@ -134,3 +139,18 @@ export function mkDirectionFilter(id, direction) {
134139
: _.isEqual(r.direction, direction)
135140
};
136141
}
142+
143+
export function mkClassificationFilter(id, desiredClassificationRatings = []) {
144+
return {
145+
id,
146+
kind: FilterKinds.FLOW_CLASSIFICATION,
147+
classifications: desiredClassificationRatings,
148+
test: flowRow => _.isEmpty(desiredClassificationRatings)
149+
? true
150+
: _.some(
151+
flowRow.dataTypesForLogicalFlow,
152+
x => _.some(
153+
desiredClassificationRatings,
154+
d => _.isEqual(d, x.rating)))
155+
}
156+
}

waltz-service/src/main/java/org/finos/waltz/service/flow_classification_rule/FlowClassificationService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
import org.finos.waltz.data.flow_classification_rule.FlowClassificationDao;
2222
import org.finos.waltz.model.flow_classification.FlowClassification;
23-
import org.slf4j.Logger;
24-
import org.slf4j.LoggerFactory;
2523
import org.springframework.beans.factory.annotation.Autowired;
2624
import org.springframework.stereotype.Service;
2725

@@ -33,8 +31,6 @@
3331
@Service
3432
public class FlowClassificationService {
3533

36-
private static final Logger LOG = LoggerFactory.getLogger(FlowClassificationService.class);
37-
3834
private final FlowClassificationDao flowClassificationDao;
3935

4036
@Autowired

waltz-web/src/main/java/org/finos/waltz/web/endpoints/api/FlowClassificationEndpoint.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,13 @@ public class FlowClassificationEndpoint implements Endpoint {
4242
private static final String BASE_URL = WebUtilities.mkPath("api", "flow-classification");
4343

4444
private final FlowClassificationService flowClassificationService;
45-
private final UserRoleService userRoleService;
4645

4746

4847
@Autowired
49-
public FlowClassificationEndpoint(FlowClassificationService flowClassificationService,
50-
UserRoleService userRoleService) {
48+
public FlowClassificationEndpoint(FlowClassificationService flowClassificationService) {
5149
checkNotNull(flowClassificationService, "flowClassificationService must not be null");
52-
checkNotNull(userRoleService, "userRoleService cannot be null");
5350

5451
this.flowClassificationService = flowClassificationService;
55-
this.userRoleService = userRoleService;
5652
}
5753

5854

0 commit comments

Comments
 (0)