GitHub user doanduyhai opened a pull request:

    https://github.com/apache/incubator-zeppelin/pull/740

    [Zeppelin 689] Add AngularJS z object and z.angularBind()

    ### What is this PR for?
    Add client-side `z` object with method `angularBind()`
    
    @Leemoonsoo 
    
    Compared to the original implementation, I have simplified a lot.
    
    Now, you can only bind angular variable to one unique scope, which is the 
**paragraph**. I just remove the note scope and also remove the `interpreter` 
parameter. 
    
    Indeed, when passing a `paragraphId`, on the server-side, we can retrieve 
the `Paragraph` object with the `noteId` + `paragraphId` so we can now which 
interpreter is currently being used.
    
    The signature of the `angularBind(varName, value, parameters)` method has 
also been greatly simplified:
    The `parameter` is a JSON object that looks like:
    
    ```
    parameters = {
         paragraph: '20160126-153136_1060166247',
         paragraphs: ['20160126-171914_843040190', 
'20160126-181556_1915782845'],
         runParagraphs: false    
    }
    ```
    * paragraph: paragraph id used to update the angular object repository
    * paragraphs: paragraph ids used to update the angular object repository
    * runParagraphs: if true, run the paragraphs listed by the properties 
paragraph or paragraphs. Default = true  (**not implemented yet in this PR, 
will be implemented in another PR with the method `z.runParagraph()`**)
    
    
    _This is a sub-task of epic **[ZEPPELIN-635]**_
    ### What type of PR is it?
    [Improvement]
    
    ### Todos
    * [ ] - Code review
    * [ ] - Simple test
    
    ### Is there a relevant Jira issue?
    **[ZEPPELIN-689]**
    
    ### How should this be tested?
    * Create a new note
    * In the first paragraph, put the following code
    
    ```html
    %angular
    
    <form class="form-inline">
      <div class="form-group">
        <label for="superheroId">Super Hero: </label>
        <input type="text" class="form-control" id="superheroId" 
placeholder="Superhero name ..." ng-model="superhero"></input>
      </div>
      <button type="submit" class="btn btn-primary" 
        ng-click="z.angularBind('superhero', superhero, {paragraph: 
'PUT_HERE_PARAGRAPH_ID')"> Bind Angular</button>
    </form>
    ```
    * Create a second paragraph with the following code:
    
    ```scala
    z.getInterpreterContext().getParagraphId()
    z.angular("superhero")
    ````
    
    * Execute the second paragraph to retrieve its paragraph id
    * In the first paragraph, replace the text **PUT_HERE_PARAGRAPH_ID** by the 
correct paragraph id
    * In the input text, put "Superman" and click on the **Bind Angular** button
    * Execute the second paragraph to see that the _superhero_ variable is now 
set to **Superman**
    
    ### Screenshots (if appropriate)
    
![angularbind](https://cloud.githubusercontent.com/assets/1532977/13251894/3e5324aa-da33-11e5-89a9-8702cc4c08f6.gif)
    
    ### Questions:
    * Does the licenses files need update? --> **No**
    * Is there breaking changes for older versions? --> **No**
    * Does this needs documentation? --> **Yes**
    
    [ZEPPELIN-635]: https://issues.apache.org/jira/browse/ZEPPELIN-635
    [ZEPPELIN-689]: https://issues.apache.org/jira/browse/ZEPPELIN-689

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/doanduyhai/incubator-zeppelin ZEPPELIN-689

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-zeppelin/pull/740.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #740
    
----
commit b6501c77d9eb63a91e4a772acf6703603f9751a5
Author: DuyHai DOAN <doanduy...@gmail.com>
Date:   2016-02-23T10:11:40Z

    [ZEPPELIN-689] Add Thrift RPC method angularRegistryPush()

commit a4b5f7c3a56e96271328f05e436e6b60b3017262
Author: DuyHai DOAN <doanduy...@gmail.com>
Date:   2016-02-22T16:45:34Z

    [ZEPPELIN-689] Make AngularObject constructor public because of 
serialization issue

commit 5746cb73452f139d18df02bf310f3b622dbe20c5
Author: DuyHai DOAN <doanduy...@gmail.com>
Date:   2016-02-22T22:28:11Z

    [ZEPPELIN-689] ZeppelinContext angular() method should look for variable 
using the paragraph scope then note scope

commit b78d12db1b5d80bdca8d5c146c77c4f4f9ec9758
Author: DuyHai DOAN <doanduy...@gmail.com>
Date:   2016-02-23T10:01:31Z

    [ZEPPELIN-689] Implement z.angularBind() function

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to