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
f0011004
Commit
f0011004
authored
May 19, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #207 from lepdou/env_cluster_select
集群选择做成一个标签
parents
ff8856fc
2ef6cf95
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
105 additions
and
110 deletions
+105
-110
sync.html
apollo-portal/src/main/resources/static/config/sync.html
+2
-18
index.html
apollo-portal/src/main/resources/static/index.html
+1
-1
namespace.html
apollo-portal/src/main/resources/static/namespace.html
+2
-18
app.js
apollo-portal/src/main/resources/static/scripts/app.js
+1
-1
NamespaceController.js
...esources/static/scripts/controller/NamespaceController.js
+5
-41
SyncConfigController.js
...ces/static/scripts/controller/app/SyncConfigController.js
+10
-29
directive.js
apollo-portal/src/main/resources/static/scripts/directive.js
+64
-0
env-selector.html
...c/main/resources/static/views/component/env-selector.html
+18
-0
application.pid
application.pid
+2
-2
No files found.
apollo-portal/src/main/resources/static/config/sync.html
View file @
f0011004
...
...
@@ -46,24 +46,8 @@
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
同步到那个集群
</label>
<div
class=
"col-sm-6"
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<td><input
type=
"checkbox"
ng-click=
"toggleEnvsCheckedStatus()"
></td>
</td>
<td>
环境
</td>
<td>
集群
</td>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"namespaceIdentifer in namespaceIdentifers"
>
<td
width=
"10%"
><input
type=
"checkbox"
ng-checked=
"namespaceIdentifer.checked"
ng-click=
"switchSelect(namespaceIdentifer)"
></td>
<td
width=
"30%"
ng-bind=
"namespaceIdentifer.env"
></td>
<td
width=
"60%"
ng-bind=
"namespaceIdentifer.name"
></td>
</tr>
</tbody>
</table>
<apolloclusterselector
apollo-app-id=
"pageContext.appId"
apollo-default-checked=
"true"
apollo-select=
"collectSelectedClusters"
></apolloclusterselector>
</div>
</div>
</div>
...
...
apollo-portal/src/main/resources/static/index.html
View file @
f0011004
...
...
@@ -15,7 +15,7 @@
<div
class=
"site-notice"
>
当前站点支持
<a
ng-repeat=
"env in envs"
ng-class=
"{selected:selectedEnv == env}"
ng-click=
"switchEnv(env)"
><em
ng-bind=
"env"
>
</em>
</a>
</em>
</a>
环境点击切换
</div>
...
...
apollo-portal/src/main/resources/static/namespace.html
View file @
f0011004
...
...
@@ -41,24 +41,8 @@
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
><font
style=
"color: red"
>
*
</font>
选择集群
</label>
<div
class=
"col-sm-6"
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<td><input
type=
"checkbox"
ng-click=
"toggleEnvsCheckedStatus()"
></td>
</td>
<td>
环境
</td>
<td>
集群
</td>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"namespaceIdentifer in namespaceIdentifers"
>
<td
width=
"10%"
><input
type=
"checkbox"
ng-checked=
"namespaceIdentifer.checked"
ng-click=
"switchSelect(namespaceIdentifer)"
></td>
<td
width=
"30%"
ng-bind=
"namespaceIdentifer.env"
></td>
<td
width=
"60%"
ng-bind=
"namespaceIdentifer.name"
></td>
</tr>
</tbody>
</table>
<apolloclusterselector
apollo-app-id=
"appId"
apollo-default-checked=
"true"
apollo-select=
"collectSelectedClusters"
></apolloclusterselector>
</div>
</div>
</div>
...
...
apollo-portal/src/main/resources/static/scripts/app.js
View file @
f0011004
...
...
@@ -5,7 +5,7 @@ var appService = angular.module('app.service', ['ngResource']);
var
appUtil
=
angular
.
module
(
'app.util'
,
[
'toastr'
]);
/** directive */
var
directive_module
=
angular
.
module
(
'apollo.directive'
,
[
'app.service'
]);
var
directive_module
=
angular
.
module
(
'apollo.directive'
,
[
'app.service'
,
'app.util'
,
'toastr'
]);
/** page module 定义*/
// 首页
...
...
apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js
View file @
f0011004
...
...
@@ -8,22 +8,6 @@ namespace_module.controller("LinkNamespaceController",
$scope
.
step
=
1
;
////// load env //////
AppService
.
load_nav_tree
(
$scope
.
appId
).
then
(
function
(
result
)
{
$scope
.
namespaceIdentifers
=
[];
var
envClusterInfo
=
AppUtil
.
collectData
(
result
);
envClusterInfo
.
forEach
(
function
(
node
)
{
var
env
=
node
.
env
;
node
.
clusters
.
forEach
(
function
(
cluster
)
{
cluster
.
env
=
env
;
cluster
.
checked
=
false
;
$scope
.
namespaceIdentifers
.
push
(
cluster
);
})
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"加载环境出错"
);
});
NamespaceService
.
find_public_namespaces
().
then
(
function
(
result
)
{
var
publicNamespaces
=
[];
result
.
forEach
(
function
(
item
)
{
...
...
@@ -45,9 +29,13 @@ namespace_module.controller("LinkNamespaceController",
name
:
''
,
comment
:
''
};
var
selectedClusters
=
[];
$scope
.
collectSelectedClusters
=
function
(
data
)
{
selectedClusters
=
data
;
};
$scope
.
createNamespace
=
function
()
{
if
(
$scope
.
type
==
'link'
){
var
selectedClusters
=
collectSelectedClusters
();
if
(
selectedClusters
.
length
==
0
){
toastr
.
warning
(
"请选择集群"
);
return
;
...
...
@@ -85,35 +73,11 @@ namespace_module.controller("LinkNamespaceController",
};
var
envAllSelected
=
false
;
$scope
.
toggleEnvsCheckedStatus
=
function
()
{
envAllSelected
=
!
envAllSelected
;
$scope
.
namespaceIdentifers
.
forEach
(
function
(
namespaceIdentifer
)
{
namespaceIdentifer
.
checked
=
envAllSelected
;
})
};
function
collectSelectedClusters
()
{
var
selectedClusters
=
[];
$scope
.
namespaceIdentifers
.
forEach
(
function
(
namespaceIdentifer
)
{
if
(
namespaceIdentifer
.
checked
){
namespaceIdentifer
.
clusterName
=
namespaceIdentifer
.
name
;
selectedClusters
.
push
(
namespaceIdentifer
);
}
});
return
selectedClusters
;
}
$scope
.
namespaceType
=
1
;
$scope
.
selectNamespaceType
=
function
(
type
)
{
$scope
.
namespaceType
=
type
;
};
$scope
.
switchSelect
=
function
(
o
)
{
o
.
checked
=
!
o
.
checked
;
};
$scope
.
back
=
function
()
{
$window
.
location
.
href
=
'/config.html?#appid='
+
$scope
.
appId
;
};
...
...
apollo-portal/src/main/resources/static/scripts/controller/app/SyncConfigController.js
View file @
f0011004
...
...
@@ -10,31 +10,7 @@ sync_item_module.controller("SyncItemController",
namespaceName
:
params
.
namespaceName
};
////// load env //////
AppService
.
load_nav_tree
(
$scope
.
pageContext
.
appId
).
then
(
function
(
result
)
{
$scope
.
namespaceIdentifers
=
[];
var
envClusterInfo
=
AppUtil
.
collectData
(
result
);
envClusterInfo
.
forEach
(
function
(
node
)
{
var
env
=
node
.
env
;
node
.
clusters
.
forEach
(
function
(
cluster
)
{
cluster
.
env
=
env
;
cluster
.
checked
=
false
;
if
(
env
!=
$scope
.
pageContext
.
env
||
cluster
.
name
!=
$scope
.
pageContext
.
clusterName
){
$scope
.
namespaceIdentifers
.
push
(
cluster
);
}
})
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"加载环境出错"
);
});
var
envAllSelected
=
false
;
$scope
.
toggleEnvsCheckedStatus
=
function
()
{
envAllSelected
=
!
envAllSelected
;
$scope
.
namespaceIdentifers
.
forEach
(
function
(
namespaceIdentifer
)
{
namespaceIdentifer
.
checked
=
envAllSelected
;
})
};
////// load items //////
ConfigService
.
find_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
...
...
@@ -85,6 +61,11 @@ sync_item_module.controller("SyncItemController",
toastr
.
error
(
AppUtil
.
errorMsg
(
result
));
});
};
var
selectedClusters
=
[];
$scope
.
collectSelectedClusters
=
function
(
data
)
{
selectedClusters
=
data
;
};
function
parseSyncSourceData
()
{
var
sourceData
=
{
...
...
@@ -92,11 +73,11 @@ sync_item_module.controller("SyncItemController",
syncItems
:
[]
};
var
namespaceName
=
$scope
.
pageContext
.
namespaceName
;
$scope
.
namespaceIdentifers
.
forEach
(
function
(
namespaceIdentif
er
)
{
if
(
namespaceIdentif
er
.
checked
){
namespaceIdentifer
.
clusterName
=
namespaceIdentif
er
.
name
;
namespaceIdentif
er
.
namespaceName
=
namespaceName
;
sourceData
.
syncToNamespaces
.
push
(
namespaceIdentif
er
);
selectedClusters
.
forEach
(
function
(
clust
er
)
{
if
(
clust
er
.
checked
){
cluster
.
clusterName
=
clust
er
.
name
;
clust
er
.
namespaceName
=
namespaceName
;
sourceData
.
syncToNamespaces
.
push
(
clust
er
);
}
});
$scope
.
sourceItems
.
forEach
(
function
(
item
)
{
...
...
apollo-portal/src/main/resources/static/scripts/directive.js
View file @
f0011004
/** navbar */
directive_module
.
directive
(
'apollonav'
,
function
(
$compile
,
$window
,
AppService
,
EnvService
)
{
return
{
restrict
:
'E'
,
...
...
@@ -113,3 +115,65 @@ directive_module.directive('apollonav', function ($compile, $window, AppService,
}
});
/** env cluster selector*/
directive_module
.
directive
(
'apolloclusterselector'
,
function
(
$compile
,
$window
,
AppService
,
AppUtil
,
toastr
)
{
return
{
restrict
:
'E'
,
templateUrl
:
'../views/component/env-selector.html'
,
transclude
:
true
,
replace
:
true
,
scope
:
{
appId
:
'=apolloAppId'
,
defaultChecked
:
'=apolloDefaultChecked'
,
select
:
'=apolloSelect'
},
link
:
function
(
scope
,
element
,
attrs
)
{
////// load env //////
AppService
.
load_nav_tree
(
scope
.
appId
).
then
(
function
(
result
)
{
scope
.
clusters
=
[];
var
envClusterInfo
=
AppUtil
.
collectData
(
result
);
envClusterInfo
.
forEach
(
function
(
node
)
{
var
env
=
node
.
env
;
node
.
clusters
.
forEach
(
function
(
cluster
)
{
cluster
.
env
=
env
;
cluster
.
checked
=
scope
.
defaultChecked
;
scope
.
clusters
.
push
(
cluster
);
})
});
scope
.
select
(
collectSelectedClusters
());
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"加载环境信息出错"
);
});
scope
.
envAllSelected
=
scope
.
defaultChecked
;
scope
.
toggleEnvsCheckedStatus
=
function
()
{
scope
.
envAllSelected
=
!
scope
.
envAllSelected
;
scope
.
clusters
.
forEach
(
function
(
cluster
)
{
cluster
.
checked
=
scope
.
envAllSelected
;
});
scope
.
select
(
collectSelectedClusters
());
};
scope
.
switchSelect
=
function
(
o
)
{
o
.
checked
=
!
o
.
checked
;
scope
.
select
(
collectSelectedClusters
());
};
function
collectSelectedClusters
()
{
var
selectedClusters
=
[];
scope
.
clusters
.
forEach
(
function
(
cluster
)
{
if
(
cluster
.
checked
){
cluster
.
clusterName
=
cluster
.
name
;
selectedClusters
.
push
(
cluster
);
}
});
return
selectedClusters
;
}
}
}
});
apollo-portal/src/main/resources/static/views/component/env-selector.html
0 → 100644
View file @
f0011004
<table
class=
"table table-hover"
>
<thead>
<tr>
<td><input
type=
"checkbox"
ng-checked=
"envAllSelected"
ng-click=
"toggleEnvsCheckedStatus()"
></td>
</td>
<td>
环境
</td>
<td>
集群
</td>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"cluster in clusters"
>
<td
width=
"10%"
><input
type=
"checkbox"
ng-checked=
"cluster.checked"
ng-click=
"switchSelect(cluster)"
></td>
<td
width=
"30%"
ng-bind=
"cluster.env"
></td>
<td
width=
"60%"
ng-bind=
"cluster.name"
></td>
</tr>
</tbody>
</table>
application.pid
View file @
f0011004
7804
\ No newline at end of file
13303
\ No newline at end of file
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