Skip to content
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

feat: use web history mode #2480

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,29 @@
*/
return [
'routes' => [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'collections#getCollections','url' => '/collections', 'verb' => 'GET'],
['name' => 'collections#setVisibility', 'url' => '/collection/{collectionID}/visibility/{visibility}', 'verb' => 'POST'],
['name' => 'settings#get', 'url' => '/settings', 'verb' => 'GET'],
['name' => 'settings#set', 'url' => '/settings/{setting}', 'verb' => 'POST'],
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#index', 'url' => '/calendars', 'verb' => 'GET', 'postfix' => 'view.calendars'],
['name' => 'page#index', 'url' => '/calendars/', 'verb' => 'GET', 'postfix' => 'view.calendars./'],
[
'name' => 'page#index',
'url' => '/calendars/{calendar}',
'verb' => 'GET',
'postfix' => 'view.calendars.calendar',
'requirements' => array('calendar' => '.+')
],
['name' => 'page#index', 'url' => '/collections', 'verb' => 'GET', 'postfix' => 'view.collections'],
['name' => 'page#index', 'url' => '/collections/', 'verb' => 'GET', 'postfix' => 'view.collections./'],
[
'name' => 'page#index',
'url' => '/collections/{collection}',
'verb' => 'GET',
'postfix' => 'view.collections.collection',
'requirements' => array('collection' => '.+')
],

['name' => 'collections#getCollections','url' => '/api/v1/collections', 'verb' => 'GET'],
['name' => 'collections#setVisibility', 'url' => '/api/v1/collection/{collectionID}/visibility/{visibility}', 'verb' => 'POST'],
['name' => 'settings#get', 'url' => '/api/v1/settings', 'verb' => 'GET'],
['name' => 'settings#set', 'url' => '/api/v1/settings/{setting}', 'verb' => 'POST'],
]
];
12 changes: 10 additions & 2 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ import AppSidebar from './views/AppSidebar.vue'
import Calendar from './views/AppContent/Calendar.vue'
import Collections from './views/AppContent/Collections.vue'

import { getRootUrl, generateUrl } from '@nextcloud/router'

import { h } from 'vue'
import { createWebHashHistory, createRouter, RouterView } from 'vue-router'
import { createWebHistory, createRouter, RouterView } from 'vue-router'

const webRootWithIndexPHP = getRootUrl() + '/index.php'
const doesURLContainIndexPHP = window.location.pathname.startsWith(webRootWithIndexPHP)
const base = generateUrl('apps/tasks', {}, {
noRewrite: doesURLContainIndexPHP,
})
raimund-schluessler marked this conversation as resolved.
Show resolved Hide resolved

const routes = [
{ path: '/', redirect: getInitialRoute() },
Expand Down Expand Up @@ -81,7 +89,7 @@ const routes = [
]

const router = createRouter({
history: createWebHashHistory(),
history: createWebHistory(base),
routes,
})

Expand Down
4 changes: 2 additions & 2 deletions src/store/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const actions = {
*/
loadCollections({ commit }) {
return new Promise(function(resolve) {
Requests.get(generateUrl('apps/tasks/collections'))
Requests.get(generateUrl('apps/tasks/api/v1/collections'))
.then(response => {
commit('setCollections', {
collections: response.data.data.collections,
Expand All @@ -123,7 +123,7 @@ const actions = {
setVisibility(context, collection) {
context.commit('setVisibility', collection)
return new Promise(function() {
Requests.post(generateUrl('apps/tasks/collection/{id}/visibility/{show}', collection), {})
Requests.post(generateUrl('apps/tasks/api/v1/collection/{id}/visibility/{show}', collection), {})
})
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const actions = {
setSetting(context, payload) {
context.commit('setSetting', payload)
return new Promise(function() {
Requests.post(generateUrl('apps/tasks/settings/{type}', payload), { value: payload.value })
Requests.post(generateUrl('apps/tasks/api/v1/settings/{type}', payload), { value: payload.value })
})
},

Expand Down
Loading