diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php index c61138e859..d9dcb4a06d 100644 --- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php +++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php @@ -57,11 +57,11 @@ class IndexController extends Controller public function index(): JsonResponse { - $piggies = $this->repository->getAll(); + $entries = $this->repository->getAll(); $pageSize = $this->parameters->get('limit'); - $count = $piggies->count(); - $piggies = $piggies->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); - $paginator = new LengthAwarePaginator($piggies, $count, $pageSize, $this->parameters->get('page')); + $count = $entries->count(); + $entries = $entries->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); + $paginator = new LengthAwarePaginator($entries, $count, $pageSize, $this->parameters->get('page')); $transformer = new ExchangeRateTransformer(); $transformer->setParameters($this->parameters); // give params to transformer diff --git a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php index 9c153d9b9c..e0edbf1dda 100644 --- a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php +++ b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php @@ -108,6 +108,6 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface #[\Override] public function getAll(): Collection { - return $this->userGroup->currencyExchangeRates()->get(); + return $this->userGroup->currencyExchangeRates()->orderBy('date','ASC')->get(); } } diff --git a/resources/assets/v1/mix-manifest.json b/resources/assets/v1/mix-manifest.json index ff2938f703..9f22a4fe0f 100644 --- a/resources/assets/v1/mix-manifest.json +++ b/resources/assets/v1/mix-manifest.json @@ -20,8 +20,12 @@ "/public/v1/js/app.js.LICENSE.txt": "/public/v1/js/app.js.LICENSE.txt", "/public/v1/js/app_vue.js": "/public/v1/js/app_vue.js", "/public/v1/js/app_vue.js.LICENSE.txt": "/public/v1/js/app_vue.js.LICENSE.txt", + "/public/v1/js/create.js": "/public/v1/js/create.js", + "/public/v1/js/create.js.LICENSE.txt": "/public/v1/js/create.js.LICENSE.txt", "/public/v1/js/create_transaction.js": "/public/v1/js/create_transaction.js", "/public/v1/js/create_transaction.js.LICENSE.txt": "/public/v1/js/create_transaction.js.LICENSE.txt", + "/public/v1/js/edit.js": "/public/v1/js/edit.js", + "/public/v1/js/edit.js.LICENSE.txt": "/public/v1/js/edit.js.LICENSE.txt", "/public/v1/js/edit_transaction.js": "/public/v1/js/edit_transaction.js", "/public/v1/js/edit_transaction.js.LICENSE.txt": "/public/v1/js/edit_transaction.js.LICENSE.txt", "/public/v1/js/exchange-rates/index.js": "/public/v1/js/exchange-rates/index.js", @@ -96,6 +100,8 @@ "/public/v1/js/ff/transactions/mass/edit-bulk.js": "/public/v1/js/ff/transactions/mass/edit-bulk.js", "/public/v1/js/ff/transactions/mass/edit.js": "/public/v1/js/ff/transactions/mass/edit.js", "/public/v1/js/ff/transactions/show.js": "/public/v1/js/ff/transactions/show.js", + "/public/v1/js/index.js": "/public/v1/js/index.js", + "/public/v1/js/index.js.LICENSE.txt": "/public/v1/js/index.js.LICENSE.txt", "/public/v1/js/lib/Chart.bundle.min.js": "/public/v1/js/lib/Chart.bundle.min.js", "/public/v1/js/lib/accounting.min.js": "/public/v1/js/lib/accounting.min.js", "/public/v1/js/lib/bootstrap-multiselect.js": "/public/v1/js/lib/bootstrap-multiselect.js", @@ -154,6 +160,8 @@ "/public/v1/js/lib/vue.js": "/public/v1/js/lib/vue.js", "/public/v1/js/profile.js": "/public/v1/js/profile.js", "/public/v1/js/profile.js.LICENSE.txt": "/public/v1/js/profile.js.LICENSE.txt", + "/public/v1/js/show.js": "/public/v1/js/show.js", + "/public/v1/js/show.js.LICENSE.txt": "/public/v1/js/show.js.LICENSE.txt", "/public/v1/js/webhooks/create.js": "/public/v1/js/webhooks/create.js", "/public/v1/js/webhooks/create.js.LICENSE.txt": "/public/v1/js/webhooks/create.js.LICENSE.txt", "/public/v1/js/webhooks/edit.js": "/public/v1/js/webhooks/edit.js", diff --git a/resources/assets/v1/src/components/exchange-rates/Index.vue b/resources/assets/v1/src/components/exchange-rates/Index.vue index 38f44a84ad..80afc156d9 100644 --- a/resources/assets/v1/src/components/exchange-rates/Index.vue +++ b/resources/assets/v1/src/components/exchange-rates/Index.vue @@ -57,6 +57,7 @@ export default { data() { return { currencies: [], + page: 1, }; }, mounted() { @@ -65,6 +66,7 @@ export default { methods: { getCurrencies: function () { this.currencies = []; + // start with page one, loop for the rest. this.downloadCurrencies(1); }, downloadCurrencies: function (page) { diff --git a/resources/assets/v1/src/components/exchange-rates/Rates.vue b/resources/assets/v1/src/components/exchange-rates/Rates.vue index 3c8250756e..3639830270 100644 --- a/resources/assets/v1/src/components/exchange-rates/Rates.vue +++ b/resources/assets/v1/src/components/exchange-rates/Rates.vue @@ -42,6 +42,27 @@

{{ $t('firefly.header_exchange_rates_table') }}

+ + @@ -98,6 +119,28 @@
+ + +
@@ -167,6 +210,8 @@ export default { loading: true, posting: false, updating: false, + page: 1, + totalPages: 1, }; }, mounted() { @@ -175,8 +220,16 @@ export default { let parts = window.location.href.split('/'); this.from_code = parts[parts.length - 2].substring(0, 3); this.to_code = parts[parts.length - 1].substring(0, 3); + + const params = new Proxy(new URLSearchParams(window.location.search), { + get: (searchParams, prop) => searchParams.get(prop), + }); + this.page = parseInt(params.page ?? 1); + + this.downloadCurrencies(); - this.downloadRates(1); + this.rates = []; + this.downloadRates(this.page); }, methods: { submitRate: function(e) { @@ -203,16 +256,11 @@ export default { return ('' === this.rates[index].rate && '' === this.rates[index].inverse) || this.updating; }, updateRate: function (index) { - // console.log('Update!'); - // console.log(this.rates[index].key); let parts = this.spliceKey(this.rates[index].key); if (0 === parts.length) { return; } if ('' !== this.rates[index].rate) { - // update rate - // console.log('Rate is ' + this.rates[index].rate); - // console.log('ID is ' + this.rates[index].rate_id); this.updating = true; axios.put("./api/v1/exchange-rates/" + this.rates[index].rate_id, {rate: this.rates[index].rate}) .then(() => { @@ -220,9 +268,6 @@ export default { }); } if ('' !== this.rates[index].inverse) { - // update inverse - // console.log('Inverse is ' + this.rates[index].inverse); - // console.log('Inverse ID is ' + this.rates[index].inverse_id); this.updating = true; axios.put("./api/v1/exchange-rates/" + this.rates[index].inverse_id, {rate: this.rates[index].inverse}) .then(() => { @@ -281,7 +326,6 @@ export default { }, downloadRates: function (page) { this.tempRates = {}; - this.rates = []; this.loading = true; axios.get("./api/v1/exchange-rates/rates/" + this.from_code + '/' + this.to_code + '?page=' + page).then((response) => { for (let i in response.data.data) { @@ -334,13 +378,10 @@ export default { } } - if (parseInt(response.data.meta.pagination.current_page) < parseInt(response.data.meta.pagination.total_pages)) { - this.downloadRates(page + 1); - } - if (parseInt(response.data.meta.pagination.current_page) === parseInt(response.data.meta.pagination.total_pages)) { - this.loading = false; - this.rates = Object.values(this.tempRates); - } + this.totalPages = parseInt(response.data.meta.pagination.total_pages); + this.loading = false; + this.rates = Object.values(this.tempRates); + console.log('Do not download more pages. Now on page ' + this.page + ' of ' + this.totalPages); }); } },