GitHub user doanduyhai opened a pull request: https://github.com/apache/incubator-zeppelin/pull/742
[ZEPPELIN-695] Add AngularJS z.runParagraph() ### What is this PR for? Add AngularJS `z.runParagraph()` and `z.runParagraphs()` methods @corneadoug On the client-side, inside the scope of a paragraph, we cannot access to the list of all existing paragraphs for the current note. In my previous implementation, I was using the following trick: ``` var paragraphDiv = angular.element('#' + paragraphId + '_paragraphColumn_main[ng-controller="ParagraphCtrl"]'); var paragraph = paragraphDiv.scope().paragraph; ``` This is **dirty** and can be broken if we change the CSS style tomorrow for paragraph. For the current implementation, what I did is to **inject** a reference to the `note` object into the `$scope` of paragraph so that we can access the current list of paragraph **programmatically**: ```javascript $scope.$broadcast('updateParagraph', { note: $scope.note, // pass the note object to paragraph scope paragraph: note.paragraphs[index]}); ``` _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-695]** ### 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="paragraphId">Paragraph Id: </label> <input type="text" class="form-control" id="paragraphId" placeholder="Paragraph Id ..." ng-model="paragraph"></input> </div> <button type="submit" class="btn btn-primary" ng-click="z.runParagraph(paragraph)"> Run Paragraph</button> </form> ``` * Create a second paragraph with the following code: ```scala z.getInterpreterContext().getParagraphId() println("Date "+new java.util.Date().toString) ``` * Execute the second paragraph to retrieve its paragraph id * In the first paragraph, put the paragraph id in the input text and click on the **Run Paragraph** button, it should trigger execution of the second paragraph ### Screenshots (if appropriate) ![angularrunparagraph](https://cloud.githubusercontent.com/assets/1532977/13255885/8ff5c604-da48-11e5-9e1c-3216074fbb17.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-695]: https://issues.apache.org/jira/browse/ZEPPELIN-695 You can merge this pull request into a Git repository by running: $ git pull https://github.com/doanduyhai/incubator-zeppelin ZEPPELIN-695 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-zeppelin/pull/742.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 #742 ---- 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 commit f0f6f89d34a3ad123ded30179f182bf6fdb1e35b Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-23T14:20:46Z [ZEPPELIN-693] Add AngularJS z.angularUnbind() commit c3a857a3d8379188c65e41edf013ebb3b826bb49 Author: DuyHai DOAN <doanduy...@gmail.com> Date: 2016-02-23T15:07:36Z [ZEPPELIN-695] Add AngularJS z.runParagraph() ---- --- 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. ---