Skip to content

Commit 98f1809

Browse files
committed
Merge pull request pinpoint-apm#1664 from denzelsN/master
bug fix.
2 parents df281b5 + 7809d82 commit 98f1809

File tree

5 files changed

+35
-38
lines changed

5 files changed

+35
-38
lines changed

web/src/main/webapp/common/services/preference.service.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
*/
1010
pinpointApp.constant('PreferenceServiceConfig', {
1111
names: {
12-
caller: "preference.caller",
13-
callee: "preference.callee",
14-
period: "preference.period",
1512
favorite: "preference.favorite"
1613
},
1714
defaults: {
@@ -62,7 +59,7 @@
6259
setFavoriteList();
6360
};
6461
function setFavoriteList() {
65-
localStorage.setItem(cfg.names.favorite, JSON.stringify(aFavoriteList) );
62+
webStorage.add(cfg.names.favorite, JSON.stringify(aFavoriteList) );
6663
}
6764
this.getFavoriteList = function() {
6865
return aFavoriteList;
@@ -95,28 +92,34 @@
9592
});
9693
return o;
9794
};
98-
this.getCalleeFromStorage = function(app) {
95+
this.getCalleeByApp = function(app) {
9996
if ( angular.isUndefined( app ) ) {
10097
return this.getCallee();
10198
} else {
10299
return webStorage.get( app + "+callee" ) || this.getCallee();
103100
}
104101
};
105-
this.getCallerFromStorage = function(app) {
102+
this.getCallerByApp = function(app) {
106103
if ( angular.isUndefined( app ) ) {
107104
return this.getCaller();
108105
} else {
109106
return webStorage.get(app + "+caller") || this.getCaller();
110107
}
111108
};
109+
this.setDepthByApp = function( app, depth ) {
110+
if (angular.isUndefined(app) || app === null || angular.isUndefined(depth) || depth === null) {
111+
return;
112+
}
113+
webStorage.add(app, depth);
114+
};
112115

113116

114117
function loadPreference() {
115-
// set value of localStoraget or default
116-
// and set getter and setter function
118+
// set value of webStorage or default
119+
// and make getter and setter function
117120
jQuery.each( cfg.list, function( index, value ) {
118121
var name = value.name;
119-
oDefault[name] = localStorage.getItem( name ) || cfg.defaults[name];
122+
oDefault[name] = webStorage.get( name ) || cfg.defaults[name];
120123
switch( value.type ) {
121124
case "number":
122125
oDefault[name] = parseInt( oDefault[name] );
@@ -127,11 +130,11 @@
127130
return oDefault[name];
128131
};
129132
self["set" + fnPostfix] = function(v) {
130-
localStorage.setItem(name, v);
133+
webStorage.add(name, v);
131134
oDefault[name] = v;
132135
};
133136
});
134-
aFavoriteList = JSON.parse( localStorage.getItem(cfg.names.favorite) || "[]");
137+
aFavoriteList = webStorage.get(cfg.names.favorite) || [];
135138
}
136139

137140
}]);

web/src/main/webapp/features/navbar/navbar.directive.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@
3535

3636
var applicationResource;
3737

38-
var setDepthToStorage = function(app, depth) {
39-
if (angular.isUndefined(app) || app === null || angular.isUndefined(depth) || depth === null) {
40-
return;
41-
}
42-
webStorage.add(app, depth);
43-
};
4438
scope.showNavbar = false;
4539
scope.periodDelay = false;
4640
scope.aReadablePeriodList = preferenceService.getPeriodTypes();
@@ -65,8 +59,8 @@
6559
label: '1 minute'
6660
}
6761
];
68-
scope.callee = prevCallee = preferenceService.getCalleeFromStorage( scope.application );
69-
scope.caller = prevCaller = preferenceService.getCallerFromStorage( scope.application );
62+
scope.callee = prevCallee = preferenceService.getCalleeByApp( scope.application );
63+
scope.caller = prevCaller = preferenceService.getCallerByApp( scope.application );
7064
scope.rangeList = preferenceService.getDepthList();
7165
scope.applications = [
7266
{
@@ -119,10 +113,10 @@
119113
}
120114
];
121115
scope.application = oNavbarVoService.getApplication() || "";
122-
if ( scope.application !== "" ) {
123-
scope.callee = prevCallee = preferenceService.getCalleeFromStorage( scope.application );
124-
scope.caller = prevCaller = preferenceService.getCallerFromStorage( scope.application );
125-
}
116+
// if ( scope.application !== "" ) {
117+
scope.callee = prevCallee = preferenceService.getCalleeByApp( scope.application );
118+
scope.caller = prevCaller = preferenceService.getCallerByApp( scope.application );
119+
// }
126120
scope.disableApplication = true;
127121
scope.readablePeriod = oNavbarVoService.getReadablePeriod() || preferenceService.getPeriod();
128122
scope.periodCalendar = oNavbarVoService.getReadablePeriod() || preferenceService.getPeriod();
@@ -299,8 +293,8 @@
299293
}
300294
oNavbarVoService.setApplication(scope.application);
301295

