nasa / openmct

A web based mission control framework.
https://nasa.github.io/openmct/
Other
12.02k stars 1.24k forks source link

When dropping an unsupported file onto a notebook entry, tell the user it isn't supported #7097

Closed scottbell closed 12 months ago

scottbell commented 1 year ago

Is your feature request related to a problem? Please describe. When dropping an supported file onto a notebook entry (e.g., non-image or an image too big), tell the user it isn't supported - don't just silently fail.

Describe the solution you'd like Perhaps a notification that the embed didn't work because it wasn't the right type of file (an image), or it was too big.

Note that for the issue of an image being too big, this does not affect the initial import of the file into the entry, but rather when the user is doing some action with the image afterwards (i.e., annotating). When the image is annotated and saved, only then do we see errors coming from the console, which stop the annotations from persisting.

scottbell commented 1 year ago

@scottbell to document how/why images are getting bigger post annotations. My current theory is when we annotate, we re-save the image much larger than the original.

scottbell commented 1 year ago

@rukmini-bose found that an image that's 2MB in size goes to 4.9 MB after adding a circle, which points to the image library being a bit inefficient about encoding

scottbell commented 1 year ago

I've added notifications & errors for:

I've also updated the README in the CouchDB plugin to describe how to up the documents limits. Basically:

  [couchdb]
  max_document_size = 4294967296 ; approx 4 GB

  [chttpd]
  max_http_request_size = 4294967296 ; approx 4 GB

as both the documents, and the HTTP server in front of CouchDB need to accept the new big limits.

I've also updated interaction with the entry to accept pasting of images, both in the text box, and if selecting the entry.

What I haven't done is intercept a CouchDB error when annotating an image that's become too big, as this happens during a mutation, which unfortunately isn't propagated all the way back. We could fix this by allowing mutate in ObjectAPI to return a Promise, e.g.:

mutate(domainObject, path, value) {
    this.#mutate(domainObject, path, value);

    if (this.isTransactionActive()) {
      return Promise.resolve(this.transaction.add(domainObject));
    } else {
      return this.save(domainObject);
    }
  }

and then catching it on the Notebook side, but this is touching some core Open MCT stuff, and would need @akhenry's blessing.

scottbell commented 1 year ago

To test:

  1. Create a notebook
  2. Drop an unsupported file onto the notebook (e.g., a javascript file)
  3. Note the error
  4. Drop a really big image file onto the notebook (> 20 megabytes)
  5. Note the couch error
  6. Drop a normal size image onto the notebook (~6 megabytes)
  7. Annotate the image, click done
  8. Note the couch error waiting for you

Also, try copy/pasting images into both the entry text, and just selecting the entry. It should create embeddings for you.

shefalijoshi commented 11 months ago

Verified fixed.