Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
28e4fc16
Commit
28e4fc16
authored
Oct 12, 2016
by
Jason Song
Committed by
GitHub
Oct 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #430 from lepdou/index_page_refactor
bugfix:add illegal appId to visited app list
parents
c57a690b
174a4c75
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
42 deletions
+43
-42
FavoriteRepository.java
...ramework/apollo/portal/repository/FavoriteRepository.java
+1
-1
FavoriteService.java
...trip/framework/apollo/portal/service/FavoriteService.java
+1
-1
ConfigBaseInfoController.js
...tic/scripts/controller/config/ConfigBaseInfoController.js
+41
-40
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/repository/FavoriteRepository.java
View file @
28e4fc16
...
...
@@ -13,7 +13,7 @@ public interface FavoriteRepository extends PagingAndSortingRepository<Favorite,
List
<
Favorite
>
findByAppIdOrderByPositionAscDataChangeCreatedTimeAsc
(
String
appId
,
Pageable
page
);
Favorite
findFirst
1
ByUserIdOrderByPositionAscDataChangeCreatedTimeAsc
(
String
userId
);
Favorite
findFirstByUserIdOrderByPositionAscDataChangeCreatedTimeAsc
(
String
userId
);
Favorite
findByUserIdAndAppId
(
String
userId
,
String
appId
);
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java
View file @
28e4fc16
...
...
@@ -91,7 +91,7 @@ public class FavoriteService {
checkUserOperatePermission
(
favorite
);
String
userId
=
favorite
.
getUserId
();
Favorite
firstFavorite
=
favoriteRepository
.
findFirst
1
ByUserIdOrderByPositionAscDataChangeCreatedTimeAsc
(
userId
);
Favorite
firstFavorite
=
favoriteRepository
.
findFirstByUserIdOrderByPositionAscDataChangeCreatedTimeAsc
(
userId
);
long
minPosition
=
firstFavorite
.
getPosition
();
favorite
.
setPosition
(
minPosition
-
1
);
...
...
apollo-portal/src/main/resources/static/scripts/controller/config/ConfigBaseInfoController.js
View file @
28e4fc16
...
...
@@ -25,50 +25,15 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer
UserService
.
load_user
().
then
(
function
(
result
)
{
$rootScope
.
pageContext
.
userId
=
result
.
userId
;
loadAppInfo
();
handleFavorite
();
recordVisitApp
();
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"获取用户登录信息失败"
);
});
loadAppInfo
();
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
()
{
$scope
.
notFoundApp
=
true
;
AppService
.
load
(
$rootScope
.
pageContext
.
appId
).
then
(
function
(
result
)
{
...
...
@@ -78,6 +43,7 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer
$scope
.
appBaseInfo
.
orgInfo
=
result
.
orgName
+
'('
+
result
.
orgId
+
')'
;
loadNavTree
();
recordVisitApp
();
$
(
".J_appFound"
).
removeClass
(
"hidden"
);
},
function
(
result
)
{
...
...
@@ -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
()
{
AppService
.
load_nav_tree
(
$rootScope
.
pageContext
.
appId
).
then
(
function
(
result
)
{
var
navTree
=
[];
...
...
@@ -152,7 +153,7 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer
//default selection from session storage or first env & first cluster
if
(
$rootScope
.
pageContext
.
env
==
env
.
env
&&
$rootScope
.
pageContext
.
clusterName
==
cluster
.
name
)
{
==
cluster
.
name
)
{
clusterNode
.
state
=
{};
clusterNode
.
state
.
selected
=
true
;
}
...
...
@@ -227,7 +228,7 @@ function ConfigBaseInfoController($rootScope, $scope, $location, toastr, UserSer
function
handleFavorite
()
{
FavoriteService
.
findFavorites
(
$rootScope
.
pageContext
.
userId
,
$rootScope
.
pageContext
.
appId
)
$rootScope
.
pageContext
.
appId
)
.
then
(
function
(
result
)
{
if
(
result
&&
result
.
length
)
{
$scope
.
favoriteId
=
result
[
0
].
id
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment