Commit a32815ad by zhangle

optimize load more logic

parent 40ef0bd1
......@@ -24,15 +24,16 @@ release_history_module.controller("ReleaseHistoryController",
var hasFindActiveRelease = false;
function findReleases(page) {
var size = 10;
ReleaseService.findAllRelease($scope.pageContext.appId,
$scope.pageContext.env,
$scope.pageContext.clusterName,
$scope.pageContext.namespaceName,
page)
page,
size)
.then(function (result) {
if (!result || result.length == 0) {
if (!result || result.length < size) {
$scope.hasLoadAll = true;
return;
}
var hasParseNamespaceType = false;
......
......@@ -166,15 +166,19 @@ directive_module.directive('apollonspanel',
namespace.commits = [];
namespace.commitPage = 0;
}
var size = 10;
CommitService.find_commits(scope.appId,
scope.env,
scope.cluster,
namespace.baseInfo.namespaceName,
namespace.commitPage)
namespace.commitPage,
size)
.then(function (result) {
if (result.length == 0) {
if (result.length < size) {
namespace.hasLoadAllCommit = true;
}
for (var i = 0; i < result.length; i++) {
//to json
result[i].changeSets = JSON.parse(result[i].changeSets);
......@@ -418,7 +422,6 @@ directive_module.directive('apollonspanel',
return true;
}
}
}
});
......@@ -7,14 +7,15 @@ appService.service('CommitService', ['$resource', '$q', function ($resource, $q)
}
});
return {
find_commits: function (appId, env, clusterName, namespaceName, page) {
find_commits: function (appId, env, clusterName, namespaceName, page, size) {
var d = $q.defer();
commit_resource.find_commits({
appId: appId,
env: env,
clusterName: clusterName,
namespaceName: namespaceName,
page: page
page: page,
size: size
},
function (result) {
d.resolve(result);
......
......@@ -42,14 +42,15 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
return d.promise;
}
function findAllReleases(appId, env, clusterName, namespaceName, page) {
function findAllReleases(appId, env, clusterName, namespaceName, page, size) {
var d = $q.defer();
resource.find_all_releases({
appId: appId,
env: env,
clusterName: clusterName,
namespaceName: namespaceName,
page: page
page: page,
size: size
}, function (result) {
d.resolve(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