fix(panel): handle refresh better

master
Brian Ford 10 years ago
parent ca0dc695e5
commit f2a9044e3b

@ -63,6 +63,7 @@ function inspectedAppService($rootScope, $q) {
$rootScope.$applyAsync(function () { $rootScope.$applyAsync(function () {
if (msg === 'refresh') { if (msg === 'refresh') {
onRefreshMessage(); onRefreshMessage();
$rootScope.$broadcast('refresh');
} else if (typeof msg === 'string') { } else if (typeof msg === 'string') {
var hint = JSON.parse(msg); var hint = JSON.parse(msg);
onHintMessage(hint); onHintMessage(hint);

@ -42,6 +42,13 @@ function batJsonTreeDirective() {
scope.$watch('batModel', function (val) { scope.$watch('batModel', function (val) {
if (!val) { if (!val) {
root = angular.element(BAT_JSON_TREE_TEMPLATE);
element.html('');
element.append(root);
branches = {
'': root
};
return; return;
} }
Object. Object.

@ -36,6 +36,11 @@ function batScopeTreeDirective($compile) {
renderScopeDescriptorElement(data.id, data.descriptor); renderScopeDescriptorElement(data.id, data.descriptor);
}); });
scope.$on('refresh', function () {
map = {};
element.html('');
});
function renderScopeElement (id, parentId) { function renderScopeElement (id, parentId) {
if (map[id]) { if (map[id]) {
return; return;

@ -16,13 +16,18 @@ function ScopesController($scope, inspectedApp) {
$scope.inspectedScope = null; $scope.inspectedScope = null;
$scope.$on('refresh', function () {
$scope.inspectedScope = null;
});
// expand models the fist time we inspect a scope // expand models the fist time we inspect a scope
var cancelWatch = $scope.$watch('inspectedScope', function (newScope) { var cancelWatch = $scope.$watch('inspectedScope', function (newScope) {
if (newScope) { if (newScope) {
$scope.modelsExpanded = true; $scope.modelsExpanded = true;
cancelWatch(); cancelWatch();
} }
}) });
$scope.$on('inspected-scope:change', function (ev, data) { $scope.$on('inspected-scope:change', function (ev, data) {
inspectScope(data.id); inspectScope(data.id);