Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lepdou
committed
Apr 25, 2016
1 parent
22756eb
commit 0f8aa33
Showing
15 changed files
with
466 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
apollo-portal/src/main/java/com/ctrip/apollo/portal/controller/EnvController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.ctrip.apollo.portal.controller; | ||
|
||
import com.ctrip.apollo.core.enums.Env; | ||
import com.ctrip.apollo.portal.PortalSettings; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/envs") | ||
public class EnvController { | ||
|
||
@Autowired | ||
private PortalSettings portalSettings; | ||
|
||
@RequestMapping(value = "", method = RequestMethod.GET) | ||
public List<Env> envs(){ | ||
return portalSettings.getEnvs(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ ctrip: | |
|
||
apollo: | ||
portal: | ||
env: local | ||
env: local,dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 44 additions & 22 deletions
66
apollo-portal/src/main/resources/static/scripts/controller/IndexController.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,49 @@ | ||
index_module.controller('IndexController', ['$scope', '$window', 'toastr', 'AppService', | ||
function ($scope, $window, toastr, AppService) { | ||
index_module.controller('IndexController', ['$scope', '$window', 'toastr', 'AppService', 'EnvService', | ||
function ($scope, $window, toastr, AppService, EnvService) { | ||
|
||
var apps = []; | ||
AppService.find_all_app().then(function (result) { | ||
apps = result; | ||
$scope.apps = apps; | ||
$scope.appsCount = apps.length; | ||
}); | ||
$scope.envs = []; | ||
$scope.selectedEnv = ''; | ||
EnvService.find_all_envs().then(function (result) { | ||
$scope.envs = result; | ||
//default select first env | ||
$scope.switchEnv($scope.envs[0]); | ||
}, function (result) { | ||
toastr.error(result.status + result.data.message, "load env error"); | ||
}); | ||
|
||
$scope.search = function () { | ||
var key = $scope.searchKey; | ||
if (key == '') { | ||
$scope.apps = apps; | ||
return; | ||
} | ||
var result = []; | ||
apps.forEach(function (item) { | ||
if (item.appId.indexOf(key) >= 0 || item.name.indexOf(key) >= 0) { | ||
result.push(item); | ||
} | ||
}); | ||
var apps = []; | ||
|
||
$scope.switchEnv = function (env) { | ||
$scope.selectedEnv = env; | ||
loadApps(env); | ||
}; | ||
|
||
function loadApps(env){ | ||
AppService.find_all_app(env).then(function (result) { | ||
apps = result; | ||
$scope.apps = apps; | ||
$scope.appsCount = apps.length; | ||
$scope.selectedEnv = env; | ||
}, function (result) { | ||
toastr.error(result.status + result.data.message, "load apps error"); | ||
}); | ||
}; | ||
|
||
|
||
$scope.apps = result; | ||
}; | ||
$scope.search = function () { | ||
var key = $scope.searchKey; | ||
if (key == '') { | ||
$scope.apps = apps; | ||
return; | ||
} | ||
var result = []; | ||
apps.forEach(function (item) { | ||
if (item.appId.indexOf(key) >= 0 || item.name.indexOf(key) >= 0) { | ||
result.push(item); | ||
} | ||
}); | ||
|
||
$scope.apps = result; | ||
}; | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
apollo-portal/src/main/resources/static/scripts/services/EnvService.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
appService.service('EnvService', ['$resource', '$q', function ($resource, $q) { | ||
var env_resource = $resource('/envs', {}, { | ||
find_all_envs:{ | ||
method: 'GET', | ||
isArray: true, | ||
url:'/envs' | ||
} | ||
}); | ||
return { | ||
find_all_envs: function () { | ||
var d = $q.defer(); | ||
env_resource.find_all_envs({ | ||
}, | ||
function (result) { | ||
d.resolve(result); | ||
}, function (result) { | ||
d.reject(result); | ||
}); | ||
return d.promise; | ||
} | ||
} | ||
}]); |
Oops, something went wrong.