Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions zeppelin-web/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,41 @@ module.exports = function (grunt) {
// Project settings
yeoman: appConfig,


// use ngAnnotate instead og ngMin
ngAnnotate: {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}]
}
},

// lint typescript files
tslint: {
options: {
configuration: grunt.file.readJSON("tslint.json")
},
files: {
src: ['<%= yeoman.app %>/typescripts/**/*.ts']
}
},

// Watches files for changes and runs tasks based on the changed files
watch: {
bower: {
files: ['bower.json'],
tasks: ['wiredep']
},
js: {
files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
tasks: ['newer:jshint:all'],
options: {
livereload: '<%= connect.options.livereload %>'
}
},
scripts: {
files: ['<%= yeoman.app %>/scripts/ts/**/*.ts'],
tasks: ['typescript'],
files: ['<%= yeoman.app %>/typescripts/**/*.ts'],
tasks: ['typescript', 'tslint'],
options: {
spawn: false
spawn: false,
livereload: '<%= connect.options.livereload %>'
}
},
jsTest: {
Expand Down Expand Up @@ -272,20 +289,6 @@ module.exports = function (grunt) {
}
},

// ngmin tries to make the code safe for minification automatically by
// using the Angular long form for dependency injection. It doesn't work on
// things like resolve or inject so those have to be done manually.
ngmin: {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}]
}
},

