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 <rohit.yadav@shapeblue.com>
This commit is contained in:
Philipp Bankonier 2019-08-07 11:29:27 +02:00 committed by Rohit Yadav
parent 1e05b89e19
commit f8f0a99e26
1 changed files with 24 additions and 12 deletions

View File

@ -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')