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

Vue.js frontend possible? #1841

Open
nerdoc opened this issue Mar 13, 2020 · 15 comments
Open

Vue.js frontend possible? #1841

nerdoc opened this issue Mar 13, 2020 · 15 comments

Comments

@nerdoc
Copy link
Contributor

nerdoc commented Mar 13, 2020

More a question than an issue. This project is really promising.
Is there a way to support Vue.js instead of Angular? I don't expect you to support that, it's me that want so use Vue instead - so I'd just like to know:
Would it be (easily) possible to write a Vue.js frontend for Opal? Or is the Angular part so deeply integrated that it can't be changed?

@davidmiller
Copy link
Member

Short answer: Possible yes, trivial no.

Longer answer: The design of Opal 0.x isn't to make front end explicitly pluggable, but to allow customisation of the front end using the components provided (in Angular). That said, the front end consumes JSON APIs, we've seen proof of concept applications use Vue.

More strategically, Angular 1.x is EOL soon, and the jump to 2.x is large enough to require a full scale rewrite. After much discussion, the current plan is to jump javascript ships to Vue, and try to reduce the overall javascript front end dependency, for Opal 1.x.

We've done some work towards this, mostly exploratory, broad conclusions are:

  • If you're going to have to rewrite anyway, Angular 2 doesn't seem like the right bet right now
  • React effectively forces you to be all SPA JS front end, without a way to progressively enhance / mix & match
  • Pure Web 2.0 Django will make it hard to to some things well that are expected of modern UX
  • Vue gives us the best balance of JS functionality where it enhances things, while allowing pages that are more straightforward to be rendered with raw Django

@fredkingham has done more Vue / Opal integration than me personally though

@nerdoc
Copy link
Contributor Author

nerdoc commented Mar 15, 2020

Ok, thanks, this looks promising. I've written a Django plugin system that should it make easy to create Django applications which consost of "modules", each containing a server part, and a frontend part - namely Vue.js - it is still not stable, but usable. I created this originally with a EMR in mind - which is my long term goal. Now that I see OPAL, I think I could bet on that too, as it does many things exactly as I wanted a system to work - except Vue as frontend ;-)
I decided to create my system more generic,and named it GDAPS: Generic Django Application Plugin System.
What I wanted to say: If you want to have a look at my project, maybe it could be of some help in OPAL too: https://gitlab.com/nerdocs/gdaps

@nerdoc
Copy link
Contributor Author

nerdoc commented Mar 24, 2020

@fredkingham ist there any code available publicly? ;-)

@fredkingham
Copy link
Contributor

fredkingham commented Mar 24, 2020 via email

@nerdoc
Copy link
Contributor Author

nerdoc commented Mar 24, 2020

In fact, I designed GDAPS for use with a EMR. And I am open for input too. You may be right that in 5+ years Vue may be replaced by the community of Js enthusiasts with AnotherAwesomeJsFramework(TM). That was my main concern using Vue, although I think it is almost perfect (except routing and vuex). But I didn't find anything else.
In medical world, we have to support development for many (and I mean MANY) years. That's the point, because all the medical record applications are so old and look as being written for MS-DOS or Win3.1 - in fact, they ARE. But: they all have long-term framework support. It works - somehow.

So your approach setting up Django with an (REST) API using FHIR is great. I tried to design GDAPS to be frontend agnostic - although the state is still early. Qt as frontend would be a good possibility too for medical applications, if it evolves and makes REST (or GraphQL?) querying easier.

So - my question should be asked better: is OPAL designed - or could it be re-designed more frontend-agnostic?

@fredkingham
Copy link
Contributor

fredkingham commented Mar 24, 2020 via email

@nerdoc
Copy link
Contributor Author

nerdoc commented Mar 24, 2020

Sure. When time-to-market is releveant then using whatever provides you with a fast solution is good. My 2 main aims are:

  • long lasting compatibility and maintainance. 30 years would be nice. (maybe a dream)
  • extensibility versus stability - both should be handled in a proper way.
    FHIR is a must IMHO, because it is/will be the de-fact- standard in near future. I would rather say theother way round as you did: GraphQL as main communication protocol between (Django) server and frontend. FHIR for interoperability with other apps, devices etc.

I think GraphQL has legs but I think json in a view rendered into the
template as arguments to vue feels like it cuts out a lot of middle men and
makes testing easier.

I didn't understand that part. did you mean JSON/Vue is a good way, or not?

@fredkingham
Copy link
Contributor

fredkingham commented Mar 25, 2020 via email

@nerdoc
Copy link
Contributor Author

nerdoc commented Mar 28, 2020

For me Vue is not a matter of rendering on the server, it's responsiveness. You can do things like you could do before with desktop applications now int a browser (or Electron). And this speeds up the user's work a lot. And to load a page fast, and load needed data later when needed is so great with GraphQL, because you have so few road-trips - you don't have to ask the server 5 times via REST.

But back to the proper theme...
OPAL having support for more than one frontend would give the project a bit more flexibility on the long term. You see how short-lived AngularJs 1 was, after a few years it is replaced with Angular2, completely incompatible. TBH, I doubt that Vue.js will be the same in 10 years. But REST will stay, and probably GraphQL too. We even have SOAP calls around in the medical world now, and pre-XML data formats like EDIFACT all over the place.
So in a fast changing world, the best bet on the long run is not to be the fastest, but to stay flexible.

@fredkingham
Copy link
Contributor

fredkingham commented Mar 30, 2020 via email

@nerdoc
Copy link
Contributor Author

nerdoc commented Mar 31, 2020

This sounds great.

  1. yes keep REST, allow a plugg...

definitely. I just wanted to state that my GDAPS project will allow more than one frontend. This could be anything, and

  1. Have a single blessed toolchain ...

for OPAL definitely,for GDAPS not...

  1. keep much on the server

definitely

  1. keep Urls on the server

partly. I think that the most important part is the API here. URLs and SSR are nice, but I think on non-HTML frontends too. Here URLs are useless - excluding API URLs.

I'm keen what is going on with your project. I don't know If I'm much of a help, but maybe. At least I'm a MD who knows a bit to code.

@andybak
Copy link

andybak commented Apr 11, 2020

Very happy to read this thread as I've just had Opal suggested for a volunteer-led project and when I saw Angular my initial reaction was to run away. (I got burnt on an Angular project a few years back and have no desire to relearn any of it)

However - does this mean it's a bad time to use the current version of Opal?

For general extensions and customisation how likely am I to need to touch Angular code? How big will the breakage be when there's a switch to Vue?

@davidmiller
Copy link
Member

davidmiller commented Apr 11, 2020

I've heard lots of people say they've been horribly burned by Angular. It's not really been my experience - the only real headache-inducing downside is the shelf life of Javascript Frameworks. This is not an Angular issue.

Your mileage will obviously vary, but it's been my experience that the things that have genuinely burned me in writing/maintaining health applications have never been 'Nouns'.

Premature Optimisation, pressure resulting in a lack of rigorous code review, unreliable upstream systems to integrate with, unstable requirements, Being Clever (c.f Premature Optimisation), pre-existing failure modes of the cultural context of users - these are things I imagine likely to burn you.

For general extensions and customisation how likely am I to need to touch Angular code?

That's not a static thing - it depends on what you want.

If you need code that runs in the client, without writing a full Single Page App that just hits API endpoints, you'll have to interact with some of the APIs that the JS framework has.

The general strategy is to limit the points of exposure to specific DOM APIs that tie you to any specific framework API. That's not an Angular strategy, it's a JS framework shelf life strategy.

A decent example is https://github.com/odonto/odonto which has reasonably complicated form validation in it (because you're submitting something to an upstream government database) - the "Angular Code" is all in here https://github.com/odonto/odonto/blob/v0.32/odonto/static/js/openodonto/controllers/check_fp17.step.controller.js
The individual validation is in here https://github.com/odonto/odonto/tree/v0.32/odonto/static/js/openodonto/services/validators

You'll notice that the bulk of the files/code doesn't know or care about the framework it's using, it's operations on data.

How big will the breakage be when there's a switch to Vue?

As small as possible, but non 0.
The core dev team will have to migrate complex production applications, so there's going to be some work put into the migration strategy.

does this mean it's a bad time to use the current version of Opal?

Very much depends what your project is - feel free to drop a line

@lawrenceadams
Copy link

Hi all,

In the same vein as the above thread - given that AngularJS is due to drop LTS in a year- is there any news on a successor to AngularJS within OPAL?

@mslourens
Copy link

What about an upgrade to Angular x on a per component basis using NgUpgrade? That way you don't have to rewrite everything and can upgrade in small increments. I can help you with that, if you want. I have a lot of experience with Angular1 and Angular 2-11.

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

No branches or pull requests

6 participants