take care angular object

This commit is contained in:
Lee moon soo 2016-11-19 18:09:56 -08:00
parent 804768dfd9
commit 0156ffc89c
5 changed files with 73 additions and 8 deletions

View file

@ -28,12 +28,13 @@
'$timeout',
'saveAsService',
'ngToast',
'noteActionSrv'
'noteActionSrv',
'noteVarShareService'
];
function NotebookCtrl($scope, $route, $routeParams, $location, $rootScope,
$http, websocketMsgSrv, baseUrlSrv, $timeout, saveAsService,
ngToast, noteActionSrv) {
ngToast, noteActionSrv, noteVarShareService) {
ngToast.dismiss();
@ -87,6 +88,7 @@
/** Init the new controller */
var initNotebook = function() {
noteVarShareService.clear();
websocketMsgSrv.getNote($routeParams.noteId);
websocketMsgSrv.listRevisionHistory($routeParams.noteId);
var currentRoute = $route.current;

View file

@ -30,12 +30,13 @@
'websocketMsgSrv',
'baseUrlSrv',
'ngToast',
'saveAsService'
'saveAsService',
'noteVarShareService'
];
function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $location,
$timeout, $compile, $http, $q, websocketMsgSrv,
baseUrlSrv, ngToast, saveAsService) {
baseUrlSrv, ngToast, saveAsService, noteVarShareService) {
var ANGULAR_FUNCTION_OBJECT_NAME_PREFIX = '_Z_ANGULAR_FUNC_';
$scope.parentNote = null;
$scope.paragraph = null;
@ -116,6 +117,8 @@
$scope.paragraph.config = {};
}
noteVarShareService.put($scope.paragraph.id + '_paragraphScope', paragraphScope);
initializeDefault();
getApplicationStates();
@ -1167,7 +1170,7 @@
) {
var statusChanged = (data.paragraph.status !== $scope.paragraph.status);
var resultRefreshed = (data.paragraph.dateFinished !== $scope.paragraph.dateFinished) ||
isEmpty(data.paragraph.result) !== isEmpty($scope.paragraph.result) ||
isEmpty(data.paragraph.result) !== isEmpty($scope.paragraph.result) ||
data.paragraph.status === 'ERROR' || (data.paragraph.status === 'FINISHED' && statusChanged);
if ($scope.paragraph.text !== data.paragraph.text) {
@ -1199,6 +1202,11 @@
}
}
// resize col width
if ($scope.paragraph.config.colWidth !== data.paragraph.colWidth) {
$rootScope.$broadcast('paragraphResized', $scope.paragraph.id);
}
/** push the rest */
$scope.paragraph.aborted = data.paragraph.aborted;
$scope.paragraph.user = data.paragraph.user;

View file

@ -31,12 +31,13 @@
'websocketMsgSrv',
'baseUrlSrv',
'ngToast',
'saveAsService'
'saveAsService',
'noteVarShareService'
];
function ResultCtrl($scope, $rootScope, $route, $window, $routeParams, $location,
$timeout, $compile, $http, $q, websocketMsgSrv,
baseUrlSrv, ngToast, saveAsService) {
$timeout, $compile, $http, $q, websocketMsgSrv,
baseUrlSrv, ngToast, saveAsService, noteVarShareService) {
/**
* Built-in visualizations
@ -290,6 +291,7 @@
try {
angular.element('#p' + $scope.id + '_angular').html(data);
var paragraphScope = noteVarShareService.get(paragraph.id + '_paragraphScope');
$compile(angular.element('#p' + $scope.id + '_angular').contents())(paragraphScope);
} catch (err) {
console.log('ANGULAR rendering error %o', err);
@ -608,6 +610,16 @@
}
};
$scope.$on('paragraphResized', function(event, paragraphId) {
// paragraph col width changed
if (paragraphId === paragraph.id) {
var builtInViz = builtInVisualizations[$scope.graphMode];
if (builtInViz && builtInViz.instance) {
builtInViz.instance.resize();
}
}
});
$scope.resize = function(width, height) {
$timeout(function() {
changeHeight(width, height);

View file

@ -0,0 +1,42 @@
/*
* 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').service('noteVarShareService', noteVarShareService);
noteVarShareService.$inject = [];
function noteVarShareService() {
var store = {};
this.clear = function() {
store = {};
};
this.put = function(key, value) {
store[key] = value;
};
this.get = function(key) {
return store[key];
};
this.del = function(key) {
var v = store[key];
delete store[key];
return v;
};
};
})();

View file

@ -216,6 +216,7 @@ limitations under the License.
<script src="components/login/login.controller.js"></script>
<script src="components/elasticInputCtrl/elasticInput.controller.js"></script>
<script src="components/noteAction/noteAction.service.js"></script>
<script src="components/notevarshareService/notevarshare.service.js"></script>
<script src="components/rename/rename.controller.js"></script>
<script src="components/rename/rename.service.js"></script>
<!-- endbuild -->