Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MainUI] /settings/things/<thing uid> requests entire things JSON from API #1650

Closed
ccutrer opened this issue Jan 17, 2023 · 3 comments · Fixed by #1661
Closed

[MainUI] /settings/things/<thing uid> requests entire things JSON from API #1650

ccutrer opened this issue Jan 17, 2023 · 3 comments · Fixed by #1661
Labels
enhancement New feature or request main ui Main UI

Comments

@ccutrer
Copy link
Contributor

ccutrer commented Jan 17, 2023

The problem

I have a lot of things. With an even more ridiculous amount of channels. My /rest/things endpoint returns over 2.5MB of JSON. When I'm local, this takes nearly a second just to transfer. If I'm remote, it would take much longer. Right now, when I click on an individual thing to configure it, I notice that it's using /rest/things to load the data. I'm sure this takes a long time for the javascript to parse, as well.

Your suggestion

Instead, it should use /rest/things/<thing UID> to only load the relevant information for the current page.

Your environment

runtimeInfo:
  version: 3.4.1
  buildString: Release Build
locale: en-Latn-US
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 17.0.5
  javaVendor: Private Build
  osName: Linux
  osVersion: 5.15.0-57-generic
  osArchitecture: amd64
  availableProcessors: 8
  freeMemory: 169239392
  totalMemory: 2147483648
  startLevel: 100
bindings:
  - amazonechocontrol
  - astro
  - bondhome
  - dscalarm
  - lgwebos
  - mqtt
  - myq
  - onkyo
  - pioneeravr
  - tuya
  - unifi
  - zwave
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: true
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: macos
    pixelRatio: 2
    prefersColorScheme: light
  isSecureContext: true
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 8
    language: en-US
    languages:
      - en-US
    onLine: true
    platform: MacIntel
  screen:
    width: 3008
    height: 1692
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: filled
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15
    (KHTML, like Gecko) Version/16.2 Safari/605.1.15
timestamp: 2023-01-17T23:36:18.688Z
@ccutrer ccutrer added enhancement New feature or request main ui Main UI labels Jan 17, 2023
@ccutrer
Copy link
Contributor Author

ccutrer commented Jan 18, 2023

After watching network inspector more, it seems that the thing-specific endpoint is used when opening the settings page for a specific thing, but then the broad request is also sent to /rest/things. so maybe not necessarily the main data load for the page using the general endpoint.

@ghys
Copy link
Member

ghys commented Jan 22, 2023

I think the additional call is due to the thing picker used to select the bridge:

// TODO use a Vuex store
this.$oh.api.get('/rest/things').then((data) => {
this.things = data.sort((a, b) => {

It could use a ?summary=true here to limit the amount of data (or eventually a cache/Vuex store but then we'll have to deal with outdated data and how to detect it without querying - this would be relatively easy if the ETag or Last-Modified HTTP headers were supported: a 304 Not Modified response to a request with the header would then determine if the objects in cache are to be refreshed).

The rules picker should also append ?summary=true:

// TODO use a Vuex store
this.$oh.api.get('/rest/rules').then((data) => {
this.rules = data.sort((a, b) => {

/rest/items doesn't have a summary query parameter so the item picker can't be changed.

@ccutrer
Copy link
Contributor Author

ccutrer commented Jan 22, 2023

Nice sleuthing! While ETag/Last-Modified support from openHAB would be nice, it may not be easy. Especially considering item state. Just adding ?summary to the bridge (and rules) calls would be extremely helpful. Perhaps if there were a ?bridgesOnly param for the former as well?

ghys added a commit to ghys/openhab-webui that referenced this issue Jan 24, 2023
Depends on openhab/openhab-core#3335.

Will fetch items, things and rules with the `cacheable` parameter set
when appropriate.

Closes openhab#1650.

Signed-off-by: Yannick Schaus <github@schaus.net>
ghys added a commit to ghys/openhab-webui that referenced this issue Jan 24, 2023
Depends on openhab/openhab-core#3335.

Will fetch items, things and rules with the `cacheable` parameter set
when appropriate.

Closes openhab#1650.

Signed-off-by: Yannick Schaus <github@schaus.net>
florian-h05 pushed a commit that referenced this issue Jul 2, 2023
Closes #1650.
Depends on openhab/openhab-core#3335.

Will fetch items, things and rules with the `staticDataOnly` parameter set when appropriate.

Also-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Yannick Schaus <github@schaus.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
2 participants