Commit 86371916 by Jason Song Committed by GitHub

Merge pull request #422 from lepdou/ConfigPage404

config page show tips when app not created
parents 4434416c 27e29e67
...@@ -20,61 +20,71 @@ ...@@ -20,61 +20,71 @@
<!--具体配置信息--> <!--具体配置信息-->
<div class="row config-info-container"> <div class="row config-info-container">
<!--tag导航--> <div ng-controller="ConfigBaseInfoController">
<div class="col-md-3 col-xs-3 col-sm-3" ng-controller="ConfigBaseInfoController">
<div id="treeview"></div> <div class="J_appNotFound hidden row text-center app-not-found" ng-show="notFoundApp">
<!--app info--> <img src="img/404.png">
<section class="panel"> <br>
<header class="panel-heading"> <p>
<img src="img/info.png" class="i-25-20"/> 应用信息 <span ng-bind="pageContext.appId"></span> 不存在,<a href="/app.html">点击创建</a>
</p>
</div>
<div class="J_appFound hidden col-md-3 col-xs-3 col-sm-3" ng-show="!notFoundApp">
<div id="treeview"></div>
<!--app info-->
<section class="panel">
<header class="panel-heading">
<img src="img/info.png" class="i-25-20"/> 应用信息
<span class="tools pull-right"> <span class="tools pull-right">
<a href="javascript:;" class="icon-chevron-down"></a> <a href="javascript:;" class="icon-chevron-down"></a>
</span> </span>
</header> </header>
<div class="panel-body"> <div class="panel-body">
<table class="project-info"> <table class="project-info">
<tbody class="text-left"> <tbody class="text-left">
<tr> <tr>
<th>AppId:</th> <th>AppId:</th>
<td ng-bind="appBaseInfo.appId"></td> <td ng-bind="appBaseInfo.appId"></td>
</tr> </tr>
<tr> <tr>
<th>应用名:</th> <th>应用名:</th>
<td ng-bind="appBaseInfo.name"></td> <td ng-bind="appBaseInfo.name"></td>
</tr> </tr>
<tr> <tr>
<th>部门:</th> <th>部门:</th>
<td ng-bind="appBaseInfo.orgInfo"></td> <td ng-bind="appBaseInfo.orgInfo"></td>
</tr> </tr>
<tr> <tr>
<th>负责人:</th> <th>负责人:</th>
<td ng-bind="appBaseInfo.ownerName"></td> <td ng-bind="appBaseInfo.ownerName"></td>
</tr> </tr>
<tr> <tr>
<th>负责人Email:</th> <th>负责人Email:</th>
<td ng-bind="appBaseInfo.ownerEmail"></td> <td ng-bind="appBaseInfo.ownerEmail"></td>
</tr> </tr>
<tr ng-show="missEnvs.length > 0"> <tr ng-show="missEnvs.length > 0">
<th>缺失的环境:</th> <th>缺失的环境:</th>
<td> <td>
<span ng-repeat="env in missEnvs" ng-bind="env"> <span ng-repeat="env in missEnvs" ng-bind="env">
</span> </span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</section> </section>
<a class="list-group-item" ng-show="missEnvs.length > 0" ng-click="createAppInMissEnv()">
<div class="row icon-text icon-plus-orange"> <a class="list-group-item" ng-show="missEnvs.length > 0" ng-click="createAppInMissEnv()">
<p class="btn-title ng-binding">补缺环境</p> <div class="row icon-text icon-plus-orange">
</div> <p class="btn-title ng-binding">补缺环境</p>
</a> </div>
</a>
<apolloentrance apollo-title="'添加集群'" apollo-img-src="'plus-orange'" <apolloentrance apollo-title="'添加集群'" apollo-img-src="'plus-orange'"
apollo-href="'cluster.html?#/appid=' + pageContext.appId" apollo-href="'cluster.html?#/appid=' + pageContext.appId"
ng-show="hasCreateClusterPermission"></apolloentrance> ng-show="hasCreateClusterPermission"></apolloentrance>
<span class="list-group-item cursor-pointer hover" ng-click="showMasterPermissionTips()" <span class="list-group-item cursor-pointer hover" ng-click="showMasterPermissionTips()"
ng-show="!hasCreateClusterPermission"> ng-show="!hasCreateClusterPermission">
<div class="row icon-text icon-plus-orange"> <div class="row icon-text icon-plus-orange">
...@@ -82,9 +92,9 @@ ...@@ -82,9 +92,9 @@
</div> </div>
</span> </span>
<apolloentrance apollo-title="'添加Namespace'" apollo-img-src="'plus-orange'" <apolloentrance apollo-title="'添加Namespace'" apollo-img-src="'plus-orange'"
apollo-href="'namespace.html?#/appid=' + pageContext.appId" apollo-href="'namespace.html?#/appid=' + pageContext.appId"
ng-show="hasCreateNamespacePermission"></apolloentrance> ng-show="hasCreateNamespacePermission"></apolloentrance>
<span class="list-group-item cursor-pointer hover" ng-click="showMasterPermissionTips()" <span class="list-group-item cursor-pointer hover" ng-click="showMasterPermissionTips()"
ng-show="!hasCreateNamespacePermission"> ng-show="!hasCreateNamespacePermission">
<div class="row icon-text icon-plus-orange"> <div class="row icon-text icon-plus-orange">
...@@ -92,15 +102,15 @@ ...@@ -92,15 +102,15 @@
</div> </div>
</span> </span>
<apolloentrance apollo-title="'项目权限'" apollo-img-src="'user-manage'" <apolloentrance apollo-title="'项目权限'" apollo-img-src="'user-manage'"
apollo-href="'/app/role.html?#/appid=' + pageContext.appId" apollo-href="'/app/role.html?#/appid=' + pageContext.appId"
ng-show="hasAssignUserPermission"></apolloentrance> ng-show="hasAssignUserPermission"></apolloentrance>
</section> </section>
</div>
</div> </div>
<!--namespaces--> <!--namespaces-->
<div class="col-md-9 col-xs-9 col-sm-9 config-item-container hide" ng-controller="ConfigNamespaceController"> <div class="col-md-9 col-xs-9 col-sm-9 config-item-container hide" ng-controller="ConfigNamespaceController">
<div class="alert alert-warning alert-dismissible" role="alert" <div class="alert alert-warning alert-dismissible" role="alert"
......
application_module.controller("ConfigBaseInfoController", application_module.controller("ConfigBaseInfoController",
['$rootScope', '$scope', '$location', 'toastr', 'AppService', 'PermissionService', ['$rootScope', '$scope', '$location', 'toastr', 'AppService', 'PermissionService',
'AppUtil', 'AppUtil', ConfigBaseInfoController]);
function ($rootScope, $scope, $location, toastr, AppService, PermissionService,
AppUtil) { function ConfigBaseInfoController($rootScope, $scope, $location, toastr, AppService, PermissionService,
AppUtil) {
var appId = AppUtil.parseParams($location.$$url).appid;
var appId = AppUtil.parseParams($location.$$url).appid;
$rootScope.hideTip = JSON.parse(localStorage.getItem("hideTip"));
$rootScope.hideTip = JSON.parse(localStorage.getItem("hideTip"));
//save user recent visited apps
var VISITED_APPS_STORAGE_KEY = "VisitedApps"; //save user recent visited apps
var visitedApps = JSON.parse(localStorage.getItem(VISITED_APPS_STORAGE_KEY)); var VISITED_APPS_STORAGE_KEY = "VisitedApps";
var hasSaved = false; var visitedApps = JSON.parse(localStorage.getItem(VISITED_APPS_STORAGE_KEY));
if (visitedApps) { var hasSaved = false;
visitedApps.forEach(function (app) { if (visitedApps) {
if (app == appId) { visitedApps.forEach(function (app) {
hasSaved = true; if (app == appId) {
return; hasSaved = true;
} return;
}); }
} else { });
visitedApps = []; } else {
} visitedApps = [];
if (!hasSaved) { }
visitedApps.push(appId); if (!hasSaved) {
visitedApps.push(appId);
localStorage.setItem(VISITED_APPS_STORAGE_KEY,
JSON.stringify(visitedApps)); localStorage.setItem(VISITED_APPS_STORAGE_KEY,
} JSON.stringify(visitedApps));
}
//load session storage to recovery scene
var scene = JSON.parse(sessionStorage.getItem(appId)); //load session storage to recovery scene
var scene = JSON.parse(sessionStorage.getItem(appId));
var pageContext = {
appId: appId, var pageContext = {
env: scene ? scene.env : '', appId: appId,
clusterName: scene ? scene.cluster : 'default' env: scene ? scene.env : '',
}; clusterName: scene ? scene.cluster : 'default'
};
$rootScope.pageContext = pageContext;
$rootScope.pageContext = pageContext;
////// load cluster nav tree //////
$scope.notFoundApp = true;
AppService.load_nav_tree($rootScope.pageContext.appId).then(function (result) { ////// app info //////
var navTree = []; AppService.load($rootScope.pageContext.appId).then(function (result) {
var nodes = AppUtil.collectData(result); $scope.notFoundApp = false;
if (!nodes || nodes.length == 0) { $scope.appBaseInfo = result;
toastr.error("加载环境信息出错"); $scope.appBaseInfo.orgInfo = result.orgName + '(' + result.orgId + ')';
return;
} loadNavTree();
//default first env if session storage is empty
if (!pageContext.env) { $(".J_appFound").removeClass("hidden");
pageContext.env = nodes[0].env; }, function (result) {
} $(".J_appNotFound").removeClass("hidden");
$rootScope.refreshNamespaces(); });
nodes.forEach(function (env, envIdx) { function loadNavTree() {
if (!env.clusters || env.clusters.length == 0) { AppService.load_nav_tree($rootScope.pageContext.appId).then(function (result) {
return; var navTree = [];
} var nodes = AppUtil.collectData(result);
var node = {};
node.text = env.env; if (!nodes || nodes.length == 0) {
var clusterNodes = []; toastr.error("系统出错,请重试或联系系统负责人");
return;
//如果env下面只有一个default集群则不显示集群列表 }
if (env.clusters && env.clusters.length == 1 && env.clusters[0].name //default first env if session storage is empty
== 'default') { if (!pageContext.env) {
if (pageContext.env == env.env) { pageContext.env = nodes[0].env;
node.state = {}; }
node.state.selected = true; $rootScope.refreshNamespaces();
}
node.selectable = true; nodes.forEach(function (env, envIdx) {
} else { if (!env.clusters || env.clusters.length == 0) {
node.selectable = false; return;
//cluster list }
env.clusters.forEach(function (cluster, clusterIdx) { var node = {};
var clusterNode = {}, node.text = env.env;
parentNode = []; var clusterNodes = [];
//default selection from session storage or first env & first cluster //如果env下面只有一个default集群则不显示集群列表
if (pageContext.env == env.env && pageContext.clusterName if (env.clusters && env.clusters.length == 1 && env.clusters[0].name
== cluster.name) { == 'default') {
clusterNode.state = {}; if (pageContext.env == env.env) {
clusterNode.state.selected = true; node.state = {};
} node.state.selected = true;
}
clusterNode.text = cluster.name; node.selectable = true;
parentNode.push(node.text); } else {
clusterNode.tags = ['集群']; node.selectable = false;
clusterNode.parentNode = parentNode; //cluster list
clusterNodes.push(clusterNode); env.clusters.forEach(function (cluster, clusterIdx) {
}); var clusterNode = {},
} parentNode = [];
node.nodes = clusterNodes;
navTree.push(node); //default selection from session storage or first env & first cluster
}); if (pageContext.env == env.env && pageContext.clusterName
== cluster.name) {
//init treeview clusterNode.state = {};
$('#treeview').treeview({ clusterNode.state.selected = true;
color: "#797979", }
showBorder: true,
data: navTree, clusterNode.text = cluster.name;
levels: 99, parentNode.push(node.text);
expandIcon: '', clusterNode.tags = ['集群'];
collapseIcon: '', clusterNode.parentNode = parentNode;
showTags: true, clusterNodes.push(clusterNode);
onNodeSelected: function (event, data) { });
if (!data.parentNode) {//first nav node }
$rootScope.pageContext.env = data.text; node.nodes = clusterNodes;
$rootScope.pageContext.clusterName = navTree.push(node);
'default'; });
} else {//second cluster node
$rootScope.pageContext.env = //init treeview
data.parentNode[0]; $('#treeview').treeview({
$rootScope.pageContext.clusterName = color: "#797979",
data.text; showBorder: true,
} data: navTree,
//storage scene levels: 99,
sessionStorage.setItem( expandIcon: '',
$rootScope.pageContext.appId, collapseIcon: '',
JSON.stringify({ showTags: true,
env: $rootScope.pageContext.env, onNodeSelected: function (event, data) {
cluster: $rootScope.pageContext.clusterName if (!data.parentNode) {//first nav node
})); $rootScope.pageContext.env = data.text;
$rootScope.pageContext.clusterName =
$rootScope.refreshNamespaces(); 'default';
} } else {//second cluster node
}); $rootScope.pageContext.env =
data.parentNode[0];
var envMapClusters = {}; $rootScope.pageContext.clusterName =
navTree.forEach(function (node) { data.text;
if (node.nodes && node.nodes.length > 0) { }
//storage scene
var clusterNames = []; sessionStorage.setItem(
node.nodes.forEach(function (cluster) { $rootScope.pageContext.appId,
if (cluster.text != 'default') { JSON.stringify({
clusterNames.push(cluster.text); env: $rootScope.pageContext.env,
} cluster: $rootScope.pageContext.clusterName
}));
});
$rootScope.refreshNamespaces();
envMapClusters[node.text] = clusterNames.join(","); }
});
}
}); var envMapClusters = {};
navTree.forEach(function (node) {
$rootScope.envMapClusters = envMapClusters; if (node.nodes && node.nodes.length > 0) {
}, function (result) { var clusterNames = [];
toastr.error(AppUtil.errorMsg(result), "加载导航出错"); node.nodes.forEach(function (cluster) {
}); if (cluster.text != 'default') {
clusterNames.push(cluster.text);
////// app info ////// }
AppService.load($rootScope.pageContext.appId).then(function (result) { });
$scope.appBaseInfo = result;
$scope.appBaseInfo.orgInfo = result.orgName + '(' + result.orgId + ')'; envMapClusters[node.text] = clusterNames.join(",");
}, function (result) {
toastr.error(AppUtil.errorMsg(result), "加载App信息出错"); }
}); });
////// 补缺失的环境 ////// $rootScope.envMapClusters = envMapClusters;
$scope.missEnvs = [];
AppService.find_miss_envs($rootScope.pageContext.appId).then(function (result) { }, function (result) {
$scope.missEnvs = AppUtil.collectData(result); toastr.error(AppUtil.errorMsg(result), "系统出错,请重试或联系系统负责人");
}, function (result) { });
console.log(AppUtil.errorMsg(result)); }
});
////// 补缺失的环境 //////
$scope.createAppInMissEnv = function () { $scope.missEnvs = [];
var count = 0; AppService.find_miss_envs($rootScope.pageContext.appId).then(function (result) {
$scope.missEnvs.forEach(function (env) { $scope.missEnvs = AppUtil.collectData(result);
AppService.create_remote(env, $scope.appBaseInfo).then(function (result) { }, function (result) {
toastr.success(env, '创建成功');
count++; });
if (count == $scope.missEnvs.length) {
location.reload(true); $scope.createAppInMissEnv = function () {
} var count = 0;
}, function (result) { $scope.missEnvs.forEach(function (env) {
toastr.error(AppUtil.errorMsg(result), '创建失败:' + env); AppService.create_remote(env, $scope.appBaseInfo).then(function (result) {
count++; toastr.success(env, '创建成功');
if (count == $scope.missEnvs.length) { count++;
location.reload(true); if (count == $scope.missEnvs.length) {
} location.reload(true);
}); }
}); }, function (result) {
}; toastr.error(AppUtil.errorMsg(result), '创建失败:' + env);
count++;
//permission if (count == $scope.missEnvs.length) {
PermissionService.has_create_namespace_permission(appId).then(function (result) { location.reload(true);
$scope.hasCreateNamespacePermission = result.hasPermission; }
}, function (result) { });
});
}); };
PermissionService.has_create_cluster_permission(appId).then(function (result) { //permission
$scope.hasCreateClusterPermission = result.hasPermission; PermissionService.has_create_namespace_permission(appId).then(function (result) {
}, function (result) { $scope.hasCreateNamespacePermission = result.hasPermission;
}, function (result) {
});
});
PermissionService.has_assign_user_permission(appId).then(function (result) {
$scope.hasAssignUserPermission = result.hasPermission; PermissionService.has_create_cluster_permission(appId).then(function (result) {
}, function (result) { $scope.hasCreateClusterPermission = result.hasPermission;
}, function (result) {
});
});
$scope.showMasterPermissionTips = function () {
$("#masterNoPermissionDialog").modal('show'); PermissionService.has_assign_user_permission(appId).then(function (result) {
} $scope.hasAssignUserPermission = result.hasPermission;
}, function (result) {
}]);
});
$scope.showMasterPermissionTips = function () {
$("#masterNoPermissionDialog").modal('show');
}
}
...@@ -541,3 +541,8 @@ table th { ...@@ -541,3 +541,8 @@ table th {
border-color: #a94442; border-color: #a94442;
} }
.app-not-found {
padding-top: 50px;
font-size: 18px;
}
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<img src="img/sync.png"> <img src="img/sync.png">
同步配置 同步配置
</a> </a>
<a type="button" class="btn btn-danger btn-sm J_tableview_btn" <a type="button" class="btn btn-default btn-sm J_tableview_btn"
data-tooltip="tooltip" data-placement="bottom" title="您没有任何配置权限,请申请" data-tooltip="tooltip" data-placement="bottom" title="您没有任何配置权限,请申请"
ng-click="showNoModifyPermissionDialog()" ng-click="showNoModifyPermissionDialog()"
ng-show="!namespace.hasModifyPermission && !namespace.hasReleasePermission"> ng-show="!namespace.hasModifyPermission && !namespace.hasReleasePermission">
......
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