Skip to content

Commit

Permalink
Merge pull request apache#196 from NFLabs/add/SVGInterpreter
Browse files Browse the repository at this point in the history
SVG interpreter
  • Loading branch information
Leemoonsoo committed Nov 11, 2014
2 parents 2e1f1a3 + 7ee3aa3 commit fafab22
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
21 changes: 20 additions & 1 deletion zeppelin-web/app/scripts/controllers/paragraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,26 @@ angular.module('zeppelinWebApp')
$scope.lastData.config = jQuery.extend(true, {}, $scope.paragraph.config);
$scope.loadTableData($scope.paragraph.result);
$scope.setGraphMode($scope.getGraphMode(), false, false);
} else if ($scope.getResultType() === 'HTML') {
$scope.renderHtml();
}
};

$scope.renderHtml = function() {
var retryRenderer = function(){
if($('#p'+$scope.paragraph.id+'_msg').length){
try {
$('#p'+$scope.paragraph.id+'_msg').html($scope.paragraph.result.msg);
} catch(err) {
console.log('HTML rendering error %o', err);
}
} else {
$timeout(retryRenderer,10);
}
};
$timeout(retryRenderer);

};

var initializeDefault = function(){
if (!$scope.paragraph.config.looknfeel) {
Expand Down Expand Up @@ -196,6 +213,8 @@ angular.module('zeppelinWebApp')
} else {
$scope.setGraphMode(newGraphMode, false, true);
}
} else if (newType==='HTML') {
$scope.renderHtml();
}
}
});
Expand Down Expand Up @@ -583,7 +602,7 @@ angular.module('zeppelinWebApp')
$scope.getBase64ImageSrc = function(base64Data) {
return 'data:image/png;base64,'+base64Data;
};

$scope.getGraphMode = function(paragraph){
var pdata = (paragraph) ? paragraph : $scope.paragraph;
if (pdata.config.graph && pdata.config.graph.mode) {
Expand Down
7 changes: 3 additions & 4 deletions zeppelin-web/app/views/paragraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,17 @@
ng-bind="paragraph.result.msg">
</div>

<div id="{{paragraph.id}}_msg"
<div id="p{{paragraph.id}}_msg"
ng-if="paragraph.result.type == 'HTML'"
ng-Init="loadResultType(paragraph.result)"
ng-bind-html="paragraph.result.msg">
ng-Init="loadResultType(paragraph.result)">
</div>

<img id="{{paragraph.id}}_msg"
ng-if="paragraph.result.type == 'IMG'"
ng-Init="loadResultType(paragraph.result)"
ng-src="{{getBase64ImageSrc(paragraph.result.msg)}}">
</img>

<div id="{{paragraph.id}}_error"
class="error"
ng-if="paragraph.status == 'ERROR'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static enum Type {
HTML,
TABLE,
IMG,
SVG,
NULL
}

Expand Down

0 comments on commit fafab22

Please sign in to comment.