Skip to content

Commit

Permalink
Merge pull request apolloconfig#528 from lepdou/url
Browse files Browse the repository at this point in the history
append page context info to url
  • Loading branch information
nobodyiam authored Jan 22, 2017
2 parents 64a609a + 71c0522 commit cac111a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr
PermissionService,
AppUtil) {

var appId = AppUtil.parseParams($location.$$url).appid;
var urlParams = AppUtil.parseParams($location.$$url);
var appId = urlParams.appid;

if (!appId) {
$window.location.href = '/index.html';
Expand All @@ -23,12 +24,21 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr

//load session storage to recovery scene
var scene = JSON.parse(sessionStorage.getItem(appId));

$rootScope.pageContext = {
appId: appId,
env: scene ? scene.env : '',
clusterName: scene ? scene.cluster : 'default'
env: urlParams.env ? urlParams.env : (scene ? scene.env : ''),
clusterName: urlParams.cluster ? urlParams.cluster : (scene ? scene.cluster : 'default')
};

//storage page context to session storage
sessionStorage.setItem(
$rootScope.pageContext.appId,
JSON.stringify({
env: $rootScope.pageContext.env,
cluster: $rootScope.pageContext.clusterName
}));

UserService.load_user().then(function (result) {
$rootScope.pageContext.userId = result.userId;
loadAppInfo();
Expand Down Expand Up @@ -211,6 +221,11 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr
cluster: $rootScope.pageContext.clusterName
}));

$window.location.href = "/config.html#/appid="
+ $rootScope.pageContext.appId
+ "&env=" + $rootScope.pageContext.env
+ "&cluster=" + $rootScope.pageContext.clusterName;

EventManager.emit(EventManager.EventType.REFRESH_NAMESPACE);
$rootScope.showSideBar = false;
}
Expand Down Expand Up @@ -311,7 +326,6 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr
$rootScope.viewMode = 1;
}


$rootScope.adaptScreenSize = function () {
if (window.innerWidth <= VIEW_MODE_SWITCH_WIDTH) {
$rootScope.viewMode = 2;
Expand All @@ -322,8 +336,8 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr

};

$(window).resize(function(){
$scope.$apply(function(){
$(window).resize(function () {
$scope.$apply(function () {
$rootScope.adaptScreenSize();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ <h5>无覆盖的配置</h5>
<div class="row">
<div class="padding-top-5 col-md-4 col-sm-4">
公共的配置
<a href="/config.html?#/appid={{namespace.publicNamespace.baseInfo.appId}}" target="_blank">
<a href="/config.html?#/appid={{namespace.publicNamespace.baseInfo.appId}}&env={{env}}&cluster={{namespace.publicNamespace.baseInfo.clusterName}}" target="_blank">
<small>
(AppId:{{namespace.publicNamespace.baseInfo.appId}},
Cluster:{{namespace.publicNamespace.baseInfo.clusterName}})
Expand Down

0 comments on commit cac111a

Please sign in to comment.