-
Notifications
You must be signed in to change notification settings - Fork 26
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
RFC: framework next steps #42
Conversation
Hi @ianchi @gmarcos87 and @jow- I wanted to give my two cents on this, based on the approach we had on the implementation Marcos is running. TL;DR Would vote on (3) because of the low storage footprint, that being 'without batteries included' (aka: you pick what libraries you want) makes it more lean The features we were looking for from a framework for our mobile app were:
We came from an AngularJS/Ionic background, so it was natural for Marcos and I to try to go through that path (also, a lot of things were already sorted out)... but... we ended up realizing that that approach just couldn't scale... The storage footprint mainly was the decisive factor... I don't have the exact figures, but I think the smallest we could shrink the app was ~600kb (marcos, can you clarify this?). So, Marcos searched for some other solution, and he came with the idea of doing it with Preact+Redux... as he had been using Redux for the Ionic app... the migration required just to work on the view side. The result... right now with Leaflet included (a Map library that is pretty heavy) the bundle is at 250kb, and keeps going down. Once he started developing, he saw some opportunities in generalizing the code, to make it Customizable, it is implemented in such a way that every functionality you add is added via plugins. Understanding you come from an Angular background as us, I'm sure once you experience it we will reach to the same conclusion (or have a very interesting conversation around the topic :) ). Regards, |
Hi @nicopace, I completely agree with the list of features you state. But I still fail to see why this requires switching away from Angular. Right now, the configuration in this PR gives a bundle of about 280kb gziped (*). I know there are still features missing, but also no work on optimizing the bundle. So I assume that the final code should be even smaller than that. (There is still much room for dead code elimination, I'll do a simple try switching from Webpack to Rollup in the building system when I have some time). Anyway, I couldn't find any repo with the app you are talking about. In our chat @marcos87 pointed me at lime-ui-ng, but I couldn't find any development of the actual client side UI there. Please, could you refer me to the correct project, so I could take a look. Regards (*) If you build it, it's actually much bigger, but only because in this playground I was lazy and included the whole MDI svg Icons, which are more than 2000 unused icons and 210kb gziped. Using luci2-ui-base as reference, which was stripped to only the used ones, adds less than 2kb. |
@jow- just by chance I came along this (prophetic?/seasoned?) post of yours from 6 months ago in the Lede Forum:
Sadly, and a bit depressing, 6 months later we are still stuck in the same discussions.... :-( |
So, let's change approach and focus on what we do agree on, so that we can start building forward: From our last chat I recall:
My comments on these topics: This leaves 3), and here we should try to define the JSON interface that we will use. Last year I sent PR #24 with a RFC for this same idea. It was a very basic first approach and being almost a year old it is a bit outdated, but perhaps we can use it to trigger the discussion. Please take a look specially at the schema definition I think an app/view needs at least to have these data defined in one or more json files: There are a lot of possibilities here and many aspects to consider. So looking just in a general way, I think that the definitions could be split in two aspects:
Please, @jow- @nicopace @marcos87 can you share your views on these topics. |
Hi @ianchi, I agree with your comments. I was watching the version of what you did in Angular2 (very significant decrease in final size, good job!) and these days I am uploading a version almost similar in Preact as a proof of concept. In a design where the views are defined by json, the widgets are especially important. Especially for specific functionalities. I think that having a kind of repository of widgets (for reuse) can be interesting, even think that a widget can be programmed for different consumptions (terminal, web in different flavors, mobile, etc). For UCI we could think of a default view for methods that do not have a specific schema (a simple form). We are currently working on orange-rpc (for web sockets), but we are adding the methods of our application to UBUS. The idea is to migrate to UBUS, even more if you are planning to support WebSocket in the not too distant future. :) |
I integrated the concepts of #40 and #24 adding basic UCI capabilities. As next step I think we should define what an Note: as this is still a dev playground, with no installation in the Lede box, it displays the menu items received from the router, but that doesn't correspond to the currently available pages. They are hardcoded as follows: |
So maybe we should decouple the entire schematic approach from the actual UCI configuration but instead let the schema describe the structure of an expected nested JSON object which can be provided through different means with a straight UCI values to JSON mapping just being one of several possibilities. This way, the view or model layer can assemble an intermediate data model representing system state from various sources like different UCI files, runtime information etc. which is then rendered into a form according to the ui schema declared for the particular view. Regarding the structure of views I support an approach which divides every page into three areas, each of them optional:
|
I agree. Regarding points 1 and 2, they should get worked in parallel, mainly outside this repo and eventually merge some changes here. Point 3, needs to be worked on here. In a few days I will send a separate PR with an initial proposal, trying to integrate all the comments so far, and we continue the specific discussion over there. So, this leaves the current PR to the initial topic of the framework choice. As stated before, I don't see any need to switch away from Angular. This PR already builds an app that is about 245kb gziped, and there is plenty of room for improvement. The Angular team is actively working on solving some tree shaking problems, and so eventually I believe the app should be below the 200kb threshold. |
Update: the gziped app now is only 185kb @gmarcos87 @nicopace I believe that the original size concerns that triggered the proposition to move out of Angular are now covered, and so there shouldn't be a reason to change framework. Please comment |
We could say that the size is sorted out, congrats! |
Hello, I tried to compile the pull request but give me other results. The build now in row is 1.9mb and compressed 470.3kb. I get it by doing |
@gmarcos87 the difference in size comes from two reasons:
Additionally, you have to change the build command to enable proper tree shaking:
Sorry I didn't include it in the scripts. |
Regarding next steps, I think that if we all agree to go for an approach where views/apps are completely defined in json, independent of the implementation in the client, what we need to do first is to discuss a little more in detail how this json files will be, so that we came with the best approach before starting to implement it. |
Create new package ui-core and set up environment for the app using Angular 4 + Material 2. Signed-off-by: Adrian Panella <[email protected]>
Initial migrations of ui-base to Angular 4 Signed-off-by: Adrian Panella <[email protected]>
2776b2c
to
759976d
Compare
Signed-off-by: Adrian Panella <[email protected]>
This is my personal "playground" and not really ready to be merged, but I'm sharing it to prompt the discussion.
I've been toying with four different topics:
A) Upgrading framework to Angular 4 + Material 2 (and building tools to Angular-Cli)
B) creating a Directive/Component to easily integrate ubus calls in a declarative way into HTML templates, without the need of js code
C) a Dashboard, as the main page. With the intention to find a structure that can be used to define individual widgets as JSON data
D) Theming
I have made some advances in all these aspects only to the point of having just some working proof of concept. (To try it out, some instructions on the README.md). Some screenshots small / large
Anyway, @jow- / @gmarcos87 after our last conversation I've halted further coding, until we agree on the basics. The most urgent topic is the framework choice, we must settle this asap.
At the moment we have three options:
My opinion:
I think 1) is not worth, as those versions are already in EOL stage, and regardless of the needed rework I think it is better to change now.
Regarding 2 vs 3 I think that there aren't any clear technical advantages, and that it mostly reduces to "personal preference".
Perhaps the most "objective" measurement could be "size", where we should add some complementary libraries to Preact, as it is not a full framework and doesn't cover the same functionality.
But regarding size, I think that we should set a Target (like the 300-350kb ipk, that we already talked), and it can be achieved with any of both.
Given my "A" playground topic, I think it is obvious which my personal preference is. ;-)
Please, speak up your mind, so that after some constructive discussion we can reach an agreement, and resume development.