Commit 28e4fc16 by Jason Song Committed by GitHub

Merge pull request #430 from lepdou/index_page_refactor

bugfix:add illegal appId to visited app list
parents c57a690b 174a4c75
...@@ -13,7 +13,7 @@ public interface FavoriteRepository extends PagingAndSortingRepository<Favorite, ...@@ -13,7 +13,7 @@ public interface FavoriteRepository extends PagingAndSortingRepository<Favorite,
List<Favorite> findByAppIdOrderByPositionAscDataChangeCreatedTimeAsc(String appId, Pageable page); List<Favorite> findByAppIdOrderByPositionAscDataChangeCreatedTimeAsc(String appId, Pageable page);
Favorite findFirst1ByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(String userId); Favorite findFirstByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(String userId);
Favorite findByUserIdAndAppId(String userId, String appId); Favorite findByUserIdAndAppId(String userId, String appId);
} }
...@@ -91,7 +91,7 @@ public class FavoriteService { ...@@ -91,7 +91,7 @@ public class FavoriteService {
checkUserOperatePermission(favorite); checkUserOperatePermission(favorite);
String userId = favorite.getUserId(); String userId = favorite.getUserId();
Favorite firstFavorite = favoriteRepository.findFirst1ByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(userId); Favorite firstFavorite = favoriteRepository.findFirstByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(userId);
long minPosition = firstFavorite.getPosition(); long minPosition = firstFavorite.getPosition();
favorite.setPosition(minPosition - 1); favorite.setPosition(minPosition - 1);
......
...@@ -25,50 +25,15 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer ...@@ -25,50 +25,15 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer
UserService.load_user().then(function (result) { UserService.load_user().then(function (result) {
$rootScope.pageContext.userId = result.userId; $rootScope.pageContext.userId = result.userId;
loadAppInfo();
handleFavorite(); handleFavorite();
recordVisitApp(); },function (result) {
toastr.error(AppUtil.errorMsg(result), "获取用户登录信息失败");
}); });
loadAppInfo();
handlePermission(); handlePermission();
} }
function recordVisitApp() {
//save user recent visited apps
var VISITED_APPS_STORAGE_KEY = "VisitedAppsV2";
var visitedAppsObject = JSON.parse(localStorage.getItem(VISITED_APPS_STORAGE_KEY));
var hasSaved = false;
if (visitedAppsObject) {
var visitedApps = visitedAppsObject[$rootScope.pageContext.userId];
if (visitedApps && visitedApps.length > 0){
visitedApps.forEach(function (app) {
if (app == appId) {
hasSaved = true;
return;
}
});
}
} else {
visitedAppsObject = {};
visitedAppsObject[$rootScope.pageContext.userId] = [];
}
var currentUserVisitedApps = visitedAppsObject[$rootScope.pageContext.userId];
if (!hasSaved) {
//if queue's length bigger than 6 will remove oldest app
if (currentUserVisitedApps.length >= 6){
currentUserVisitedApps.splice(0, 1);
}
currentUserVisitedApps.push($rootScope.pageContext.appId);
localStorage.setItem(VISITED_APPS_STORAGE_KEY,
JSON.stringify(visitedAppsObject));
}
}
function loadAppInfo() { function loadAppInfo() {
$scope.notFoundApp = true; $scope.notFoundApp = true;
AppService.load($rootScope.pageContext.appId).then(function (result) { AppService.load($rootScope.pageContext.appId).then(function (result) {
...@@ -78,6 +43,7 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer ...@@ -78,6 +43,7 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer
$scope.appBaseInfo.orgInfo = result.orgName + '(' + result.orgId + ')'; $scope.appBaseInfo.orgInfo = result.orgName + '(' + result.orgId + ')';
loadNavTree(); loadNavTree();
recordVisitApp();
$(".J_appFound").removeClass("hidden"); $(".J_appFound").removeClass("hidden");
}, function (result) { }, function (result) {
...@@ -112,6 +78,41 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer ...@@ -112,6 +78,41 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer
}; };
} }
function recordVisitApp() {
//save user recent visited apps
var VISITED_APPS_STORAGE_KEY = "VisitedAppsV2";
var visitedAppsObject = JSON.parse(localStorage.getItem(VISITED_APPS_STORAGE_KEY));
var hasSaved = false;
if (visitedAppsObject) {
var visitedApps = visitedAppsObject[$rootScope.pageContext.userId];
if (visitedApps && visitedApps.length > 0) {
visitedApps.forEach(function (app) {
if (app == appId) {
hasSaved = true;
return;
}
});
}
} else {
visitedAppsObject = {};
visitedAppsObject[$rootScope.pageContext.userId] = [];
}
var currentUserVisitedApps = visitedAppsObject[$rootScope.pageContext.userId];
if (!hasSaved) {
//if queue's length bigger than 6 will remove oldest app
if (currentUserVisitedApps.length >= 6) {
currentUserVisitedApps.splice(0, 1);
}
currentUserVisitedApps.push($rootScope.pageContext.appId);
localStorage.setItem(VISITED_APPS_STORAGE_KEY,
JSON.stringify(visitedAppsObject));
}
}
function loadNavTree() { function loadNavTree() {
AppService.load_nav_tree($rootScope.pageContext.appId).then(function (result) { AppService.load_nav_tree($rootScope.pageContext.appId).then(function (result) {
var navTree = []; var navTree = [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment