Commit a4c3f278 by Jason Song Committed by GitHub

Merge pull request #428 from lepdou/loadMore

optimize load more logic
parents 40ef0bd1 a32815ad
...@@ -24,15 +24,16 @@ release_history_module.controller("ReleaseHistoryController", ...@@ -24,15 +24,16 @@ release_history_module.controller("ReleaseHistoryController",
var hasFindActiveRelease = false; var hasFindActiveRelease = false;
function findReleases(page) { function findReleases(page) {
var size = 10;
ReleaseService.findAllRelease($scope.pageContext.appId, ReleaseService.findAllRelease($scope.pageContext.appId,
$scope.pageContext.env, $scope.pageContext.env,
$scope.pageContext.clusterName, $scope.pageContext.clusterName,
$scope.pageContext.namespaceName, $scope.pageContext.namespaceName,
page) page,
size)
.then(function (result) { .then(function (result) {
if (!result || result.length == 0) { if (!result || result.length < size) {
$scope.hasLoadAll = true; $scope.hasLoadAll = true;
return;
} }
var hasParseNamespaceType = false; var hasParseNamespaceType = false;
......
...@@ -166,15 +166,19 @@ directive_module.directive('apollonspanel', ...@@ -166,15 +166,19 @@ directive_module.directive('apollonspanel',
namespace.commits = []; namespace.commits = [];
namespace.commitPage = 0; namespace.commitPage = 0;
} }
var size = 10;
CommitService.find_commits(scope.appId, CommitService.find_commits(scope.appId,
scope.env, scope.env,
scope.cluster, scope.cluster,
namespace.baseInfo.namespaceName, namespace.baseInfo.namespaceName,
namespace.commitPage) namespace.commitPage,
size)
.then(function (result) { .then(function (result) {
if (result.length == 0) { if (result.length < size) {
namespace.hasLoadAllCommit = true; namespace.hasLoadAllCommit = true;
} }
for (var i = 0; i < result.length; i++) { for (var i = 0; i < result.length; i++) {
//to json //to json
result[i].changeSets = JSON.parse(result[i].changeSets); result[i].changeSets = JSON.parse(result[i].changeSets);
...@@ -418,7 +422,6 @@ directive_module.directive('apollonspanel', ...@@ -418,7 +422,6 @@ directive_module.directive('apollonspanel',
return true; return true;
} }
} }
} }
}); });
...@@ -7,14 +7,15 @@ appService.service('CommitService', ['$resource', '$q', function ($resource, $q) ...@@ -7,14 +7,15 @@ appService.service('CommitService', ['$resource', '$q', function ($resource, $q)
} }
}); });
return { return {
find_commits: function (appId, env, clusterName, namespaceName, page) { find_commits: function (appId, env, clusterName, namespaceName, page, size) {
var d = $q.defer(); var d = $q.defer();
commit_resource.find_commits({ commit_resource.find_commits({
appId: appId, appId: appId,
env: env, env: env,
clusterName: clusterName, clusterName: clusterName,
namespaceName: namespaceName, namespaceName: namespaceName,
page: page page: page,
size: size
}, },
function (result) { function (result) {
d.resolve(result); d.resolve(result);
......
...@@ -42,14 +42,15 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q ...@@ -42,14 +42,15 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
return d.promise; return d.promise;
} }
function findAllReleases(appId, env, clusterName, namespaceName, page) { function findAllReleases(appId, env, clusterName, namespaceName, page, size) {
var d = $q.defer(); var d = $q.defer();
resource.find_all_releases({ resource.find_all_releases({
appId: appId, appId: appId,
env: env, env: env,
clusterName: clusterName, clusterName: clusterName,
namespaceName: namespaceName, namespaceName: namespaceName,
page: page page: page,
size: size
}, function (result) { }, function (result) {
d.resolve(result); d.resolve(result);
}, function (result) { }, function (result) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment