diff --git a/frontend/src/api/accounts/destroy.js b/frontend/src/api/accounts/destroy.js deleted file mode 100644 index 3b784bf218..0000000000 --- a/frontend/src/api/accounts/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/accounts/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/accounts/get.js b/frontend/src/api/accounts/get.js index 6d9cb854ed..e6cf5163fd 100644 --- a/frontend/src/api/accounts/get.js +++ b/frontend/src/api/accounts/get.js @@ -18,18 +18,34 @@ * along with this program. If not, see . */ -import {api} from "boot/axios"; +import Api from "src/api/root/api"; -export default class Get { - get(identifier, date) { - let url = '/api/v1/accounts/' + identifier; - if(!date) { - return api.get(url); - } - return api.get(url, {params: {date: date}}); +export default class Get extends Api { + constructor() { + super('accounts'); // call the super class constructor and pass in the name parameter } - transactions(identifier, page, cacheKey) { - let url = '/api/v1/accounts/' + identifier + '/transactions'; - return api.get(url, {params: {page: page, cache: cacheKey}}); + + /** + * + * @param identifier + * @param date + * @returns {Promise>} + */ + get(identifier, date) { + let params = {date: date}; + if(!date) { + return this.apiGet(identifier); + } + return this.apiGet(identifier, params); + } + + /** + * + * @param identifier + * @param page + * @returns {Promise>} + */ + transactions(identifier, page) { + return this.apiGetChildren('transactions', identifier, page); } } diff --git a/frontend/src/api/accounts/list.js b/frontend/src/api/accounts/list.js index 90a0fea825..72b5f4e20b 100644 --- a/frontend/src/api/accounts/list.js +++ b/frontend/src/api/accounts/list.js @@ -19,10 +19,27 @@ */ import {api} from "boot/axios"; +import Api from "src/api/root/api"; + +export default class List extends Api{ + constructor() { + super('accounts'); + } -export default class List { list(type, page, cacheKey) { let url = '/api/v1/accounts'; return api.get(url, {params: {page: page, cache: cacheKey, type: type}}); + // console.log('list'); + // + // + // let params = { + // type: type, + // page: page + // } + // this.apiList(page, params).then((response) => { + // console.log('response OK'); + // }).catch((err) => { + // console.error('api list failed'); + // }); } } diff --git a/frontend/src/api/budgets/destroy.js b/frontend/src/api/budgets/destroy.js deleted file mode 100644 index 3b17de392a..0000000000 --- a/frontend/src/api/budgets/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = 'api/v1/budgets/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/categories/destroy.js b/frontend/src/api/categories/destroy.js deleted file mode 100644 index dcb150dc0d..0000000000 --- a/frontend/src/api/categories/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/categories/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/currencies/destroy.js b/frontend/src/api/currencies/destroy.js deleted file mode 100644 index f9ec216790..0000000000 --- a/frontend/src/api/currencies/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/currencies/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/rules/destroy.js b/frontend/src/api/generic/destroy.js similarity index 82% rename from frontend/src/api/rules/destroy.js rename to frontend/src/api/generic/destroy.js index 025f961208..90e32cb0dd 100644 --- a/frontend/src/api/rules/destroy.js +++ b/frontend/src/api/generic/destroy.js @@ -1,5 +1,5 @@ /* - * post.js + * destroy.js * Copyright (c) 2022 james@firefly-iii.org * * This file is part of Firefly III (https://github.com/firefly-iii). @@ -18,11 +18,10 @@ * along with this program. If not, see . */ -import {api} from "boot/axios"; +import Api from "src/api/root/api"; -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/rules/' + identifier; - return api.delete(url); +export default class Destroy extends Api { + constructor(path) { + super(path); } } diff --git a/frontend/src/api/groups/destroy.js b/frontend/src/api/groups/destroy.js deleted file mode 100644 index a21e6ba7d1..0000000000 --- a/frontend/src/api/groups/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/object_groups/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/piggy-banks/destroy.js b/frontend/src/api/piggy-banks/destroy.js deleted file mode 100644 index f7d7a24744..0000000000 --- a/frontend/src/api/piggy-banks/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/piggy_banks/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/recurring/destroy.js b/frontend/src/api/recurring/destroy.js deleted file mode 100644 index ffb61a8ac7..0000000000 --- a/frontend/src/api/recurring/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/recurrences/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/root/api.js b/frontend/src/api/root/api.js new file mode 100644 index 0000000000..54695ee1a1 --- /dev/null +++ b/frontend/src/api/root/api.js @@ -0,0 +1,104 @@ +import {api} from "boot/axios"; + +/** + * + */ +export default class Api { + root = '/api/v1/'; + path = ''; + + constructor(path) { + this.path = path; + } + + apiPath() { + return this.root + this.path; + } + + apiPathId(identifier) { + return this.root + this.path + '/' + identifier; + } + + /** + * + * @param identifier + * @param params + * @returns {Promise>} + */ + apiGet(identifier, params) { + let url = this.apiPathId(identifier); + if (params) { + return api.get(url, {params: params}); + } + return api.get(url); + } + + destroy(identifier) { + let url = this.apiPathId(identifier); + return api.delete(url); + } + + apiPathChildren(identifier, type) { + return this.apiPathId(identifier) + '/' + type; + } + + apiGetChildren(type, identifier, page) { + let url = this.apiPathChildren(identifier, type); + let cacheKey = 'still-todo'; + // needs a cache key. Based on type. + return api.get(url, {params: {page: page, cache: cacheKey}}); + } + + + /** + * + * @param page + * @param params + * @returns {Promise>} + */ + apiList(page, params) { + let type = 'transactions'; + let identifier = '1'; + + let cacheKey = 'still-todo'; + let url = this.apiPathChildren(identifier, type); + + // needs a cache key. Based on type. + return api.get(url, {params: {page: page, cache: cacheKey}}); + + + // let identifier = 'abc'; + // // test: + // let type= 'expense'; + + // let type ='accounts'; + // + // this.store.getters["fireflyiii/getScopedCacheKey"](type); + // let cacheKey = 'def'; + // let url = this.apiPath(); + // + // // needs a cache key. Based on type. + // return api.get(url, {params: {page: page, cache: cacheKey}}); + + // + // + // console.log('apiList'); + // let cacheKey; + // + // //let $q = useQuasar(); + // //const store = useStore(); + // cacheKey = 'OK'; + // console.log('path: ' + this.path); + // //cacheKey = $store.getters["fireflyiii/getScopedCacheKey"](this.path); + // //store.getters["fireflyiii/getScopedCacheKey"](this.path) + // let cache = { + // cache: cacheKey + // }; + // let merged = {...params, ...cache}; + // console.log(merged); + // let url = this.apiPath(); + // console.log(url); + // return api.get(url, {params: merged}); + } + +} diff --git a/frontend/src/api/rule-groups/destroy.js b/frontend/src/api/rule-groups/destroy.js deleted file mode 100644 index f72620bf1a..0000000000 --- a/frontend/src/api/rule-groups/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/rule_groups/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/subscriptions/destroy.js b/frontend/src/api/subscriptions/destroy.js deleted file mode 100644 index 83bb5c833c..0000000000 --- a/frontend/src/api/subscriptions/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/bills/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/transactions/destroy.js b/frontend/src/api/transactions/destroy.js deleted file mode 100644 index 1eca9641a6..0000000000 --- a/frontend/src/api/transactions/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/transactions/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/api/webhooks/destroy.js b/frontend/src/api/webhooks/destroy.js deleted file mode 100644 index b99a699a89..0000000000 --- a/frontend/src/api/webhooks/destroy.js +++ /dev/null @@ -1,28 +0,0 @@ -/* - * post.js - * Copyright (c) 2022 james@firefly-iii.org - * - * This file is part of Firefly III (https://github.com/firefly-iii). - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import {api} from "boot/axios"; - -export default class Destroy { - destroy(identifier) { - let url = '/api/v1/webhooks/' + identifier; - return api.delete(url); - } -} diff --git a/frontend/src/pages/accounts/Index.vue b/frontend/src/pages/accounts/Index.vue index 6e91c86a10..18671cd1d2 100644 --- a/frontend/src/pages/accounts/Index.vue +++ b/frontend/src/pages/accounts/Index.vue @@ -5,7 +5,6 @@ :rows="rows" :columns="columns" row-key="id" - @request="onRequest" v-model:pagination="pagination" :loading="loading" class="q-ma-md" @@ -75,7 +74,7 @@