Skip to content

Commit 9bc9003

Browse files
Merge pull request #7300 from deutschebank/db-contrib/waltz-7299-viewpoint-mapping-changes
Db contrib/waltz 7299 viewpoint mapping changes
2 parents 8c95ae2 + 5f8b077 commit 9bc9003

File tree

6 files changed

+177
-20
lines changed

6 files changed

+177
-20
lines changed

waltz-data/src/main/java/org/finos/waltz/data/changelog/ChangeLogDao.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,19 @@ public static SelectConditionStep<Record> mkUnattestedChangesQuery(EntityReferen
110110
.and(latestAttestationsSubQuery.field("pei", Long.class).eq(cl.PARENT_ID))
111111
.and(latestAttestationsSubQuery.field("aek", String.class).eq(cl.CHILD_KIND));
112112

113+
// query for viewpoints as the kinds differ
114+
Condition viewpointAttestationCondition = latestAttestationsSubQuery.field("pek", String.class).eq(cl.PARENT_KIND)
115+
.and(latestAttestationsSubQuery.field("pei", Long.class).eq(cl.PARENT_ID))
116+
.and(latestAttestationsSubQuery.field("aek", String.class).eq(EntityKind.MEASURABLE_CATEGORY.name()))
117+
.and(cl.CHILD_KIND.eq(EntityKind.MEASURABLE.name()));
118+
113119
// giving the final query which limits the changelog based to those entries after the latest attestation:
114120
return DSL
115121
.select(cl.fields())
116122
.from(cl)
117123
.innerJoin(latestAttestationsSubQuery)
118-
.on(joinChangeLogToLatestAttestationCondition)
124+
.on(joinChangeLogToLatestAttestationCondition
125+
.or(viewpointAttestationCondition))
119126
.where(cl.CREATED_AT.greaterThan(latestAttestationsSubQuery.field("aat", Timestamp.class)))
120127
.and(changeLogEntryOfInterest);
121128
}

waltz-ng/client/attestation/components/section/attestation-section.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
ng-if="$ctrl.activeTab === 'viewpoints'">
8181
<waltz-svelte-component component="$ctrl.MeasurableAttestationPanel"
8282
on-attestation-initiated="$ctrl.onMeasurableAttestationInitiated"
83-
primary-entity-ref="$ctrl.parentEntityRef">
83+
primary-entity-ref="$ctrl.parentEntityRef"
84+
un-attested-changes ="$ctrl.allUnattestedChanges">
8485
</waltz-svelte-component>
8586
</div>
8687
</div>

waltz-ng/client/attestation/components/section/attestation-section.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ function controller($q,
141141
.all([runsPromise, instancesPromise, unattestedChangesPromise, permissionGroupPromise])
142142
.then(([runs, instances, unattestedChanges, permissions]) => {
143143
vm.attestations = mkAttestationData(runs, instances);
144+
vm.allUnattestedChanges = unattestedChanges && unattestedChanges.length ? unattestedChanges : []
144145
vm.attestationSections = mkAttestationSections(baseSections, vm.attestations, unattestedChanges);
145146
vm.permissions = permissions;
146147
});

waltz-ng/client/attestation/components/svelte/MeasurableAttestationPanel.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import _ from "lodash";
23
import {attestationInstanceStore} from "../../../svelte-stores/attestation-instance-store";
34
import NoData from "../../../common/svelte/NoData.svelte";
45
import {permissionGroupStore} from "../../../svelte-stores/permission-group-store";
@@ -9,11 +10,16 @@
910
1011
export let primaryEntityRef;
1112
export let onAttestationInitiated = (category) => console.log("Default Handler: onAttestationInitiated", {category});
13+
export let unAttestedChanges;
1214
1315
function attestationInitiated(evt) {
1416
onAttestationInitiated(evt.detail);
1517
}
1618
19+
function getUnAttestedChanges() {
20+
return _.filter(unAttestedChanges, change => change.childKind === 'MEASURABLE');
21+
}
22+
1723
let chunkedCategories = [];
1824
1925
$: latestAttestationsCall = attestationInstanceStore.findLatestMeasurableAttestations(primaryEntityRef, true);
@@ -23,6 +29,7 @@
2329
$supportedCategoriesCall.data,
2430
$latestAttestationsCall.data),
2531
2);
32+
$: changelog = getUnAttestedChanges();
2633
</script>
2734

