add app orderer

This commit is contained in:
Simon Vieille
2025-04-12 14:58:40 +02:00
parent c8eed69672
commit ab64a13fc1
6 changed files with 215 additions and 54 deletions
+22 -28
View File
@@ -21,48 +21,42 @@ import axios from '@nextcloud/axios'
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
export const useNavStore = defineStore('nav', () => {
const categories = ref(null)
const apps = ref(null)
const coreApps = ref(null)
let categories = null
let apps = null
let coreApps = null
async function getApps() {
if (apps.value !== null) {
return apps.value
if (apps === null) {
apps = []
const cats = await getCategories()
cats.forEach((category) => {
Object.values(category.apps).forEach((app) => {
apps.push(app)
})
})
}
apps.value = []
const cats = await getCategories()
cats.forEach((category) => {
Object.values(category.apps).forEach((app) => {
apps.value.push(app)
})
})
return apps.value
return apps
}
async function getCoreApps() {
if (coreApps.value !== null) {
return coreApps.value
if (coreApps == null) {
coreApps = await axios
.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json')
.then((response) => response.data)
.then((value) => value.ocs.data)
}
coreApps.value = await axios
.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json')
.then((response) => response.data)
.then((value) => value.ocs.data)
return coreApps.value
return coreApps
}
async function getCategories() {
if (categories.value !== null) {
return categories.value
if (categories === null) {
categories = await axios.get(generateUrl('/apps/side_menu/nav/items')).then((response) => response.data.items)
}
categories.value = await axios.get(generateUrl('/apps/side_menu/nav/items')).then((response) => response.data.items)
return categories.value
return categories
}
return {