New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sites manager first last buttons #12276
Changes from all commits
1f78b32
fc5265c
23adc45
792313a
b2ed63a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ | |
(function () { | ||
angular.module('piwikApp').factory('sitesManagerAdminSitesModel', sitesManagerAdminSitesModel); | ||
|
||
sitesManagerAdminSitesModel.$inject = ['piwikApi']; | ||
sitesManagerAdminSitesModel.$inject = ['piwikApi', 'sitesManagerAPI']; | ||
|
||
function sitesManagerAdminSitesModel(piwikApi) | ||
function sitesManagerAdminSitesModel(piwikApi, sitesManagerAPI) | ||
{ | ||
var model = { | ||
sites : [], | ||
|
@@ -16,10 +16,14 @@ | |
currentPage : 0, | ||
offsetStart : 0, | ||
offsetEnd : 10, | ||
hasFirst : false, | ||
hasPrev : false, | ||
hasNext : false, | ||
hasLast : false, | ||
firstPage: firstPage, | ||
previousPage: previousPage, | ||
nextPage: nextPage, | ||
lastPage: lastPage, | ||
searchSite: searchSite, | ||
fetchLimitedSitesWithAdminAccess: fetchLimitedSitesWithAdminAccess | ||
}; | ||
|
@@ -38,8 +42,10 @@ | |
var numSites = sites.length; | ||
model.offsetStart = model.currentPage * model.pageSize; | ||
model.offsetEnd = model.offsetStart + numSites; | ||
model.hasFirst = model.currentPage >= 1; | ||
model.hasPrev = model.currentPage >= 1; | ||
model.hasNext = numSites === model.pageSize; | ||
model.hasLast = numSites === model.pageSize; | ||
} | ||
|
||
function setCurrentPage(page) | ||
|
@@ -51,6 +57,12 @@ | |
model.currentPage = page; | ||
} | ||
|
||
function firstPage() | ||
{ | ||
setCurrentPage(0); | ||
fetchLimitedSitesWithAdminAccess(); | ||
} | ||
|
||
function previousPage() | ||
{ | ||
setCurrentPage(model.currentPage - 1); | ||
|
@@ -63,6 +75,16 @@ | |
fetchLimitedSitesWithAdminAccess(); | ||
} | ||
|
||
function lastPage() | ||
{ | ||
sitesManagerAPI.getSitesIdWithAdminAccess(function (siteIds) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't tested it, but I reckon it might not work when the user is currently searching for a site and then goes to the last page because I think here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, yes you are right. |
||
if (siteIds && siteIds.length) { | ||
setCurrentPage(Math.floor(siteIds.length / model.pageSize)); | ||
fetchLimitedSitesWithAdminAccess(); | ||
} | ||
}); | ||
} | ||
|
||
function searchSite (term) | ||
{ | ||
model.searchTerm = term; | ||
|
@@ -84,8 +106,9 @@ | |
var params = { | ||
method: 'SitesManager.getSitesWithAdminAccess', | ||
fetchAliasUrls: true, | ||
limit: limit + offset, // this is applied in SitesManager.getSitesWithAdminAccess API | ||
filter_offset: offset, // filter_offset and filter_limit is applied in response builder | ||
limit: limit, // this is applied in SitesManager.getSitesWithAdminAccess API | ||
offset: offset, // this is applied in SitesManager.getSitesWithAdminAccess API | ||
filter_offset: 0, // filter_offset and filter_limit is applied in response builder | ||
filter_limit: limit | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The offset would need to be applied here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean in
getPatternMatchSites