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
05281db8
Commit
05281db8
authored
May 27, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #230 from lepdou/bugfix
文本模式下value包含\n处理
parents
ea3563c5
71c4ec27
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
config.html
apollo-portal/src/main/resources/static/config.html
+8
-1
ConfigNamespaceController.js
...tatic/scripts/controller/app/ConfigNamespaceController.js
+17
-5
No files found.
apollo-portal/src/main/resources/static/config.html
View file @
05281db8
...
...
@@ -213,11 +213,18 @@
</header>
<!--text view-->
<!--只读模式下的文本内容,不替换换行符-->
<textarea
class=
"form-control"
rows=
"{{namespace.itemCnt}}"
style=
"border-radius: 0px"
ng-show=
"namespace.viewType == 'text'"
ng-show=
"namespace.viewType == 'text'
&& !namespace.isTextEditing
"
ng-disabled=
"!namespace.isTextEditing"
ng-model=
"namespace.text"
ng-bind=
"namespace.text"
>
</textarea>
<!--编辑状态下的文本内容,会过滤掉换行符-->
<textarea
class=
"form-control"
rows=
"{{namespace.itemCnt}}"
style=
"border-radius: 0px"
ng-show=
"namespace.viewType == 'text' && namespace.isTextEditing"
ng-disabled=
"!namespace.isTextEditing"
ng-model=
"namespace.editText"
ng-bind=
"namespace.editText"
>
</textarea>
<!--table view-->
<div
class=
"namespace-view-table"
>
...
...
apollo-portal/src/main/resources/static/scripts/controller/app/ConfigNamespaceController.js
View file @
05281db8
...
...
@@ -63,7 +63,7 @@ application_module.controller("ConfigNamespaceController",
var
MAX_ROW_SIZE
=
30
;
var
APPEND_ROW_SIZE
=
8
;
//把表格内容解析成文本
function
parseModel2Text
(
namespace
)
{
function
parseModel2Text
(
namespace
,
modeType
)
{
if
(
!
namespace
.
items
)
{
return
"无配置信息"
;
...
...
@@ -72,8 +72,18 @@ application_module.controller("ConfigNamespaceController",
var
itemCnt
=
0
;
namespace
.
items
.
forEach
(
function
(
item
)
{
if
(
item
.
item
.
key
)
{
var
itemValue
=
item
.
item
.
value
;
if
(
modeType
==
'edit'
)
{
//编辑状态下替换value的换行符
if
(
item
.
item
.
value
&&
(
item
.
item
.
value
.
indexOf
(
"
\
n"
)
>
-
1
))
{
alert
(
"警告:["
+
item
.
item
.
key
+
"]的值包含换行符
\\
n,文本编辑会过滤掉换行符."
);
while
(
itemValue
.
indexOf
(
"
\
n"
)
>
-
1
)
{
itemValue
=
itemValue
.
replace
(
"
\
n"
,
""
);
}
}
}
result
+=
item
.
item
.
key
+
" = "
+
item
.
item
.
v
alue
+
"
\
n"
;
item
.
item
.
key
+
" = "
+
item
V
alue
+
"
\
n"
;
}
else
{
result
+=
item
.
item
.
comment
+
"
\
n"
;
}
...
...
@@ -97,7 +107,7 @@ application_module.controller("ConfigNamespaceController",
ConfigService
.
modify_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
$scope
.
pageContext
.
clusterName
,
$scope
.
toCommitNamespace
.
namespace
.
namespaceName
,
$scope
.
toCommitNamespace
.
t
ext
,
$scope
.
toCommitNamespace
.
editT
ext
,
$scope
.
toCommitNamespace
.
namespace
.
id
,
$scope
.
commitComment
).
then
(
function
(
result
)
{
...
...
@@ -120,6 +130,8 @@ application_module.controller("ConfigNamespaceController",
if
(
namespace
.
isTextEditing
)
{
//切换为编辑状态
$scope
.
toCommitNamespace
.
commited
=
false
;
namespace
.
backupText
=
namespace
.
text
;
namespace
.
editText
=
parseModel2Text
(
namespace
,
'edit'
);
}
else
{
if
(
!
$scope
.
toCommitNamespace
.
commited
)
{
//取消编辑,则复原
namespace
.
text
=
namespace
.
backupText
;
...
...
@@ -234,7 +246,7 @@ application_module.controller("ConfigNamespaceController",
itemModal
.
modal
(
'hide'
);
$rootScope
.
refreshNamespaces
(
namespace_view_type
.
TABLE
);
},
function
(
result
)
{
AppUtil
.
errorMsg
(
result
);
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"添加失败"
);
});
}
else
if
(
$scope
.
tableViewOperType
==
TABLE_VIEW_OPER_TYPE
.
UPDATE
)
{
...
...
@@ -250,7 +262,7 @@ application_module.controller("ConfigNamespaceController",
itemModal
.
modal
(
'hide'
);
$rootScope
.
refreshNamespaces
(
namespace_view_type
.
TABLE
);
},
function
(
result
)
{
AppUtil
.
errorMsg
(
result
);
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"更新失败"
);
});
}
});
...
...
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