302-
scope.callee = preferenceService.getCalleeFromStorage(scope.application);
303-
scope.caller = preferenceService.getCallerFromStorage(scope.application);
296+
scope.callee = prevCallee = preferenceService.getCalleeByApp(scope.application);
297+
scope.caller = prevCaller = preferenceService.getCallerByApp(scope.application);
304298

305299
oNavbarVoService.setCalleeRange( scope.callee );
306300
oNavbarVoService.setCallerRange( scope.caller );
@@ -630,11 +624,11 @@
630624
analyticsService.send(analyticsService.CONST.MAIN, analyticsService.CONST.CLK_CALLER_RANGE, scope.caller);
631625
prevCallee = scope.callee;
632626
prevCaller = scope.caller;
633-
setDepthToStorage( scope.application + "+callee", scope.callee );
634-
setDepthToStorage( scope.application + "+caller", scope.caller );
635-
627+
preferenceService.setDepthByApp( scope.application + "+callee", scope.callee );
628+
preferenceService.setDepthByApp( scope.application + "+caller", scope.caller );
629+
636630
window.location.reload(true);
637-
//broadcast();
631+
// broadcast();
638632
}
639633
};
640634
scope.cancelDepth = function( bHide ) {

web/src/main/webapp/lib/js/pinpoint.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/main/webapp/lib/js/pinpoint.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/main/webapp/pages/main/main.controller.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @name MainCtrl
88
* @class
99
*/
10-
pinpointApp.controller( "MainCtrl", [ "filterConfig", "$route", "$scope", "$timeout", "$routeParams", "locationService", "NavbarVoService", "$window", "SidebarTitleVoService", "filteredMapUtilService", "$rootElement", "AnalyticsService", "PreferenceService",
11-
function (cfg, $route, $scope, $timeout, $routeParams, locationService, NavbarVoService, $window, SidebarTitleVoService, filteredMapUtilService, $rootElement, analyticsService, preferenceService) {
10+
pinpointApp.controller( "MainCtrl", [ "filterConfig", "$scope", "$timeout", "$routeParams", "locationService", "NavbarVoService", "$window", "SidebarTitleVoService", "filteredMapUtilService", "$rootElement", "AnalyticsService", "PreferenceService",
11+
function (cfg, $scope, $timeout, $routeParams, locationService, NavbarVoService, $window, SidebarTitleVoService, filteredMapUtilService, $rootElement, analyticsService, preferenceService) {
1212
analyticsService.send(analyticsService.CONST.MAIN_PAGE);
1313
// define private variables
1414
var oNavbarVoService, bNodeSelected, bNoData;
@@ -38,8 +38,8 @@
3838
if ($routeParams.queryEndDateTime) {
3939
oNavbarVoService.setQueryEndDateTime($routeParams.queryEndDateTime);
4040
}
41-
oNavbarVoService.setCalleeRange( preferenceService.getCalleeFromStorage($routeParams.application) );
42-
oNavbarVoService.setCallerRange( preferenceService.getCallerFromStorage($routeParams.application) );
41+
oNavbarVoService.setCalleeRange( preferenceService.getCalleeByApp($routeParams.application) );
42+
oNavbarVoService.setCallerRange( preferenceService.getCallerByApp($routeParams.application) );
4343

4444
if ( oNavbarVoService.isRealtime() ) {
4545
$scope.$broadcast('navbarDirective.initialize.realtime.andReload', oNavbarVoService);

0 commit comments

Comments
 (0)