2835

@@ -36,7 +43,8 @@
3643
<MeasurableAttestationSubPanel on:attestationInitiated={attestationInitiated}
3744
measurableCategory={chunk.qualifierReference}
3845
latestAttestation={chunk.latestAttestation}
39-
isAttestable={chunk.hasPermission}/>
46+
isAttestable={chunk.hasPermission}
47+
unAttestedChanges={changelog}/>
4048
</div>
4149
{/each}
4250
</div>
Lines changed: 153 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,136 @@
11
<script>
2+
import moment from "moment";
3+
import _ from "lodash";
4+
import { SlickGrid } from "slickgrid";
5+
import Icon from "../../../common/svelte/Icon.svelte";
26
import SubSection from "../../../common/svelte/SubSection.svelte";
37
import NoData from "../../../common/svelte/NoData.svelte";
4-
import {createEventDispatcher} from "svelte";
8+
import { createEventDispatcher } from "svelte";
59
import MiniActions from "../../../common/svelte/MiniActions.svelte";
610
import DateTime from "../../../common/svelte/DateTime.svelte";
7-
import _ from "lodash";
11+
import { mkSortFn } from "../../../common/slick-grid-utils";
12+
import SearchInput from "../../../common/svelte/SearchInput.svelte";
13+
import { termSearch } from "../../../common";
14+
import { compareDates } from "../../../common/sort-utils";
15+
import { severity } from "../../../common/services/enums/severity";
816
917
export let measurableCategory;
1018
export let isAttestable = false;
1119
export let latestAttestation = null;
20+
export let unAttestedChanges = [];
21+
let grid;
22+
let viewData = [];
23+
let elem = null;
24+
let searchStr = "";
25+
let showingUnAttestedChanges = false;
1226
1327
const dispatcher = createEventDispatcher();
1428
1529
const attestMiniAction = {
1630
name: "Attest Now",
1731
icon: "check",
1832
description: "Initiate Attestation",
19-
handleAction: ctx => dispatcher("attestationInitiated", ctx)
33+
handleAction: (ctx) => dispatcher("attestationInitiated", ctx),
34+
};
35+
36+
const options = {
37+
enableCellNavigation: false,
38+
enableColumnReorder: false,
2039
};
2140
22-
$: actions = _.compact([
23-
isAttestable ? attestMiniAction : null
24-
]);
41+
function initGrid(elem) {
42+
grid = new SlickGrid(elem, [], columnDefs, options);
43+
grid.onSort.subscribe((e, args) => {
44+
const sortCol = args.sortCol;
45+
grid.data.sort(mkSortFn(sortCol, args.sortAsc));
46+
grid.invalidate();
47+
});
48+
}
49+
50+
function mkGridData(data) {
51+
return data;
52+
}
53+
54+
function doGridSearch(data = [], searchStr) {
55+
return termSearch(data, searchStr, [
56+
"severity",
57+
"message",
58+
"userId",
59+
"createdAt",
60+
]);
61+
}
62+
63+
$: actions = _.compact([isAttestable ? attestMiniAction : null]);
64+
65+
$: hasEverBeenAttested = !_.isNil(_.get(latestAttestation, "attestedBy"));
66+
67+
$: columnDefs = [
68+
{
69+
id: "severity",
70+
field: "severity",
71+
name: "Severity",
72+
width: 50,
73+
sortable: true,
74+
formatter: (row, cell, value) => {
75+
return value
76+
? `<span title="${value}">${severity[value].name}</span>`
77+
: "";
78+
},
79+
},
80+
{
81+
id: "message",
82+
field: "message",
83+
name: "Message",
84+
width: 200,
85+
formatter: (row, cell, value) => {
86+
return `<span title="${value}">${value}</span>`;
87+
},
88+
},
89+
{
90+
id: "userId",
91+
field: "userId",
92+
name: "User",
93+
width: 100,
94+
formatter: (row, cell, value) => {
95+
return `<span title="${value}">${value}</span>`;
96+
},
97+
},
98+
{
99+
id: "createdAt",
100+
field: "createdAt",
101+
name: "Timestamp",
102+
width: 50,
103+
sortable: true,
104+
formatter: (row, cell, value) => {
105+
if (value) {
106+
const formatStr = "YYYY-MM-DD HH:mm:ss";
107+
const format = (t) =>
108+
moment.utc(t).local().format(formatStr);
109+
110+
return `<span>${format(value)}</span>`;
111+
}
112+
return "";
113+
},
114+
sortFn: (a, b) => compareDates(a?.createdAt, b?.createdAt),
115+
},
116+
];
117+
$: {
118+
if (unAttestedChanges.length) {
119+
viewData = mkGridData(unAttestedChanges);
120+
}
121+
122+
if (elem && !_.isEmpty(viewData)) {
123+
initGrid(elem);
124+
}
125+
}
25126
26-
$: hasEverBeenAttested = ! _.isNil(_.get(latestAttestation, "attestedBy"))
127+
$: {
128+
const data = doGridSearch(viewData, searchStr);
129+
if (grid) {
130+
grid.data = data;
131+
grid.invalidate();
132+
}
133+
}
27134
</script>
28135
29136
{#if measurableCategory}
@@ -33,7 +140,6 @@
33140
</div>
34141
<div slot="content">
35142
{#if hasEverBeenAttested}
36-
37143
<table class="table waltz-field-table waltz-field-table-border">
38144
<tr>
39145
<td class="wft-label">Attested By:</td>
@@ -42,33 +148,63 @@
42148
<tr>
43149
<td class="wft-label">Attested At:</td>
44150
<td>
45-
<DateTime dateTime={latestAttestation.attestedAt}/>
151+
<DateTime dateTime={latestAttestation.attestedAt} />
46152
</td>
47153
</tr>
48154
</table>
49-
50155
{:else}
51-
52156
<NoData type="warning">
53157
Never attested.
54158
{#if isAttestable}
55-
<button class="btn-link"
56-
on:click={() => attestMiniAction.handleAction(measurableCategory)}>
159+
<button
160+
class="btn-link"
161+
on:click={() =>
162+
attestMiniAction.handleAction(
163+
measurableCategory,
164+
)}
165+
>
57166
Attest now
58167
</button>
59168
{/if}
60169
</NoData>
61-
62170
{/if}
63171
</div>
64172
65173
<div slot="controls">
66174
<div style="float:right" class="small">
67175
{#if isAttestable}
68-
<MiniActions actions={actions} ctx={measurableCategory}/>
176+
<MiniActions {actions} ctx={measurableCategory} />
69177
{/if}
70178
</div>
71179
</div>
72-
180+
<div slot="changes">
181+
{#if !_.isEmpty(viewData)}
182+
<NoData type={"warning"}>
183+
{#if showingUnAttestedChanges}
184+
<SearchInput bind:value={searchStr} />
185+
<div
186+
class="slick-container"
187+
style="width:100%;height:250px;"
188+
bind:this={elem}
189+
></div>
190+
{:else}
191+
<Icon
192+
name="exclamation-triangle"
193+
size="2x"
194+
/>
195+
Unattested changes detected
196+
<button
197+
class="btn-link"
198+
on:click={() => (showingUnAttestedChanges = true)}
199+
>
200+
Show the <span>{unAttestedChanges.length}</span> unattested
201+
change/s.
202+
</button>
203+
{/if}
204+
</NoData>
205+
{:else}
206+
<NoData>No attestation changes</NoData>
207+
{/if}
208+
</div>
73209
</SubSection>
74-
{/if}
210+
{/if}

waltz-ng/client/common/svelte/SubSection.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
<div class="controls">
1818
<slot name="controls"></slot>
1919
</div>
20+
21+
<div class="content">
22+
<slot name="changes"></slot>
23+
</div>
2024
</div>
2125

2226
<style type="text/scss">

0 commit comments

Comments
 (0)