// Copies remaining files to places other tasks can use
copy: {
dist: {
Expand Down Expand Up @@ -381,11 +384,11 @@ module.exports = function (grunt) {
grunt.task.run([
'clean:server',
'typescript',
'tslint',
'wiredep',
'concurrent:dist',
'autoprefixer',
'connect:livereload',
/*'newer:jshint'*/
'watch'
]);
});
Expand All @@ -407,22 +410,21 @@ module.exports = function (grunt) {
grunt.registerTask('build', [
'clean:dist',
'typescript',
'tslint',
'wiredep',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'ngmin',
'ngAnnotate',
'copy:dist',
'cssmin',
'uglify',
/*'filerev',*/
'usemin',
'htmlmin'
]);

grunt.registerTask('default', [
'newer:jshint',
/*
* Since we dont have test (or up to date) there is no reason to keep this task
* I am commented this, but can be changed in the future (if someone want to implement front tests).
Expand Down
40 changes: 21 additions & 19 deletions zeppelin-web/app/typescripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,35 @@
* limitations under the License.
*/

'use strict';

/** get the current port of the websocket
* In the case of running the zeppelin-server normally,
* The body of this function is just filler. It will be dynamically
* overridden with the zeppelin-site.xml config value when the client
* requests the script. If the config value is not defined, it defaults
* to the HTTP port + 1
*
* At the moment, the key delimiter denoting the end of this function
* during the replacement is the '}' character. Avoid using this
* character inside the function body
*
* In the case of running "grunt serve", this function will appear
* as is.
*/
/* get the current port of the websocket
* In the case of running the zeppelin-server normally,
* The body of this function is just filler. It will be dynamically
* overridden with the zeppelin-site.xml config value when the client
* requests the script. If the config value is not defined, it defaults
* to the HTTP port + 1
*
* At the moment, the key delimiter denoting the end of this function
* during the replacement is the '}' character. Avoid using this
* character inside the function body
*
* In the case of running "grunt serve", this function will appear
* as is.
*/
module zeppelin {

'use strict';

function getPort() {
var port = Number(location.port);
if (location.protocol !== 'https:' && (port === undefined || port === 0)) {
port = 80;
} else if (location.protocol == 'https:' && (port === undefined || port === 0)) {
} else if (location.protocol === 'https:' && (port === undefined || port === 0)) {
port = 443;
} else if (port == 3333 || port == 9000) {
} else if (port === 3333 || port === 9000) {
port = 8080;
}
return port+1;
return (port + 1);
}

function getWebsocketProtocol() {
Expand Down Expand Up @@ -92,7 +94,7 @@ module zeppelin {
])
.filter('breakFilter', function() {
return function (text) {
if (text !== undefined) return text.replace(/\n/g, '<br />');
if (text !== undefined) { return text.replace(/\n/g, '<br />'); }
};
})
.config(function ($routeProvider, WebSocketProvider) {
Expand Down
59 changes: 32 additions & 27 deletions zeppelin-web/app/typescripts/controllers/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

/**
* @ngdoc function
Expand All @@ -25,6 +24,9 @@
*/

module zeppelin {

'use strict';

angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope, $route, $routeParams, $location, $rootScope, $http) {

var remoteSettingToLocalSetting = function(settingId, setting) {
Expand All @@ -45,7 +47,7 @@ module zeppelin {
$http.get(restApiBase() + '/interpreter/setting').
success(function(data, status, headers, config) {
var interpreterSettings = [];
//console.log('getInterpreterSettings=%o', data);
// console.log('getInterpreterSettings=%o', data);

for (var settingId in data.body) {
var setting = data.body[settingId];
Expand Down Expand Up @@ -77,7 +79,7 @@ module zeppelin {
}

$scope.availableInterpreters = groupedInfo;
//console.log('getAvailableInterpreters=%o', data);
// console.log('getAvailableInterpreters=%o', data);
}).
error(function(data, status, headers, config) {
console.log('Error %o %o', status, data.message);
Expand All @@ -86,9 +88,9 @@ module zeppelin {

$scope.copyOriginInterpreterSettingProperties = function(settingId) {
$scope.interpreterSettingProperties = {};
for (var i=0; i < $scope.interpreterSettings.length; i++) {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if(setting.id === settingId) {
if (setting.id === settingId) {
angular.copy(setting.properties, $scope.interpreterSettingProperties);
break;
}
Expand All @@ -105,9 +107,9 @@ module zeppelin {
$scope.addNewInterpreterProperty(settingId);

var properties = {};
for (var i=0; i < $scope.interpreterSettings.length; i++) {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if(setting.id === settingId) {
if (setting.id === settingId) {
for (var p in setting.properties) {
properties[p] = setting.properties[p].value;
}
Expand All @@ -117,7 +119,7 @@ module zeppelin {

$http.put(restApiBase() + '/interpreter/setting/' + settingId, properties).
success(function(data, status, headers, config) {
for (var i=0; i < $scope.interpreterSettings.length; i++) {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if (setting.id === settingId) {
$scope.interpreterSettings.splice(i, 1);
Expand All @@ -131,10 +133,10 @@ module zeppelin {
});
};

$scope.resetInterpreterSetting = function(settingId){
for (var i=0; i<$scope.interpreterSettings.length; i++) {
$scope.resetInterpreterSetting = function(settingId) {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if (setting.id ===settingId) {
if (setting.id === settingId) {
angular.copy($scope.interpreterSettingProperties, setting.properties);
break;
}
Expand All @@ -150,7 +152,7 @@ module zeppelin {
console.log('Delete setting %o', settingId);
$http.delete(restApiBase() + '/interpreter/setting/' + settingId).
success(function(data, status, headers, config) {
for (var i=0; i < $scope.interpreterSettings.length; i++) {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if (setting.id === settingId) {
$scope.interpreterSettings.splice(i, 1);
Expand All @@ -166,7 +168,7 @@ module zeppelin {
$scope.newInterpreterGroupChange = function() {
var property = {};
var intpGroupInfo = $scope.availableInterpreters[$scope.newInterpreterSetting.group];
for (var i=0; i<intpGroupInfo.length; i++) {
for (var i = 0; i < intpGroupInfo.length; i++) {
var intpInfo = intpGroupInfo[i];
for (var key in intpInfo.properties) {
property[key] = {
Expand All @@ -186,7 +188,7 @@ module zeppelin {

$http.put(restApiBase() + '/interpreter/setting/restart/' + settingId).
success(function(data, status, headers, config) {
for (var i=0; i < $scope.interpreterSettings.length; i++) {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if (setting.id === settingId) {
$scope.interpreterSettings.splice(i, 1);
Expand All @@ -207,7 +209,7 @@ module zeppelin {
return;
}

for (var i=0; i<$scope.interpreterSettings.length; i++) {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if (setting.name === $scope.newInterpreterSetting.name) {
alert('Name ' + setting.name + ' already exists');
Expand Down Expand Up @@ -247,36 +249,35 @@ module zeppelin {
};
$scope.newInterpreterSetting.propertyValue = '';
$scope.newInterpreterSetting.propertyKey = '';
}
};

$scope.removeInterpreterProperty = function(key, settingId) {
if (settingId === undefined) {
delete $scope.newInterpreterSetting.properties[key];
}
else {
for (var i=0; i < $scope.interpreterSettings.length; i++) {
} else {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if (setting.id === settingId) {
delete $scope.interpreterSettings[i].properties[key]
delete $scope.interpreterSettings[i].properties[key];
break;
}
}
}
};

$scope.addNewInterpreterProperty = function(settingId) {
if(settingId === undefined) {
if (settingId === undefined) {
if (!$scope.newInterpreterSetting.propertyKey || $scope.newInterpreterSetting.propertyKey === '') {
return;
}
$scope.newInterpreterSetting.properties[$scope.newInterpreterSetting.propertyKey] = { value : $scope.newInterpreterSetting.propertyValue};
var property = { value : $scope.newInterpreterSetting.propertyValue };
$scope.newInterpreterSetting.properties[$scope.newInterpreterSetting.propertyKey] = property;
$scope.newInterpreterSetting.propertyValue = '';
$scope.newInterpreterSetting.propertyKey = '';
}
else {
for (var i=0; i < $scope.interpreterSettings.length; i++) {
} else {
for (var i = 0; i < $scope.interpreterSettings.length; i++) {
var setting = $scope.interpreterSettings[i];
if (setting.id === settingId){
if (setting.id === settingId) {
if (!setting.propertyKey || setting.propertyKey === '') {
return;
}
Expand All @@ -290,7 +291,11 @@ module zeppelin {
};

var init = function() {
// when interpreter page opened after seeing non-default looknfeel note, the css remains unchanged. that's what interpreter page want. Force set default looknfeel.
/*
** when interpreter page opened after seeing non-default looknfeel note,
** the css remains unchanged. that's what interpreter page want. Force set default looknfeel.
*/

$rootScope.$emit('setLookAndFeel', 'default');
$scope.interpreterSettings = [];
$scope.availableInterpreters = {};
Expand Down
7 changes: 5 additions & 2 deletions zeppelin-web/app/typescripts/controllers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

/**
* @ngdoc function
Expand All @@ -23,7 +22,11 @@
*
* @author anthonycorbacho
*/

module zeppelin {

'use strict';

export interface IZeppelinRootScope extends ng.IRootScopeService {
sendEventToServer: (event: ZEvent) => void;
}
Expand Down Expand Up @@ -100,7 +103,7 @@ module zeppelin {

$rootScope.sendEventToServer = function(event: ZEvent) {
$rootScope.$emit('sendEventToServer', event.toJson());
}
};

/** get the childs event and sebd to the websocket server */
$rootScope.$on('sendEventToServer', function(event, data) {
Expand Down
Loading