Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
apollo
Commits
15b70240
Commit
15b70240
authored
Apr 21, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页获取的app列表从配置的环境中拿到 & 创建默认的namespace名字用appid
parent
bb624498
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
20 additions
and
18 deletions
+20
-18
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java
.../main/java/com/ctrip/apollo/biz/service/AdminService.java
+2
-2
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
...t/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
+3
-2
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java
...ava/com/ctrip/apollo/portal/controller/AppController.java
+3
-3
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java
...main/java/com/ctrip/apollo/portal/service/AppService.java
+3
-1
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java
...n/java/com/ctrip/apollo/portal/service/ConfigService.java
+3
-2
apollo-portal/src/main/resources/static/scripts/controller/IndexController.js
...in/resources/static/scripts/controller/IndexController.js
+1
-3
apollo-portal/src/main/resources/static/scripts/services/AppService.js
.../src/main/resources/static/scripts/services/AppService.js
+4
-4
apollo-portal/src/main/resources/static/views/common/nav.html
...lo-portal/src/main/resources/static/views/common/nav.html
+1
-1
No files found.
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/AdminService.java
View file @
15b70240
...
@@ -54,7 +54,7 @@ public class AdminService {
...
@@ -54,7 +54,7 @@ public class AdminService {
private
void
createDefaultAppNamespace
(
String
appId
,
String
createBy
)
{
private
void
createDefaultAppNamespace
(
String
appId
,
String
createBy
)
{
AppNamespace
appNs
=
new
AppNamespace
();
AppNamespace
appNs
=
new
AppNamespace
();
appNs
.
setAppId
(
appId
);
appNs
.
setAppId
(
appId
);
appNs
.
setName
(
ConfigConsts
.
NAMESPACE_APPLICATION
);
appNs
.
setName
(
appId
);
appNs
.
setComment
(
"default app namespace"
);
appNs
.
setComment
(
"default app namespace"
);
appNs
.
setDataChangeCreatedBy
(
createBy
);
appNs
.
setDataChangeCreatedBy
(
createBy
);
appNs
.
setDataChangeLastModifiedBy
(
createBy
);
appNs
.
setDataChangeLastModifiedBy
(
createBy
);
...
@@ -79,7 +79,7 @@ public class AdminService {
...
@@ -79,7 +79,7 @@ public class AdminService {
Namespace
ns
=
new
Namespace
();
Namespace
ns
=
new
Namespace
();
ns
.
setAppId
(
appId
);
ns
.
setAppId
(
appId
);
ns
.
setClusterName
(
ConfigConsts
.
CLUSTER_NAME_DEFAULT
);
ns
.
setClusterName
(
ConfigConsts
.
CLUSTER_NAME_DEFAULT
);
ns
.
setNamespaceName
(
ConfigConsts
.
NAMESPACE_APPLICATION
);
ns
.
setNamespaceName
(
appId
);
ns
.
setDataChangeCreatedBy
(
createBy
);
ns
.
setDataChangeCreatedBy
(
createBy
);
ns
.
setDataChangeLastModifiedBy
(
createBy
);
ns
.
setDataChangeLastModifiedBy
(
createBy
);
namespaceRepository
.
save
(
ns
);
namespaceRepository
.
save
(
ns
);
...
...
apollo-biz/src/test/java/com/ctrip/apollo/biz/service/AdminServiceTest.java
View file @
15b70240
...
@@ -17,6 +17,7 @@ import com.ctrip.apollo.biz.entity.App;
...
@@ -17,6 +17,7 @@ import com.ctrip.apollo.biz.entity.App;
import
com.ctrip.apollo.biz.entity.Audit
;
import
com.ctrip.apollo.biz.entity.Audit
;
import
com.ctrip.apollo.biz.entity.Cluster
;
import
com.ctrip.apollo.biz.entity.Cluster
;
import
com.ctrip.apollo.biz.entity.Namespace
;
import
com.ctrip.apollo.biz.entity.Namespace
;
import
com.ctrip.apollo.core.ConfigConsts
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
BizTestConfiguration
.
class
)
@SpringApplicationConfiguration
(
classes
=
BizTestConfiguration
.
class
)
...
@@ -51,11 +52,11 @@ public class AdminServiceTest {
...
@@ -51,11 +52,11 @@ public class AdminServiceTest {
List
<
Cluster
>
clusters
=
viewService
.
findClusters
(
app
.
getAppId
());
List
<
Cluster
>
clusters
=
viewService
.
findClusters
(
app
.
getAppId
());
Assert
.
assertEquals
(
1
,
clusters
.
size
());
Assert
.
assertEquals
(
1
,
clusters
.
size
());
Assert
.
assertEquals
(
"default"
,
clusters
.
get
(
0
).
getName
());
Assert
.
assertEquals
(
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
clusters
.
get
(
0
).
getName
());
List
<
Namespace
>
namespaces
=
viewService
.
findNamespaces
(
appId
,
clusters
.
get
(
0
).
getName
());
List
<
Namespace
>
namespaces
=
viewService
.
findNamespaces
(
appId
,
clusters
.
get
(
0
).
getName
());
Assert
.
assertEquals
(
1
,
namespaces
.
size
());
Assert
.
assertEquals
(
1
,
namespaces
.
size
());
Assert
.
assertEquals
(
"application"
,
namespaces
.
get
(
0
).
getNamespaceName
());
Assert
.
assertEquals
(
appId
,
namespaces
.
get
(
0
).
getNamespaceName
());
List
<
Audit
>
audits
=
auditService
.
findByOwner
(
owner
);
List
<
Audit
>
audits
=
auditService
.
findByOwner
(
owner
);
Assert
.
assertEquals
(
4
,
audits
.
size
());
Assert
.
assertEquals
(
4
,
audits
.
size
());
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/AppController.java
View file @
15b70240
...
@@ -25,9 +25,9 @@ public class AppController {
...
@@ -25,9 +25,9 @@ public class AppController {
private
AppService
appService
;
private
AppService
appService
;
@RequestMapping
(
"
/env/{env}
"
)
@RequestMapping
(
""
)
public
List
<
AppDTO
>
findAllApp
(
@PathVariable
String
env
){
public
List
<
AppDTO
>
findAllApp
(){
return
appService
.
findAll
(
Env
.
valueOf
(
env
)
);
return
appService
.
findAll
();
}
}
@RequestMapping
(
"/{appId}/navtree"
)
@RequestMapping
(
"/{appId}/navtree"
)
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/AppService.java
View file @
15b70240
...
@@ -29,7 +29,9 @@ public class AppService {
...
@@ -29,7 +29,9 @@ public class AppService {
@Autowired
@Autowired
private
AdminServiceAPI
.
AppAPI
appAPI
;
private
AdminServiceAPI
.
AppAPI
appAPI
;
public
List
<
AppDTO
>
findAll
(
Env
env
)
{
public
List
<
AppDTO
>
findAll
()
{
// TODO: 16/4/21 先从 portalSettings第一个环境去apps,后续可以优化
Env
env
=
portalSettings
.
getEnvs
().
get
(
0
);
return
appAPI
.
getApps
(
env
);
return
appAPI
.
getApps
(
env
);
}
}
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java
View file @
15b70240
...
@@ -9,6 +9,7 @@ import org.springframework.http.HttpStatus;
...
@@ -9,6 +9,7 @@ import org.springframework.http.HttpStatus;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.HttpClientErrorException
;
import
org.springframework.web.client.HttpClientErrorException
;
import
com.ctrip.apollo.common.utils.ExceptionUtils
;
import
com.ctrip.apollo.core.enums.Env
;
import
com.ctrip.apollo.core.enums.Env
;
import
com.ctrip.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.apollo.core.dto.ItemDTO
;
import
com.ctrip.apollo.core.dto.ItemDTO
;
...
@@ -73,7 +74,7 @@ public class ConfigService {
...
@@ -73,7 +74,7 @@ public class ConfigService {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"parse namespace error. app id:{}, env:{}, clusterName:{}, namespace:{}"
,
logger
.
error
(
"parse namespace error. app id:{}, env:{}, clusterName:{}, namespace:{}"
,
appId
,
env
,
clusterName
,
namespace
.
getNamespaceName
(),
e
);
appId
,
env
,
clusterName
,
namespace
.
getNamespaceName
(),
e
);
return
namespaceVOs
;
throw
e
;
}
}
}
}
...
@@ -98,7 +99,7 @@ public class ConfigService {
...
@@ -98,7 +99,7 @@ public class ConfigService {
releaseItems
=
gson
.
fromJson
(
release
.
getConfigurations
(),
Map
.
class
);
releaseItems
=
gson
.
fromJson
(
release
.
getConfigurations
(),
Map
.
class
);
}
catch
(
HttpClientErrorException
e
){
}
catch
(
HttpClientErrorException
e
){
if
(
e
.
getStatusCode
()
==
HttpStatus
.
NOT_FOUND
){
if
(
e
.
getStatusCode
()
==
HttpStatus
.
NOT_FOUND
){
//ignore maybe new app has no release.
logger
.
warn
(
ExceptionUtils
.
toString
(
e
));
}
else
{
}
else
{
throw
e
;
throw
e
;
}
}
...
...
apollo-portal/src/main/resources/static/scripts/controller/IndexController.js
View file @
15b70240
index_module
.
controller
(
'
IndexController
'
,
[
'
$scope
'
,
'
$window
'
,
'
toastr
'
,
'
AppService
'
,
index_module
.
controller
(
'
IndexController
'
,
[
'
$scope
'
,
'
$window
'
,
'
toastr
'
,
'
AppService
'
,
function
(
$scope
,
$window
,
toastr
,
AppService
)
{
function
(
$scope
,
$window
,
toastr
,
AppService
)
{
$scope
.
env
=
'
LOCAL
'
;
var
apps
=
[];
var
apps
=
[];
AppService
.
find_all_app
(
$scope
.
env
).
then
(
function
(
result
)
{
AppService
.
find_all_app
().
then
(
function
(
result
)
{
apps
=
result
;
apps
=
result
;
$scope
.
apps
=
apps
;
$scope
.
apps
=
apps
;
$scope
.
appsCount
=
apps
.
length
;
$scope
.
appsCount
=
apps
.
length
;
...
...
apollo-portal/src/main/resources/static/scripts/services/AppService.js
View file @
15b70240
...
@@ -3,7 +3,7 @@ appService.service('AppService', ['$resource', '$q', function ($resource, $q) {
...
@@ -3,7 +3,7 @@ appService.service('AppService', ['$resource', '$q', function ($resource, $q) {
find_all_app
:{
find_all_app
:{
method
:
'
GET
'
,
method
:
'
GET
'
,
isArray
:
true
,
isArray
:
true
,
url
:
'
/apps
/env/:env
'
url
:
'
/apps
'
},
},
load_navtree
:{
load_navtree
:{
methode
:
'
GET
'
,
methode
:
'
GET
'
,
...
@@ -20,11 +20,11 @@ appService.service('AppService', ['$resource', '$q', function ($resource, $q) {
...
@@ -20,11 +20,11 @@ appService.service('AppService', ['$resource', '$q', function ($resource, $q) {
}
}
});
});
return
{
return
{
find_all_app
:
function
(
env
)
{
find_all_app
:
function
()
{
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
app_resource
.
find_all_app
({
app_resource
.
find_all_app
({
env
:
env
},
},
function
(
result
)
{
function
(
result
)
{
d
.
resolve
(
result
);
d
.
resolve
(
result
);
},
function
(
result
)
{
},
function
(
result
)
{
d
.
reject
(
result
);
d
.
reject
(
result
);
...
...
apollo-portal/src/main/resources/static/views/common/nav.html
View file @
15b70240
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
class=
"container-fluid"
>
<div
class=
"container-fluid"
>
<!-- Brand and toggle get grouped for better mobile display -->
<!-- Brand and toggle get grouped for better mobile display -->
<div
class=
"navbar-header"
>
<div
class=
"navbar-header"
>
<a
class=
"navbar-brand"
href=
"
#
"
>
Apollo
</a>
<a
class=
"navbar-brand"
href=
"
/
"
>
Apollo
</a>
</div>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<!-- Collect the nav links, forms, and other content for toggling -->
...
...
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