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
9c84dccb
Commit
9c84dccb
authored
May 09, 2016
by
Yiming Liu
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #180 from lepdou/namespace
config页面拆分angular controller
parents
f60ee3e2
69c97acd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
264 additions
and
0 deletions
+264
-0
config.html
apollo-portal/src/main/resources/static/config.html
+0
-0
AppConfigController.js
...rces/static/scripts/controller/app/AppConfigController.js
+0
-0
ConfigBaseInfoController.js
...static/scripts/controller/app/ConfigBaseInfoController.js
+111
-0
ConfigNamespaceController.js
...tatic/scripts/controller/app/ConfigNamespaceController.js
+153
-0
No files found.
apollo-portal/src/main/resources/static/config.html
View file @
9c84dccb
This diff is collapsed.
Click to expand it.
apollo-portal/src/main/resources/static/scripts/controller/app/AppConfigController.js
deleted
100644 → 0
View file @
f60ee3e2
This diff is collapsed.
Click to expand it.
apollo-portal/src/main/resources/static/scripts/controller/app/ConfigBaseInfoController.js
0 → 100644
View file @
9c84dccb
application_module
.
controller
(
"ConfigBaseInfoController"
,
[
'$rootScope'
,
'$scope'
,
'$location'
,
'toastr'
,
'AppService'
,
'AppUtil'
,
function
(
$rootScope
,
$scope
,
$location
,
toastr
,
AppService
,
AppUtil
)
{
var
appId
=
AppUtil
.
parseParams
(
$location
.
$$url
).
appid
;
var
pageContext
=
{
appId
:
appId
,
env
:
''
,
clusterName
:
'default'
};
$rootScope
.
pageContext
=
pageContext
;
////// load cluster nav tree //////
AppService
.
load_nav_tree
(
$rootScope
.
pageContext
.
appId
).
then
(
function
(
result
)
{
var
navTree
=
[];
var
nodes
=
result
.
nodes
;
nodes
.
forEach
(
function
(
item
)
{
var
node
=
{};
//first nav
node
.
text
=
item
.
env
;
var
clusterNodes
=
[];
//如果env下面只有一个default集群则不显示集群列表
if
(
item
.
clusters
&&
item
.
clusters
.
length
==
1
&&
item
.
clusters
[
0
].
name
==
'default'
){
node
.
selectable
=
true
;
}
else
{
node
.
selectable
=
false
;
//second nav
item
.
clusters
.
forEach
(
function
(
item
)
{
var
clusterNode
=
{},
parentNode
=
[];
clusterNode
.
text
=
item
.
name
;
parentNode
.
push
(
node
.
text
);
clusterNode
.
tags
=
parentNode
;
clusterNodes
.
push
(
clusterNode
);
});
}
node
.
nodes
=
clusterNodes
;
navTree
.
push
(
node
);
});
$
(
'#treeview'
).
treeview
({
color
:
"#428bca"
,
showBorder
:
true
,
data
:
navTree
,
levels
:
99
,
onNodeSelected
:
function
(
event
,
data
)
{
if
(
!
data
.
tags
){
//first nav node
$rootScope
.
pageContext
.
env
=
data
.
text
;
$rootScope
.
pageContext
.
clusterName
=
'default'
;
}
else
{
//second cluster node
$rootScope
.
pageContext
.
env
=
data
.
tags
[
0
];
$rootScope
.
pageContext
.
clusterName
=
data
.
text
;
}
$rootScope
.
refreshNamespaces
();
}
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"加载导航出错"
);
});
////// app info //////
AppService
.
load
(
$rootScope
.
pageContext
.
appId
).
then
(
function
(
result
)
{
$scope
.
appBaseInfo
=
result
.
app
;
$scope
.
missEnvs
=
result
.
missEnvs
;
$scope
.
selectedEnvs
=
angular
.
copy
(
$scope
.
missEnvs
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"加载App信息出错"
);
});
////// 补缺失的环境 //////
$scope
.
toggleSelection
=
function
toggleSelection
(
env
)
{
var
idx
=
$scope
.
selectedEnvs
.
indexOf
(
env
);
// is currently selected
if
(
idx
>
-
1
)
{
$scope
.
selectedEnvs
.
splice
(
idx
,
1
);
}
// is newly selected
else
{
$scope
.
selectedEnvs
.
push
(
env
);
}
};
$scope
.
createEnvs
=
function
()
{
var
count
=
0
;
$scope
.
selectedEnvs
.
forEach
(
function
(
env
)
{
AppService
.
create
(
env
,
$scope
.
appBaseInfo
).
then
(
function
(
result
)
{
toastr
.
success
(
env
,
'创建成功'
);
count
++
;
if
(
count
==
$scope
.
selectedEnvs
.
length
){
location
.
reload
(
true
);
}
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
'创建失败:'
+
env
);
count
++
;
if
(
count
==
$scope
.
selectedEnvs
){
$route
.
reload
();
}
});
});
};
}]);
apollo-portal/src/main/resources/static/scripts/controller/app/ConfigNamespaceController.js
0 → 100644
View file @
9c84dccb
application_module
.
controller
(
"ConfigNamespaceController"
,
[
'$rootScope'
,
'$scope'
,
'$location'
,
'toastr'
,
'AppUtil'
,
'ConfigService'
,
function
(
$rootScope
,
$scope
,
$location
,
toastr
,
AppUtil
,
ConfigService
)
{
////// namespace //////
var
namespace_view_type
=
{
TEXT
:
'text'
,
TABLE
:
'table'
,
LOG
:
'log'
};
$rootScope
.
refreshNamespaces
=
function
(
viewType
)
{
if
(
$rootScope
.
pageContext
.
env
==
''
){
return
;
}
ConfigService
.
load_all_namespaces
(
$rootScope
.
pageContext
.
appId
,
$rootScope
.
pageContext
.
env
,
$rootScope
.
pageContext
.
clusterName
,
viewType
).
then
(
function
(
result
)
{
$scope
.
namespaces
=
result
;
//初始化视图
if
(
$scope
.
namespaces
)
{
$scope
.
namespaces
.
forEach
(
function
(
item
)
{
item
.
isModify
=
false
;
if
(
!
viewType
)
{
//default text view
$scope
.
switchView
(
item
,
namespace_view_type
.
TEXT
);
}
else
if
(
viewType
==
namespace_view_type
.
TABLE
)
{
item
.
viewType
=
namespace_view_type
.
TABLE
;
}
item
.
isTextEditing
=
false
;
});
}
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"加载配置信息出错"
);
});
}
////// global view oper //////
$scope
.
switchView
=
function
(
namespace
,
viewType
)
{
if
(
namespace_view_type
.
TEXT
==
viewType
)
{
namespace
.
text
=
parseModel2Text
(
namespace
);
}
else
if
(
namespace_view_type
.
TABLE
==
viewType
)
{
}
namespace
.
viewType
=
viewType
;
};
var
MAX_ROW_SIZE
=
30
;
//把表格内容解析成文本
function
parseModel2Text
(
namespace
)
{
if
(
!
namespace
.
items
)
{
return
"无配置信息"
;
}
var
result
=
""
;
var
itemCnt
=
0
;
namespace
.
items
.
forEach
(
function
(
item
)
{
if
(
item
.
item
.
key
)
{
result
+=
item
.
item
.
key
+
" = "
+
item
.
item
.
value
+
"
\
n"
;
}
else
{
result
+=
item
.
item
.
comment
+
"
\
n"
;
}
itemCnt
++
;
});
namespace
.
itemCnt
=
itemCnt
>
MAX_ROW_SIZE
?
MAX_ROW_SIZE
:
itemCnt
+
3
;
return
result
;
}
////// text view oper //////
$scope
.
draft
=
{};
//保存草稿
$scope
.
saveDraft
=
function
(
namespace
)
{
$scope
.
draft
=
namespace
;
};
$scope
.
commitComment
=
''
;
//更新配置
$scope
.
commitChange
=
function
()
{
ConfigService
.
modify_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
$scope
.
pageContext
.
clusterName
,
$scope
.
draft
.
namespace
.
namespaceName
,
$scope
.
draft
.
text
,
$scope
.
draft
.
namespace
.
id
,
$scope
.
commitComment
).
then
(
function
(
result
)
{
toastr
.
success
(
"更新成功"
);
//refresh all namespace items
$rootScope
.
refreshNamespaces
();
$scope
.
draft
.
backupText
=
''
;
//清空备份文本
$scope
.
toggleTextEditStatus
(
$scope
.
draft
);
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"更新失败"
);
}
);
};
//文本编辑框状态切换
$scope
.
toggleTextEditStatus
=
function
(
namespace
)
{
namespace
.
isTextEditing
=
!
namespace
.
isTextEditing
;
if
(
namespace
.
isTextEditing
){
//切换为编辑状态,保存一下原来值
$scope
.
draft
.
backupText
=
namespace
.
text
;
}
else
{
if
(
$scope
.
draft
.
backupText
){
//取消编辑,则复原
namespace
.
text
=
$scope
.
draft
.
backupText
;
}
}
};
////// table view oper //////
$scope
.
watch
=
{};
//查看配置
$scope
.
watchItem
=
function
(
key
,
value
,
oldValue
)
{
$scope
.
watch
.
key
=
key
;
$scope
.
watch
.
value
=
value
;
$scope
.
watch
.
oldValue
=
oldValue
;
};
/////// release ///////
var
releaseNamespace
=
{};
$scope
.
prepareReleaseNamespace
=
function
(
namespace
)
{
releaseNamespace
=
namespace
;
};
$scope
.
releaseComment
=
''
;
$scope
.
releaseTitle
=
''
;
$scope
.
release
=
function
()
{
ConfigService
.
release
(
$rootScope
.
pageContext
.
appId
,
$rootScope
.
pageContext
.
env
,
$rootScope
.
pageContext
.
clusterName
,
releaseNamespace
.
namespace
.
namespaceName
,
$scope
.
releaseTitle
,
$scope
.
releaseComment
).
then
(
function
(
result
)
{
toastr
.
success
(
"发布成功"
);
//refresh all namespace items
$rootScope
.
refreshNamespaces
();
},
function
(
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