initial implementation of helium menu

This commit is contained in:
Lee moon soo 2016-12-28 21:03:58 -08:00
parent 74d52d4ae8
commit 1663582138
9 changed files with 136 additions and 3 deletions

View file

@ -21,6 +21,7 @@ import com.google.gson.Gson;
import org.apache.zeppelin.helium.Helium;
import org.apache.zeppelin.helium.HeliumApplicationFactory;
import org.apache.zeppelin.helium.HeliumPackage;
import org.apache.zeppelin.helium.HeliumVisualizationFactory;
import org.apache.zeppelin.notebook.Note;
import org.apache.zeppelin.notebook.Notebook;
import org.apache.zeppelin.notebook.Paragraph;
@ -41,6 +42,7 @@ public class HeliumRestApi {
private Helium helium;
private HeliumApplicationFactory applicationFactory;
private HeliumVisualizationFactory visualizationFactory;
private Notebook notebook;
private Gson gson = new Gson();
@ -49,9 +51,11 @@ public class HeliumRestApi {
public HeliumRestApi(Helium helium,
HeliumApplicationFactory heliumApplicationFactory,
HeliumVisualizationFactory heliumVisualizationFactory,
Notebook notebook) {
this.helium = helium;
this.applicationFactory = heliumApplicationFactory;
this.visualizationFactory = heliumVisualizationFactory;
this.notebook = notebook;
}
@ -105,4 +109,11 @@ public class HeliumRestApi {
return new JsonResponse(Response.Status.OK, "", appId).build();
}
@GET
@Path("visualizations/load")
@Produces("text/javascript")
public Response visualizationLoad() {
return Response.ok("console.log(' -- vis bundle -- ');").build();
}
}

View file

@ -35,6 +35,7 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars;
import org.apache.zeppelin.dep.DependencyResolver;
import org.apache.zeppelin.helium.Helium;
import org.apache.zeppelin.helium.HeliumApplicationFactory;
import org.apache.zeppelin.helium.HeliumVisualizationFactory;
import org.apache.zeppelin.interpreter.InterpreterFactory;
import org.apache.zeppelin.notebook.Notebook;
import org.apache.zeppelin.notebook.NotebookAuthorization;
@ -83,6 +84,7 @@ public class ZeppelinServer extends Application {
public static NotebookServer notebookWsServer;
public static Helium helium;
public static HeliumApplicationFactory heliumApplicationFactory;
public static HeliumVisualizationFactory heliumVisualizationFactory;
private SchedulerFactory schedulerFactory;
private InterpreterFactory replFactory;
@ -100,6 +102,10 @@ public class ZeppelinServer extends Application {
this.helium = new Helium(conf.getHeliumConfPath(), conf.getHeliumDefaultLocalRegistryPath());
this.heliumApplicationFactory = new HeliumApplicationFactory();
this.heliumVisualizationFactory = new HeliumVisualizationFactory(
new File(conf.getRelativeDir(ConfVars.ZEPPELIN_DEP_LOCALREPO)));
this.schedulerFactory = new SchedulerFactory();
this.replFactory = new InterpreterFactory(conf, notebookWsServer,
notebookWsServer, heliumApplicationFactory, depResolver, SecurityUtils.isAuthenticated());
@ -332,7 +338,8 @@ public class ZeppelinServer extends Application {
NotebookRepoRestApi notebookRepoApi = new NotebookRepoRestApi(notebookRepo, notebookWsServer);
singletons.add(notebookRepoApi);
HeliumRestApi heliumApi = new HeliumRestApi(helium, heliumApplicationFactory, notebook);
HeliumRestApi heliumApi = new HeliumRestApi(helium, heliumApplicationFactory,
heliumVisualizationFactory, notebook);
singletons.add(heliumApi);
InterpreterRestApi interpreterApi = new InterpreterRestApi(replFactory);

View file

@ -46,13 +46,20 @@
// withCredentials when running locally via grunt
$httpProvider.defaults.withCredentials = true;
var visBundleLoad = {
load: function(heliumService) {
return heliumService.load;
}
};
$routeProvider
.when('/', {
templateUrl: 'app/home/home.html'
})
.when('/notebook/:noteId', {
templateUrl: 'app/notebook/notebook.html',
controller: 'NotebookCtrl'
controller: 'NotebookCtrl',
resolve: visBundleLoad
})
.when('/notebook/:noteId/paragraph?=:paragraphId', {
templateUrl: 'app/notebook/notebook.html',
@ -83,6 +90,10 @@
templateUrl: 'app/credential/credential.html',
controller: 'CredentialCtrl'
})
.when('/helium', {
templateUrl: 'app/helium/helium.html',
controller: 'HeliumCtrl'
})
.when('/configuration', {
templateUrl: 'app/configuration/configuration.html',
controller: 'ConfigurationCtrl'

View file

@ -0,0 +1,41 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
(function() {
angular.module('zeppelinWebApp').controller('HeliumCtrl', HeliumCtrl);
HeliumCtrl.$inject = ['$scope', '$rootScope', '$http', 'baseUrlSrv', 'ngToast'];
function HeliumCtrl($scope, $rootScope, $http, baseUrlSrv, ngToast) {
$scope.packageInfos = [];
var getAllPackageInfo = function() {
$http.get(baseUrlSrv.getRestApiBase() + '/helium/all').
success(function(data, status) {
console.log('Packages %o', data);
$scope.packageInfos = data.body;
}).
error(function(data, status) {
console.log('Can not load package info %o %o', status, data);
});
};
var init = function() {
getAllPackageInfo();
};
init();
}
})();

View file

@ -0,0 +1,45 @@
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="interpreterHead">
<div class="header">
<div class="row">
<div class="col-md-12">
<h3 class="new_h3">
Helium (Experimental)
</h3>
</div>
</div>
</div>
</div>
<div class="box width-full">
<div class="row"
ng-repeat="packageInfo in packageInfos"
style="margin-bottom:20px">
<div class="col-md-12">
<div style="height:25px">
<div style="float:left;width:20px;height:20px"
ng-bind-html=packageInfo.pkg.icon></div>
<b style="float:left">{{packageInfo.pkg.name}}</b>
<div ng-show="!packageInfo.enabled"
class="btn btn-success btn-xs"
style="float:right">Enable</div>
<div ng-show="packageInfo.enabled"
class="btn btn-info btn-xs"
style="float:right">Disable</div>
</div>
{{packageInfo.pkg.description}}
</div>
</div>
</div>

View file

@ -87,6 +87,7 @@ limitations under the License.
<li><a href="#/interpreter">Interpreter</a></li>
<li><a href="#/notebookRepos">Notebook Repos</a></li>
<li><a href="#/credential">Credential</a></li>
<li><a href="#/helium">Helium</a></li>
<li><a href="#/configuration">Configuration</a></li>
<li ng-if="ticket.principal && ticket.principal !== 'anonymous'" role="separator" style="margin: 5px 0;" class="divider"></li>
<li ng-if="ticket.principal && ticket.principal !== 'anonymous'"><a ng-click="navbar.logout()">Logout</a></li>

View file

@ -132,6 +132,15 @@ public class Helium {
return list;
}
public void enable(HeliumPackage pkg) {
}
public void disable(HeliumPackage pkg) {
}
public HeliumPackageSuggestion suggestApp(Paragraph paragraph) {
HeliumPackageSuggestion suggestion = new HeliumPackageSuggestion();

View file

@ -32,4 +32,6 @@ public class HeliumConf {
public void setRegistry(List<HeliumRegistry> registry) {
this.registry = registry;
}
// enabled visualization
}

View file

@ -1,2 +1,8 @@
console.log('vis1');
var zeppelin = zeppelin || {};
/**
* Base class for visualization
*/
zeppelin.MyVisualization = function(targetEl, config) {
this.targetEl = targetEl;