From f8f0a99e268fa2e5c1a4d94ac3a5a20fcf547dc6 Mon Sep 17 00:00:00 2001 From: Philipp Bankonier Date: Wed, 7 Aug 2019 11:29:27 +0200 Subject: [PATCH] Fix project selection request (#4) Add necessary args to listProjects request for project selection Currently the project selector does not work, because some arguments where missing in the request. I added these arguments and also added the userid as the CURRENT_USER to the application store. Signed-off-by: Rohit Yadav --- ui/src/components/tools/ProjectMenu.vue | 36 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/ui/src/components/tools/ProjectMenu.vue b/ui/src/components/tools/ProjectMenu.vue index e6e1da1c2eb..42aec0ce088 100644 --- a/ui/src/components/tools/ProjectMenu.vue +++ b/ui/src/components/tools/ProjectMenu.vue @@ -40,19 +40,31 @@ export default { if (this.isDisabled()) { return } - api('listProjects').then(json => { - this.projects = [{ name: 'Default View' }] - if (json && json.listprojectsresponse && json.listprojectsresponse.project) { - this.projects.push(...json.listprojectsresponse.project) - } - const currentProject = Vue.ls.get(CURRENT_PROJECT) - for (var project of this.projects) { - if (project.id === currentProject.id) { - this.selectedProject = project.name - break + // TODO: refactor fetching project list for project selector + this.projects = [] + var page = 1 + const getNextPage = () => { + api('listProjects', { listAll: true, details: 'min', page: page, pageSize: 500 }).then(json => { + if (this.projects.length === 0) { + this.projects.push({ name: 'Default View' }) } - } - }) + if (json && json.listprojectsresponse && json.listprojectsresponse.project) { + this.projects.push(...json.listprojectsresponse.project) + } + const currentProject = Vue.ls.get(CURRENT_PROJECT) + for (var project of this.projects) { + if (project.id === currentProject.id) { + this.selectedProject = project.name + break + } + } + if (this.projects.length - 1 < json.listprojectsresponse.count) { + page++ + getNextPage() + } + }) + } + getNextPage() }, isDisabled () { return !store.getters.apis.hasOwnProperty('listProjects')