提交 a002fa82 编写于 作者: J Jason Song 提交者: GitHub

Merge pull request #555 from lepdou/optimize_portal

check item value hidden chars
...@@ -15,6 +15,7 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr ...@@ -15,6 +15,7 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr
if (!appId) { if (!appId) {
$window.location.href = '/index.html'; $window.location.href = '/index.html';
return;
} }
initPage(); initPage();
...@@ -51,6 +52,7 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr ...@@ -51,6 +52,7 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr
} }
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) {
$scope.notFoundApp = false; $scope.notFoundApp = false;
...@@ -60,40 +62,40 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr ...@@ -60,40 +62,40 @@ function ConfigBaseInfoController($rootScope, $scope, $window, $location, toastr
loadNavTree(); loadNavTree();
recordVisitApp(); recordVisitApp();
findMissEnvs();
$(".J_appFound").removeClass("hidden"); $(".J_appFound").removeClass("hidden");
}, function (result) { }, function (result) {
$(".J_appNotFound").removeClass("hidden"); $(".J_appNotFound").removeClass("hidden");
}); });
}
$scope.createAppInMissEnv = function () {
var count = 0;
$scope.missEnvs.forEach(function (env) {
AppService.create_remote(env, $scope.appBaseInfo).then(function (result) {
toastr.success(env, '创建成功');
count++;
if (count == $scope.missEnvs.length) {
location.reload(true);
}
}, function (result) {
toastr.error(AppUtil.errorMsg(result), '创建失败:' + env);
count++;
if (count == $scope.missEnvs.length) {
location.reload(true);
}
});
});
};
////// 补缺失的环境 ////// function findMissEnvs() {
$scope.missEnvs = []; $scope.missEnvs = [];
AppService.find_miss_envs($rootScope.pageContext.appId).then(function (result) { AppService.find_miss_envs($rootScope.pageContext.appId).then(function (result) {
$scope.missEnvs = AppUtil.collectData(result); $scope.missEnvs = AppUtil.collectData(result);
}, function (result) {
}); });
$scope.createAppInMissEnv = function () {
var count = 0;
$scope.missEnvs.forEach(function (env) {
AppService.create_remote(env, $scope.appBaseInfo).then(function (result) {
toastr.success(env, '创建成功');
count++;
if (count == $scope.missEnvs.length) {
location.reload(true);
}
}, function (result) {
toastr.error(AppUtil.errorMsg(result), '创建失败:' + env);
count++;
if (count == $scope.missEnvs.length) {
location.reload(true);
}
});
});
};
} }
function recordVisitApp() { function recordVisitApp() {
//save user recent visited apps //save user recent visited apps
var VISITED_APPS_STORAGE_KEY = "VisitedAppsV2"; var VISITED_APPS_STORAGE_KEY = "VisitedAppsV2";
......
directive_module.directive('itemmodal', itemModalDirective); directive_module.directive('itemmodal', itemModalDirective);
function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) { function itemModalDirective(toastr, $sce, AppUtil, EventManager, ConfigService) {
return { return {
restrict: 'E', restrict: 'E',
templateUrl: '../../views/component/item-modal.html', templateUrl: '../../views/component/item-modal.html',
...@@ -15,7 +15,6 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) { ...@@ -15,7 +15,6 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) {
}, },
link: function (scope) { link: function (scope) {
var TABLE_VIEW_OPER_TYPE = { var TABLE_VIEW_OPER_TYPE = {
CREATE: 'create', CREATE: 'create',
UPDATE: 'update' UPDATE: 'update'
...@@ -23,6 +22,13 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) { ...@@ -23,6 +22,13 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) {
scope.doItem = doItem; scope.doItem = doItem;
scope.collectSelectedClusters = collectSelectedClusters; scope.collectSelectedClusters = collectSelectedClusters;
scope.showHiddenChars = showHiddenChars;
$('#itemModal').on('show.bs.modal', function (e) {
scope.showHiddenCharsContext = false;
scope.hiddenCharCounter = 0;
scope.valueWithHiddenChars = $sce.trustAsHtml('');
});
function doItem() { function doItem() {
...@@ -61,7 +67,6 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) { ...@@ -61,7 +67,6 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) {
namespace: scope.toOperationNamespace namespace: scope.toOperationNamespace
}); });
}, function (result) { }, function (result) {
toastr.error(AppUtil.errorMsg(result), "添加失败"); toastr.error(AppUtil.errorMsg(result), "添加失败");
scope.item.addItemBtnDisabled = false; scope.item.addItemBtnDisabled = false;
...@@ -97,7 +102,6 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) { ...@@ -97,7 +102,6 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) {
}); });
} }
} else { } else {
if (!scope.item.comment) { if (!scope.item.comment) {
...@@ -114,7 +118,7 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) { ...@@ -114,7 +118,7 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) {
{ {
namespace: scope.toOperationNamespace namespace: scope.toOperationNamespace
}); });
AppUtil.hideModal('#itemModal'); AppUtil.hideModal('#itemModal');
toastr.success("更新成功, 如需生效请发布"); toastr.success("更新成功, 如需生效请发布");
...@@ -126,9 +130,48 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) { ...@@ -126,9 +130,48 @@ function itemModalDirective(toastr, AppUtil, EventManager, ConfigService) {
} }
var selectedClusters = []; var selectedClusters = [];
function collectSelectedClusters(data) { function collectSelectedClusters(data) {
selectedClusters = data; selectedClusters = data;
} }
function showHiddenChars() {
var value = scope.item.value;
if (!value) {
return;
}
var hiddenCharCounter = 0, valueWithHiddenChars = value;
for (var i = 0; i < valueWithHiddenChars.length; i++) {
var c = valueWithHiddenChars[i];
if (isHiddenChar(c)) {
valueWithHiddenChars = valueWithHiddenChars.replace(c, viewHiddenChar);
hiddenCharCounter++;
}
}
scope.showHiddenCharsContext = true;
scope.hiddenCharCounter = hiddenCharCounter;
scope.valueWithHiddenChars = $sce.trustAsHtml(valueWithHiddenChars);
}
function isHiddenChar(c) {
return c == '\t' || c == '\n' || c == ' ';
}
function viewHiddenChar(c) {
if (c == '\t') {
return '<mark>#制表符#</mark>';
} else if (c == '\n') {
return '<mark>#换行符#</mark>';
} else if (c == ' ') {
return '<mark>#空格#</mark>';
}
}
} }
} }
} }
......
...@@ -62,6 +62,10 @@ p, td, span { ...@@ -62,6 +62,10 @@ p, td, span {
border-top: 1px solid #ddd; border-top: 1px solid #ddd;
} }
.bg-info, .bg-primary, .bg-warning, .bg-danger, .bg-success {
padding: 10px;
}
.active { .active {
background: #f5f5f5; background: #f5f5f5;
} }
...@@ -503,7 +507,6 @@ table th { ...@@ -503,7 +507,6 @@ table th {
background: url(../img/add.png) no-repeat; background: url(../img/add.png) no-repeat;
} }
.list-group-item .icon-text { .list-group-item .icon-text {
background-size: 20px; background-size: 20px;
background-position: 5% 50%; background-position: 5% 50%;
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">&times;</span></button> aria-hidden="true">&times;</span></button>
<h4 class="modal-title"> <h4 class="modal-title">
<span ng-show="item.tableViewOperType == 'create' && !toOperationNamespace.isBranch"> 添加配置项</span> <span ng-show="item.tableViewOperType == 'create' && !toOperationNamespace.isBranch">
添加配置项 <small class="text-info">(温馨提示: 可以通过文本模式批量添加配置)</small>
</span>
<span ng-show="item.tableViewOperType == 'create' && toOperationNamespace.isBranch"> 添加灰度配置项</span> <span ng-show="item.tableViewOperType == 'create' && toOperationNamespace.isBranch"> 添加灰度配置项</span>
<span ng-show="item.tableViewOperType == 'update'"> 修改配置项</span> <span ng-show="item.tableViewOperType == 'update'"> 修改配置项</span>
</h4> </h4>
...@@ -33,7 +35,13 @@ ...@@ -33,7 +35,13 @@
ng-required="true" ng-required="true"
ng-model="item.value"> ng-model="item.value">
</textarea> </textarea>
注意: 隐藏字符(空格、换行符、制表符Tab)容易导致配置出错,如果需要检测Value中隐藏字符请点击 <a ng-click="showHiddenChars()">检测隐藏字符</a>
<br>
<div class="bg-info" ng-show="showHiddenCharsContext && hiddenCharCounter == 0">无隐藏字符</div>
<div class="bg-info" ng-bind-html="valueWithHiddenChars" ng-show="showHiddenCharsContext && hiddenCharCounter > 0"></div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label">Comment</label> <label class="col-sm-2 control-label">Comment</label>
......
...@@ -233,7 +233,8 @@ ...@@ -233,7 +233,8 @@
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="config in namespace.viewItems |orderBy:col:desc" <tr ng-repeat="config in namespace.viewItems |orderBy:col:desc"
ng-if="config.item.key"> ng-if="config.item.key"
ng-class="{'warning': !config.item.value}">
<td width="8%" class="text-center"> <td width="8%" class="text-center">
<span class="label label-warning no-radius cursor-pointer" ng-if="config.isModified" <span class="label label-warning no-radius cursor-pointer" ng-if="config.isModified"
data-tooltip="tooltip" data-placement="bottom" title="点击查看已发布的值" data-tooltip="tooltip" data-placement="bottom" title="点击查看已发布的值"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册