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

RFC: Uci components #40

Closed
wants to merge 6 commits into from
Closed

RFC: Uci components #40

wants to merge 6 commits into from

Conversation

ianchi
Copy link
Collaborator

@ianchi ianchi commented May 17, 2017

This is an alternative approach to the current cbi implementation. To avoid name collisions and to keep current functionality, everything is in the "uci" prefix namespace, but eventually this should be changed.

In the current approach cbi is implemented as directives that heavily interact with each other in various ways including accessing each other's scope. The directives are responsible not only for UI interaction but also have responsibility in the workflow of persisting data to the uci files.
This makes it more difficult to build flexibility in pages definitions (some problems discussed in issue #36 ).

The idea in this alternative, is to implement the functionality but split in more isolated objects:
1.- Angular Components that manage UI interaction (switching from Directives to Components to enhance encapsulation and eventual migration to Angular2)
2.- Data model that is linked to the view to hold updated data
3.- Service that syncs model data changes to UCI files

In this way components only handle UI and use native Angular data binding to a model holding the data, no specific UCI interaction is handled here.
The data model is used to pivot with the view via the components and with the underlying UCI file via a service that handles all that interaction on any changed/added/deleted data.

Components could be defined in two ways:

  • inline in an html file with the page definition, describing each section/option with attributes (as in the example)
  • from an object holding the data (with the idea to use it for auto UCI pages - to be implemented)
    This Components also switch from Boostrap to Angular Material library.

Additionally, a wrapper around cbi validation is added in order to use the standard Angular form validation functionality, and remove all need of specific code in each component.

Up to now this is a RFC and a proof of concept, and not all functionality is implemented yet. (for instance, only reading UCI files, no saving yet)

A very simple test page is included in the menu under Tabbed - Tests - UCI

var self = this;

return function(modelValue, viewValue) {
modelCtrl.uciValidator = '';
Copy link
Owner

Choose a reason for hiding this comment

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

The double meaning of uciValidator confused me here. Within this module it appears to be both used for a uci validator instance and for the resulting error message. Maybe we should rename the message property to uciValidationResult or uciValidationMessage ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree, will change it to "uciValidationMessage"

@jow-
Copy link
Owner

jow- commented May 18, 2017

Apart from the minor nitpick above I think we should merge this and continue on top of that.

@ianchi
Copy link
Collaborator Author

ianchi commented May 18, 2017

Ok, I'll complete the work on a basic "saving" functionality, use it to create some simple config page and then merge this. (So as not to pollute the main repo with many fixes afterwards).
Meanwhile I'll keep this branch updated with the progress

ianchi added 5 commits May 23, 2017 09:28
Alternative approach to implement uci editing UI.
The idea is to split functionality in three parts:
1.- Angular Components that manage UI interaction
2.- Data model that is linked to the view to hold updated data
3.- Service that syncs model data changes to UCI files

This commit is an initial partial implementation.

Signed-off-by: Adrian Panella <[email protected]>
Basic page to test new uci components approach.

Signed-off-by: Adrian Panella <[email protected]>
Change message property in uciValidator.

Signed-off-by: Adrian Panella <[email protected]>
@ianchi
Copy link
Collaborator Author

ianchi commented May 25, 2017

Completed basic saving and reset functionality.

The workflow used when pressing the "save" button is:

  1. Save (to uci session's staging delta dir)
  2. Apply changes (with rollback true)
  3. Try to confirm changes (if this cannot go thru, the rollback mechanism will revert changes)
  4. Reset form to saved changes (to resync with any externally changed data)

It's still pending to implement all the error handling.

@ianchi ianchi mentioned this pull request Jul 14, 2017
@ianchi
Copy link
Collaborator Author

ianchi commented Aug 11, 2017

Will continue work in Angular 4 package started in #42

@ianchi ianchi closed this Aug 11, 2017
@ianchi ianchi deleted the uciComponents branch August 11, 2017 01:01
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.

2 participants