[ZEPPELIN-695] Add AngularJS z.runParagraph()#742
Conversation
6c71951 to
eeaf137
Compare
eeaf137 to
3a3e4cc
Compare
46430ac to
b4b9314
Compare
|
Just rebased from master, can be merged quickly, only JS code change |
|
Tested and working well. Do you mind add a test? |
b4b9314 to
cf0e6e4
Compare
|
@Leemoonsoo Done, I have added |
|
@doanduyhai Great. LGTM and merge if there're no more discussions. |
|
Is this feature going to available in 0.6 snapshot soon. I am using the click button example from the doc and z.run("20160326-184416_217725826" ) in click function. But for some reason the click works only once. https://zeppelin.incubator.apache.org/docs/0.6.0-incubating-SNAPSHOT/displaysystem/angular.html My code is here. https://github.com/deepakas/zeppelin-gallery/tree/master/wikigraphvis/notebook |
|
@deepakas as soon as this PR will be merged, you can start playing with it by building the master yourself |
### What is this PR for?
Add AngularJS `z.runParagraph()` method
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]});
```
```html
<div id="{{currentParagraph.id}}_paragraphColumn_main"
ng-repeat="currentParagraph in note.paragraphs"
ng-controller="ParagraphCtrl"
ng-Init="init(currentParagraph, note)"
```
_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?
* `git fetch origin pull/742/head:AngularJSRunParagraph`
* `git checkout AngularJSRunParagraph`
* `mvn clean package -DskipTests`
* `bin/zeppelin-daemon.sh restart`
* 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
println("Date "+new java.util.Date().toString)
```
* Retrieve the paragraph id of the 2nd paragraph
* 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)

### 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
Author: DuyHai DOAN <doanduyhai@gmail.com>
Closes apache#742 from doanduyhai/ZEPPELIN-695 and squashes the following commits:
cf0e6e4 [DuyHai DOAN] [ZEPPELIN-695] Add AngularJS z.runParagraph()
What is this PR for?
Add AngularJS
z.runParagraph()method@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:
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
noteobject into the$scopeof paragraph so that we can access the current list of paragraph programmatically:This is a sub-task of epic ZEPPELIN-635
What type of PR is it?
[Improvement### Todos
Is there a relevant Jira issue?
ZEPPELIN-695
How should this be tested?
git fetch origin pull/742/head:AngularJSRunParagraphgit checkout AngularJSRunParagraphmvn clean package -DskipTestsbin/zeppelin-daemon.sh restartScreenshots (if appropriate)
Questions: