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
1b7959d6
Commit
1b7959d6
authored
Jun 20, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add org information for app
parent
b1e05ca3
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
204 additions
and
33 deletions
+204
-33
App.java
...in/java/com/ctrip/framework/apollo/common/entity/App.java
+28
-5
AppDTO.java
...main/java/com/ctrip/framework/apollo/core/dto/AppDTO.java
+20
-0
AppController.java
...rip/framework/apollo/portal/controller/AppController.java
+19
-16
OrganizationController.java
...work/apollo/portal/controller/OrganizationController.java
+37
-0
Organization.java
...ctrip/framework/apollo/portal/entity/vo/Organization.java
+25
-0
app.html
apollo-portal/src/main/resources/static/app.html
+12
-3
namespace.html
apollo-portal/src/main/resources/static/namespace.html
+1
-3
CreateAppController.js
...esources/static/scripts/controller/CreateAppController.js
+29
-2
NamespaceController.js
...esources/static/scripts/controller/NamespaceController.js
+11
-4
OrganizationService.js
.../resources/static/scripts/services/OrganizationService.js
+22
-0
No files found.
apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java
View file @
1b7959d6
package
com
.
ctrip
.
framework
.
apollo
.
common
.
entity
;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"App"
)
@SQLDelete
(
sql
=
"Update App set isDeleted = 1 where id = ?"
)
...
...
@@ -21,6 +19,12 @@ public class App extends BaseEntity {
@Column
(
name
=
"AppId"
,
nullable
=
false
)
private
String
appId
;
@Column
(
name
=
"OrgId"
,
nullable
=
false
)
private
String
orgId
;
@Column
(
name
=
"OrgName"
,
nullable
=
false
)
private
String
orgName
;
@Column
(
name
=
"OwnerName"
,
nullable
=
false
)
private
String
ownerName
;
...
...
@@ -35,6 +39,14 @@ public class App extends BaseEntity {
return
name
;
}
public
String
getOrgId
()
{
return
orgId
;
}
public
String
getOrgName
()
{
return
orgName
;
}
public
String
getOwnerEmail
()
{
return
ownerEmail
;
}
...
...
@@ -51,6 +63,14 @@ public class App extends BaseEntity {
this
.
name
=
name
;
}
public
void
setOrgId
(
String
orgId
)
{
this
.
orgId
=
orgId
;
}
public
void
setOrgName
(
String
orgName
)
{
this
.
orgName
=
orgName
;
}
public
void
setOwnerEmail
(
String
ownerEmail
)
{
this
.
ownerEmail
=
ownerEmail
;
}
...
...
@@ -60,7 +80,10 @@ public class App extends BaseEntity {
}
public
String
toString
()
{
return
toStringHelper
().
add
(
"name"
,
name
).
add
(
"appId"
,
appId
).
add
(
"ownerName"
,
ownerName
)
return
toStringHelper
().
add
(
"name"
,
name
).
add
(
"appId"
,
appId
)
.
add
(
"orgId"
,
orgId
)
.
add
(
"orgName"
,
orgName
)
.
add
(
"ownerName"
,
ownerName
)
.
add
(
"ownerEmail"
,
ownerEmail
).
toString
();
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/core/dto/AppDTO.java
View file @
1b7959d6
...
...
@@ -8,6 +8,10 @@ public class AppDTO extends BaseDTO{
private
String
appId
;
private
String
orgId
;
private
String
orgName
;
private
String
ownerName
;
private
String
ownerEmail
;
...
...
@@ -28,6 +32,14 @@ public class AppDTO extends BaseDTO{
return
name
;
}
public
String
getOrgId
()
{
return
orgId
;
}
public
String
getOrgName
()
{
return
orgName
;
}
public
String
getOwnerEmail
()
{
return
ownerEmail
;
}
...
...
@@ -44,6 +56,14 @@ public class AppDTO extends BaseDTO{
this
.
name
=
name
;
}
public
void
setOrgId
(
String
orgId
)
{
this
.
orgId
=
orgId
;
}
public
void
setOrgName
(
String
orgName
)
{
this
.
orgName
=
orgName
;
}
public
void
setOwnerEmail
(
String
ownerEmail
)
{
this
.
ownerEmail
=
ownerEmail
;
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java
View file @
1b7959d6
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.http.MultiResponseEntity
;
import
com.ctrip.framework.apollo.common.http.RichResponseEntity
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.PortalSettings
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo
;
import
com.ctrip.framework.apollo.portal.listener.AppCreationEvent
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -12,15 +21,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.HttpClientErrorException
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.http.MultiResponseEntity
;
import
com.ctrip.framework.apollo.common.http.RichResponseEntity
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.PortalSettings
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo
;
import
com.ctrip.framework.apollo.portal.listener.AppCreationEvent
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
java.util.List
;
import
static
com
.
ctrip
.
framework
.
apollo
.
portal
.
util
.
RequestPrecondition
.
checkArgument
;
...
...
@@ -53,8 +53,8 @@ public class AppController {
response
.
addResponseEntity
(
RichResponseEntity
.
ok
(
appService
.
createEnvNavNode
(
env
,
appId
)));
}
catch
(
Exception
e
)
{
response
.
addResponseEntity
(
RichResponseEntity
.
error
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
"load env:"
+
env
.
name
()
+
" cluster error."
+
e
.
getMessage
()));
"load env:"
+
env
.
name
()
+
" cluster error."
+
e
.
getMessage
()));
}
}
return
response
;
...
...
@@ -68,7 +68,8 @@ public class AppController {
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<
Void
>
create
(
@RequestBody
App
app
)
{
checkArgument
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
app
.
getOwnerName
());
checkArgument
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
app
.
getOwnerName
(),
app
.
getOrgId
(),
app
.
getOrgName
());
appService
.
enrichUserInfo
(
app
);
App
createdApp
=
appService
.
createOrUpdateAppInLocal
(
app
);
...
...
@@ -78,10 +79,12 @@ public class AppController {
return
ResponseEntity
.
ok
().
build
();
}
@RequestMapping
(
value
=
"/envs/{env}"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
"application/json"
})
@RequestMapping
(
value
=
"/envs/{env}"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
"application/json"
})
public
ResponseEntity
<
Void
>
create
(
@PathVariable
String
env
,
@RequestBody
App
app
)
{
checkArgument
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
app
.
getOwnerName
());
checkArgument
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
app
.
getOwnerName
(),
app
.
getOrgId
(),
app
.
getOrgName
());
appService
.
createApp
(
Env
.
valueOf
(
env
),
app
);
...
...
@@ -107,8 +110,8 @@ public class AppController {
response
.
addResponseEntity
(
RichResponseEntity
.
ok
(
env
));
}
else
{
response
.
addResponseEntity
(
RichResponseEntity
.
error
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
String
.
format
(
"load appId:%s from env %s error."
,
appId
,
env
)
+
e
.
getMessage
()));
String
.
format
(
"load appId:%s from env %s error."
,
appId
,
env
)
+
e
.
getMessage
()));
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/OrganizationController.java
0 → 100644
View file @
1b7959d6
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.portal.entity.po.ServerConfig
;
import
com.ctrip.framework.apollo.portal.entity.vo.Organization
;
import
com.ctrip.framework.apollo.portal.repository.ServerConfigRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.lang.reflect.Type
;
import
java.util.List
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@RestController
@RequestMapping
(
"/organizations"
)
public
class
OrganizationController
{
@Autowired
private
ServerConfigRepository
serverConfigRepository
;
@Autowired
private
Gson
gson
;
private
Type
responseType
=
new
TypeToken
<
List
<
Organization
>>()
{
}.
getType
();
@RequestMapping
public
List
<
Organization
>
loadOrganization
()
{
ServerConfig
config
=
serverConfigRepository
.
findByKey
(
"organizations"
);
return
gson
.
fromJson
(
config
.
getValue
(),
responseType
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Organization.java
0 → 100644
View file @
1b7959d6
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
vo
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
Organization
{
private
String
orgId
;
private
String
orgName
;
public
String
getOrgId
()
{
return
orgId
;
}
public
void
setOrgId
(
String
orgId
)
{
this
.
orgId
=
orgId
;
}
public
String
getOrgName
()
{
return
orgName
;
}
public
void
setOrgName
(
String
orgName
)
{
this
.
orgName
=
orgName
;
}
}
apollo-portal/src/main/resources/static/app.html
View file @
1b7959d6
...
...
@@ -5,6 +5,7 @@
<!-- styles -->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"vendor/bootstrap/css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"vendor/angular/angular-toastr-1.4.1.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"vendor/select2/select2.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
'all'
href=
"vendor/angular/loading-bar.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styles/common-style.css"
>
<title>
新建项目
</title>
...
...
@@ -25,7 +26,13 @@
<div
class=
"panel-body"
>
<form
class=
"form-horizontal"
ng-controller=
"CreateAppController"
ng-submit=
"create()"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用ID
</label>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
部门
</label>
<div
class=
"col-sm-3"
>
<select
id=
"organization"
><option></option></select>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用AppId
</label>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appAppId"
ng-model=
"app.appId"
required
>
...
...
@@ -38,13 +45,13 @@
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用Owner
</label>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用负责人
</label>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appOwner"
ng-model=
"app.ownerName"
required
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
邮箱地址
</label>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
邮箱地址
</label>
<div
class=
"col-sm-4"
>
<input
type=
"email"
class=
"form-control"
ng-model=
"app.ownerEmail"
required
>
</div>
...
...
@@ -74,6 +81,7 @@
<!-- jquery.js -->
<script
src=
"vendor/jquery.min.js"
type=
"text/javascript"
></script>
<script
src=
"vendor/select2/select2.min.js"
type=
"text/javascript"
></script>
<!-- bootstrap.js -->
<script
src=
"vendor/bootstrap/js/bootstrap.min.js"
type=
"text/javascript"
></script>
...
...
@@ -83,6 +91,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/AppUtils.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/OrganizationService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/CreateAppController.js"
></script>
...
...
apollo-portal/src/main/resources/static/namespace.html
View file @
1b7959d6
...
...
@@ -61,9 +61,7 @@
<div
class=
"form-group"
ng-show=
"type == 'link'"
>
<label
class=
"col-sm-3 control-label"
><font
style=
"color: red"
>
*
</font>
namespace
</label>
<div
class=
"col-sm-4"
>
<select
id=
"namespaces"
>
</select>
<select
id=
"namespaces"
><option></option></select>
</div>
</div>
...
...
apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js
View file @
1b7959d6
create_app_module
.
controller
(
'CreateAppController'
,
[
'$scope'
,
'$window'
,
'toastr'
,
'AppService'
,
'AppUtil'
,
function
(
$scope
,
$window
,
toastr
,
AppService
,
AppUtil
)
{
create_app_module
.
controller
(
'CreateAppController'
,
[
'$scope'
,
'$window'
,
'toastr'
,
'AppService'
,
'AppUtil'
,
'OrganizationService'
,
function
(
$scope
,
$window
,
toastr
,
AppService
,
AppUtil
,
OrganizationService
)
{
OrganizationService
.
find_organizations
().
then
(
function
(
result
)
{
var
organizations
=
[];
result
.
forEach
(
function
(
item
)
{
var
org
=
{};
org
.
id
=
item
.
orgId
;
org
.
text
=
item
.
orgName
+
'('
+
item
.
orgId
+
')'
;
organizations
.
push
(
org
);
});
$
(
'#organization'
).
select2
({
placeholder
:
'请选择部门'
,
width
:
'100%'
,
data
:
organizations
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"load organizations error"
);
});
$scope
.
create
=
function
()
{
var
selectedOrg
=
$
(
'#organization'
).
select2
(
'data'
)[
0
];
if
(
!
selectedOrg
.
id
)
{
toastr
.
warning
(
"请选择部门"
);
return
;
}
$scope
.
app
.
orgId
=
selectedOrg
.
id
;
$scope
.
app
.
orgName
=
selectedOrg
.
text
;
AppService
.
create
(
$scope
.
app
).
then
(
function
(
result
)
{
toastr
.
success
(
'添加成功!'
);
setInterval
(
function
()
{
...
...
apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js
View file @
1b7959d6
...
...
@@ -17,9 +17,10 @@ namespace_module.controller("LinkNamespaceController",
publicNamespaces
.
push
(
namespace
);
});
$
(
'#namespaces'
).
select2
({
width
:
'250px'
,
data
:
publicNamespaces
});
placeholder
:
'请选择Namespace'
,
width
:
'100%'
,
data
:
publicNamespaces
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"load public namespace error"
);
});
...
...
@@ -42,7 +43,13 @@ namespace_module.controller("LinkNamespaceController",
}
if
(
$scope
.
namespaceType
==
1
){
$scope
.
namespaceName
=
$
(
'#namespaces'
).
select2
(
'data'
)[
0
].
id
;
var
selectedNamespaceName
=
$
(
'#namespaces'
).
select2
(
'data'
)[
0
].
id
;
if
(
!
selectedNamespaceName
)
{
toastr
.
warning
(
"请选择Namespace"
);
return
;
}
$scope
.
namespaceName
=
selectedNamespaceName
;
}
var
namespaceCreationModels
=
[];
...
...
apollo-portal/src/main/resources/static/scripts/services/OrganizationService.js
0 → 100644
View file @
1b7959d6
appService
.
service
(
"OrganizationService"
,
[
'$resource'
,
'$q'
,
function
(
$resource
,
$q
)
{
var
organization_source
=
$resource
(
""
,
{},
{
find_organizations
:
{
method
:
'GET'
,
isArray
:
true
,
url
:
'/organizations'
}
});
return
{
find_organizations
:
function
()
{
var
d
=
$q
.
defer
();
organization_source
.
find_organizations
({},
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
d
.
reject
(
result
);
});
return
d
.
promise
;
}
}
}]);
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