Skip to content

Commit

Permalink
#1712 fix patching a thing, removing items did not correctly upgrade …
Browse files Browse the repository at this point in the history
…the thing on the UI

* fixed by solving the merge on Ditto server side, selecting all "extraFields" for each change .. that way, the complete updated thing is emitted via the SSE instead only the diff
* as a result, also deleted the "merge" functionality of the UI, also removed no-longer needed "lodash" dependency

Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
  • Loading branch information
thjaeckle committed Oct 15, 2023
1 parent f54eed2 commit 09bef5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
30 changes: 15 additions & 15 deletions ui/modules/things/thingsSSE.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
/* eslint-disable require-jsdoc */
/* eslint-disable arrow-parens */
// @ts-check
Expand All @@ -18,7 +18,6 @@ import * as Environments from '../environments/environments.js';

import * as Things from './things.js';
import * as ThingsSearch from './thingsSearch.js';
import merge from 'lodash/merge';

let selectedThingEventSource;
let thingsTableEventSource;
Expand Down Expand Up @@ -57,7 +56,8 @@ function onSelectedThingChanged(newThingJson, isNewThingId) {
selectedThingEventSource && selectedThingEventSource.close();
console.log('SSE Start: SELECTED THING : ' + newThingJson.thingId);
selectedThingEventSource = API.getEventSource(newThingJson.thingId,
'fields=thingId,attributes,features,_revision,_modified');
'fields=thingId,policyId,attributes,features,_revision,_modified,_metadata' +
'&extraFields=thingId,policyId,attributes,features,_revision,_modified,_metadata');
selectedThingEventSource.onmessage = onMessageSelectedThing;
}
}
Expand All @@ -78,8 +78,8 @@ function onEnvironmentChanged(modifiedField) {

function onMessageSelectedThing(event) {
if (event.data && event.data !== '') {
const merged = merge(Things.theThing, JSON.parse(event.data));
Things.setTheThing(merged);
const completeChangedThing = JSON.parse(event.data);
Things.setTheThing(completeChangedThing);
notifyAll(JSON.parse(event.data));
}
}
Expand Down
8 changes: 1 addition & 7 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"bootstrap": "^5.2.3",
"bootstrap-icons": "^1.10.5",
"event-source-polyfill": "^1.0.31",
"jsonpath-plus": "^7.2.0",
"lodash": "^4.17.21"
"jsonpath-plus": "^7.2.0"
}
}

0 comments on commit 09bef5b

Please sign in to comment.