Commit 9f15c41d by Jason Song Committed by GitHub

Merge pull request #327 from lepdou/history

刷新页面维持nav选择 & 发布历史兼容文本类型的NS
parents 299049ab 71b725af
......@@ -53,7 +53,7 @@
</div>
<table class="table table-hover table-bordered table-striped">
<table class="table table-hover table-bordered table-striped" ng-show="!isTextFile">
<tr ng-repeat="item in release.items">
<td width="30%" ng-bind="item.key">
......@@ -62,14 +62,20 @@
</td>
</tr>
</table>
<textarea class="form-control no-radius" rows="15" ng-show="isTextFile" ng-bind="release.items[0].value" disabled>
</textarea>
</div>
</div>
<div class="text-center">
<div class="text-center load-more">
<button type="button" class="btn btn-default" ng-show="!hasLoadAll"
ng-click="loadMore()">加载更多
<span class="glyphicon glyphicon-menu-down"></span>
</button>
</div>
<div class="text-center" ng-show="!releases.length">
<h4>还没发布过哟~</h4>
</div>
</div>
</section>
......
......@@ -5,10 +5,14 @@ application_module.controller("ConfigBaseInfoController",
AppUtil) {
var appId = AppUtil.parseParams($location.$$url).appid;
//load session storage to recovery scene
var scene = JSON.parse(sessionStorage.getItem(appId));
var pageContext = {
appId: appId,
env: '',
clusterName: 'default'
env: scene ? scene.env : '',
clusterName: scene ? scene.cluster : 'default'
};
$rootScope.pageContext = pageContext;
......@@ -19,12 +23,14 @@ application_module.controller("ConfigBaseInfoController",
var navTree = [];
var nodes = AppUtil.collectData(result);
if (!nodes || nodes.length == 0){
toastr.error("加载导航信息出错");
if (!nodes || nodes.length == 0) {
toastr.error("加载环境信息出错");
return;
}
//默认显示第一个环境的default集群的
pageContext.env = nodes[0].env;
//default first env if session storage is empty
if (!pageContext.env) {
pageContext.env = nodes[0].env;
}
$rootScope.refreshNamespaces();
nodes.forEach(function (env, envIdx) {
......@@ -32,33 +38,31 @@ application_module.controller("ConfigBaseInfoController",
return;
}
var node = {};
//first nav
node.text = env.env;
// node.icon = 'glyphicon glyphicon-console';
var clusterNodes = [];
//如果env下面只有一个default集群则不显示集群列表
if (env.clusters && env.clusters.length == 1 && env.clusters[0].name
== 'default') {
if (envIdx == 0){
== 'default') {
if (envIdx == 0) {
node.state = {};
node.state.selected = true;
}
node.selectable = true;
} else {
node.selectable = false;
//second nav
//cluster list
env.clusters.forEach(function (cluster, clusterIdx) {
var clusterNode = {},
parentNode = [];
if (envIdx == 0 && clusterIdx == 0){
//default selection from session storage or first env & first cluster
if (pageContext.env == env.env && pageContext.clusterName == cluster.name) {
clusterNode.state = {};
clusterNode.state.selected = true;
}
clusterNode.text = cluster.name;
// clusterNode.icon = 'glyphicon glyphicon-object-align-vertical';
parentNode.push(node.text);
clusterNode.tags = ['集群'];
clusterNode.parentNode = parentNode;
......@@ -83,10 +87,19 @@ application_module.controller("ConfigBaseInfoController",
$rootScope.pageContext.clusterName =
'default';
} else {//second cluster node
$rootScope.pageContext.env = data.parentNode[0];
$rootScope.pageContext.env =
data.parentNode[0];
$rootScope.pageContext.clusterName =
data.text;
}
//storage scene
sessionStorage.setItem(
$rootScope.pageContext.appId,
JSON.stringify({
env: $rootScope.pageContext.env,
cluster: $rootScope.pageContext.clusterName
}));
$rootScope.refreshNamespaces();
}
});
......@@ -135,15 +148,15 @@ application_module.controller("ConfigBaseInfoController",
PermissionService.has_create_namespace_permission(appId).then(function (result) {
$scope.hasCreateNamespacePermission = result.hasPermission;
}, function (result) {
});
PermissionService.has_create_cluster_permission(appId).then(function (result) {
$scope.hasCreateClusterPermission = result.hasPermission;
}, function (result) {
});
PermissionService.has_assign_user_permission(appId).then(function (result) {
$scope.hasAssignUserPermission = result.hasPermission;
}, function (result) {
......
......@@ -14,7 +14,6 @@ release_history_module.controller("ReleaseHistoryController",
$scope.page = 0;
$scope.releases = [];
$scope.hasLoadAll = false;
$scope.findReleases = findReleases;
$scope.loadMore = loadMore;
......@@ -32,7 +31,13 @@ release_history_module.controller("ReleaseHistoryController",
$scope.hasLoadAll = true;
return;
}
var hasParseNamepaceType = false;
result.forEach(function (release) {
if (!hasParseNamepaceType){
$scope.isTextFile = /\.(json|yaml|yml|xml)$/gi.test(release.baseInfo.namespaceName);
hasParseNamepaceType = true;
}
$scope.releases.push(release);
})
}, function (result) {
......
......@@ -395,6 +395,14 @@ table th {
padding-left: 20px;
}
.release-history .panel-body .load-more{
margin-top: 20px;
}
.release-history .media-body textarea{
margin-top: 10px;
}
.release-history .icon{
font-size: 13px;
}
......
......@@ -111,7 +111,7 @@
</header>
<!--text view-->
<!--只读模式下的文本内容,不替换换行符-->
<textarea class="form-control" rows="{{namespace.itemCnt}}" style="border-radius: 0px"
<textarea class="form-control no-radius" rows="{{namespace.itemCnt}}"
ng-show="namespace.viewType == 'text' && !namespace.isTextEditing"
ng-disabled="!namespace.isTextEditing" ng-model="namespace.text"
ng-bind="namespace.text">
......
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