Skip to content

Commit

Permalink
Merge pull request #4739 from caskdata/feature/ui-hydrator-errors-fix
Browse files Browse the repository at this point in the history
Feature/ui hydrator errors fix
  • Loading branch information
ajainarayanan committed Dec 11, 2015
2 parents 8d73f29 + 4d151be commit b267c80
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cdap-ui/app/features/adapters/controllers/detail-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ angular.module(PKG.name + '.feature.adapters')
config: {
source: rAdapterDetail.config.source,
sinks: rAdapterDetail.config.sinks,
transforms: rAdapterDetail.config.transforms,
transforms: rAdapterDetail.config.transforms || [],
instances: rAdapterDetail.instance,
schedule: rAdapterDetail.config.schedule
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ angular.module(PKG.name + '.feature.adapters')
}

publicObj.source = config.source.name;
publicObj.transforms = config.transforms.map(function (n) { return n.name; });
publicObj.transforms = config.transforms || [];
publicObj.transforms = publicObj.transforms.map(function (n) { return n.name; });
publicObj.sinks = config.sinks.map(function (n) { return n.name; });

if (publicObj.programType === 'WORKFLOWS') {
Expand Down
1 change: 1 addition & 0 deletions cdap-ui/app/features/adapters/services/canvas-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ angular.module(PKG.name + '.feature.adapters')
type: GLOBALS.pluginTypes[type].source,
properties: config.source.properties
});
config.transforms = config.transforms || [];
config.transforms.forEach(function(transform) {
nodes.push({
id: transform.name + '-transform-' + (++i),
Expand Down
24 changes: 9 additions & 15 deletions cdap-ui/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,10 @@ angular
* attached to the <body> tag, mostly responsible for
* setting the className based events from $state and caskTheme
*/
.controller('BodyCtrl', function ($scope, $cookies, $cookieStore, caskTheme, CASK_THEME_EVENT, $rootScope, $state, $log, MYSOCKET_EVENT, MyDataSource, MY_CONFIG, MYAUTH_EVENT) {
.controller('BodyCtrl', function ($scope, $rootScope, $state, caskTheme, $log, MYSOCKET_EVENT, MyDataSource, MY_CONFIG, myAuth, MYAUTH_EVENT) {

var activeThemeClass = caskTheme.getClassName();
var dataSource = new MyDataSource($scope);
if (MY_CONFIG.securityEnabled) {
$rootScope.$on(MYAUTH_EVENT.loginSuccess, getVersion);
} else {
getVersion();
}

function getVersion() {
dataSource.request({
_cdapPath: '/version'
Expand All @@ -262,15 +256,15 @@ angular
});
}

$scope.$on(CASK_THEME_EVENT.changed, function (event, newClassName) {
if(!event.defaultPrevented) {
$scope.bodyClass = $scope.bodyClass.replace(activeThemeClass, newClassName);
activeThemeClass = newClassName;
if (MY_CONFIG.securityEnabled) {
if (myAuth.isAuthenticated()) {
getVersion();
} else {
$rootScope.$on(MYAUTH_EVENT.loginSuccess, getVersion);
}
});



} else {
getVersion();
}

$scope.$on('$stateChangeSuccess', function (event, state) {
var classes = [];
Expand Down
1 change: 1 addition & 0 deletions cdap-ui/app/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.run(function ($location, $state, $rootScope, myAuth, MYAUTH_EVENT, MYAUTH

var user = myAuth.isAuthenticated();
if (user) { // user is logged in
// $rootScope.$broadcast(MYAUTH_EVENT.loginSuccess);
if (authorizedRoles === MYAUTH_ROLE.all) { return; } // any logged-in user is welcome
if (user.hasRole(authorizedRoles)) { return; } // user is legit
}
Expand Down
16 changes: 11 additions & 5 deletions cdap-ui/app/services/status-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
angular.module(PKG.name + '.services')
.service('StatusFactory', function($http, EventPipe, myAuth, $rootScope, MYAUTH_EVENT, MY_CONFIG, $alert, $timeout) {

this.toPoll = true;
this.startPolling = function () {
$rootScope.$on(MYAUTH_EVENT.logoutSuccess, this.stopPolling.bind(this));
beginPolling.bind(this)();
};
function beginPolling() {
this.stopPolling = function() {
this.toPoll = false;
};

function beginPolling() {
_.debounce(function() {
$http.get(
(MY_CONFIG.sslEnabled? 'https://': 'http://') + window.location.host + '/backendstatus',
Expand All @@ -30,16 +35,17 @@ angular.module(PKG.name + '.services')
.success(success.bind(this))
.error(error.bind(this));
}.bind(this), 2000)();

}

function success() {
EventPipe.emit('backendUp');
this.startPolling();
if (this.toPoll) {
EventPipe.emit('backendUp');
this.startPolling();
}
}

function error(err) {
if (!reAuthenticate(err)) {
if (this.stopPoll && !reAuthenticate(err)) {
this.startPolling();
EventPipe.emit('backendDown');
}
Expand Down

0 comments on commit b267c80

Please sign in to comment.