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

[draw.io] Deployment config + .vsdx support #4337

Merged
merged 14 commits into from Dec 9, 2020

Conversation

VirtualEvan
Copy link
Contributor

@VirtualEvan VirtualEvan commented Nov 18, 2020

Description

  1. This PR allows to import .vsdx (Microsoft Visio files) directly from OC.
  2. Once the file is open, if saved, a new <filename>_<timestamp>.drawio file is created with the modifications. (This avoids overwriting the original file with XML content). A message informing this should be shown ( [Bug] Messages not shown in fullscreen apps #4335 )
  3. By default, the draw-io app now points to https://embed.diagrams.net (The official embed-specific draw.io server)
  4. If specified, the configuration in config.json will be used for the connections to draw.io (server url, autosave and theme)
    {
      ...
      "applications": [
        {
          "title": {
            "en": "draw-io"
          },
          "url": "https://custom.draw.io.url",
          "autosave": true,
          "theme": "atlas"
        }
      ]
    }

Related Issue

Motivation and Context

  • Privacy reasons
  • Flexibility
  • Support for more formats

How Has This Been Tested?

  • test environment:
    Docker OC 10 + local Phoenix: following this docs
  • test case 1:
    Use custom draw.io server, enable autosave, use the 'atlas' theme
  • test case 2:
    Open a .vsdx file by clicking on it

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Import .vsdx files directly from OwnCloud
  • Custom draw.io server support
  • Autosave support
  • Different themes support
  • Specify draw.io settings in the global configuration
  • Use by default the embed-specific diagrams.net server
  • View mode for read-only diagrams

@update-docs
Copy link

update-docs bot commented Nov 18, 2020

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@CLAassistant
Copy link

CLAassistant commented Nov 18, 2020

CLA assistant check
All committers have signed the CLA.

@VirtualEvan
Copy link
Contributor Author

I have a couple of questions regarding the implementation of these functionalities.

  1. I could not find a way to get the file permissions from inside an app, can that be achieved somehow? I am interest in knowing if the current user has read-only permissions on the open diagram.

  2. The only place I found situable to put the draw.io configuration settings was the "applications" array in config.json as there are similar configurations for other apps. However, as it is an array, it is necessary to filter by the title and en (english name), in order to get the right app.
    Is there some other place where this information could be set in a more optimal and reliable way? Or maybe change it from being an array to be a named object? Not sure how this change would affect other functionalities of Phoenix.

@LukasHirt
Copy link
Contributor

LukasHirt commented Nov 24, 2020

I could not find a way to get the file permissions from inside an app, can that be achieved somehow? I am interest in knowing if the current user has read-only permissions on the open diagram.

You could do a call via our sdk - this.$client.files.fileInfo(filePath, ['{http://owncloud.org/ns}permissions'])

The only place I found situable to put the draw.io configuration settings was the "applications" array in config.json...

This will be possible after merging #4380. Applications array is only for displaying the app in the app switcher. The config shouldn't be used for settings outside of that. Otherwise, there's also settings service which enables you to create a settings bundle for extension https://owncloud.github.io/extensions/settings/bundles For this basic config it might be too much effort though.

enabled: true
}
})
fetch(url, { headers })
Copy link
Contributor

@LukasHirt LukasHirt Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with getFileContent, but it looks like we cannot specify the responsetype. Drawio is able to handle the vsdx file as base64, so we need the file itself insted of its content. Also tried to re-create the file from its binary content, but I could not find a way to do so, the resultant file was always different.

@VirtualEvan
Copy link
Contributor Author

Sorry for the delay, I've been quite busy and wanted to test as much as possible before comming back to you

You could do a call via our sdk - this.$client.files.fileInfo(filePath, ['{http://owncloud.org/ns}permissions'])

I am trying to show diagrams in chromeless mode when they are read-only.
The SDK allowed me to know if the file is read-only, but as it is asychronous I had to delay the render until the response is ready.

This will be possible after merging #4380. Applications array is only for displaying the app in the app switcher. The config shouldn't be used for settings outside of that...

By this I understand that the applications array should not be used to store configuration specific to applications, but the external_apps can be used for this, is it right? I added it under external_apps and was able to get it directly from the store.

@LukasHirt
Copy link
Contributor

I am trying to show diagrams in chromeless mode when they are read-only.
The SDK allowed me to know if the file is read-only, but as it is asychronous I had to delay the render until the response is ready.

Is the delay okay or does it cause some issues? AFAICT the delay shouldn't take too long so from users POV it shouldn't be a big problem.

By this I understand that the applications array should not be used to store configuration specific to applications, but the external_apps can be used for this, is it right? I added it under external_apps and was able to get it directly from the store.

Correct. Nice!

@LukasHirt
Copy link
Contributor

Can you try to rebase the PR? It might solve the failing tests.

@VirtualEvan
Copy link
Contributor Author

VirtualEvan commented Dec 8, 2020

Rebasing fixed the issue with the tests, thanks!

Is the delay okay or does it cause some issues? AFAICT the delay shouldn't take too long so from users POV it shouldn't be a big problem.

It is not a problem in my local instance, but I was not sure how long could it take for other people with different/more complex setups. If you think it is OK then is perfect! :)

Copy link
Contributor

@LukasHirt LukasHirt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🚀

@LukasHirt
Copy link
Contributor

@VirtualEvan Let me pls know if there's something left you would like to commit here or if I can hit the merge button 😉

@VirtualEvan
Copy link
Contributor Author

No, I think that's all. Please merge :)

Do you want me to add some documentation somewhere mentioning the options that can be configured for the app?

"external_apps": [
  {
    "id": "draw-io",
    "path": "this_should_exist_and_cannot_be_empty",
    "config": {
      "url": "https://drawio.web.cern.ch",
      "autosave": true,
      "theme": "atlas"
    }
  }
]

By the way, I noticed that for external apps, path is mandatory.
If it does not exist or is empty, then everything fails. Just putting a dummy value makes it work.
Not sure if it's a bug or if I missed something.

@LukasHirt
Copy link
Contributor

LukasHirt commented Dec 9, 2020

Do you want me to add some documentation somewhere mentioning the options that can be configured for the app?

That would be awesome to have it documented. Maybe you could put it in the sample config.json files? If you want to add it here, I'll wait with the merging 😉 Thank you!

By the way, I noticed that for external apps, path is mandatory.

Yep, both id and path are mandatory. Without the path, the frontend doesn't know where to locate the app. I know that it's now creating confusion with the apps array where drawio is loaded. If you check the console, there should be actually a 404 error. That could be fixed by specifying the correct path and removing drawio from apps array to prevent having the app loaded twice.

@VirtualEvan
Copy link
Contributor Author

OK, I think I got it.
Added default configuration to the oc10 and ocis sample config.json files

Let me know if there is something else I can add that could be helpful

@LukasHirt
Copy link
Contributor

Thank you! I think that this is now in a perfect shape for merging! I'll hit the button when CI is green 😉

@LukasHirt LukasHirt merged commit 190e0f8 into owncloud:master Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add custom draw.io settings [Feature] draw.io vsdx support
3 participants