mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-24 12:47:00 +00:00
Fix #9738
This commit is contained in:
@@ -57,11 +57,11 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
public function index(): JsonResponse
|
public function index(): JsonResponse
|
||||||
{
|
{
|
||||||
$piggies = $this->repository->getAll();
|
$entries = $this->repository->getAll();
|
||||||
$pageSize = $this->parameters->get('limit');
|
$pageSize = $this->parameters->get('limit');
|
||||||
$count = $piggies->count();
|
$count = $entries->count();
|
||||||
$piggies = $piggies->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
$entries = $entries->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
$paginator = new LengthAwarePaginator($piggies, $count, $pageSize, $this->parameters->get('page'));
|
$paginator = new LengthAwarePaginator($entries, $count, $pageSize, $this->parameters->get('page'));
|
||||||
$transformer = new ExchangeRateTransformer();
|
$transformer = new ExchangeRateTransformer();
|
||||||
$transformer->setParameters($this->parameters); // give params to transformer
|
$transformer->setParameters($this->parameters); // give params to transformer
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,6 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface
|
|||||||
#[\Override]
|
#[\Override]
|
||||||
public function getAll(): Collection
|
public function getAll(): Collection
|
||||||
{
|
{
|
||||||
return $this->userGroup->currencyExchangeRates()->get();
|
return $this->userGroup->currencyExchangeRates()->orderBy('date','ASC')->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,12 @@
|
|||||||
"/public/v1/js/app.js.LICENSE.txt": "/public/v1/js/app.js.LICENSE.txt",
|
"/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": "/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/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": "/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/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": "/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/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",
|
"/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-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/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/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/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/accounting.min.js": "/public/v1/js/lib/accounting.min.js",
|
||||||
"/public/v1/js/lib/bootstrap-multiselect.js": "/public/v1/js/lib/bootstrap-multiselect.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/lib/vue.js": "/public/v1/js/lib/vue.js",
|
||||||
"/public/v1/js/profile.js": "/public/v1/js/profile.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/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": "/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/create.js.LICENSE.txt": "/public/v1/js/webhooks/create.js.LICENSE.txt",
|
||||||
"/public/v1/js/webhooks/edit.js": "/public/v1/js/webhooks/edit.js",
|
"/public/v1/js/webhooks/edit.js": "/public/v1/js/webhooks/edit.js",
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currencies: [],
|
currencies: [],
|
||||||
|
page: 1,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -65,6 +66,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
getCurrencies: function () {
|
getCurrencies: function () {
|
||||||
this.currencies = [];
|
this.currencies = [];
|
||||||
|
// start with page one, loop for the rest.
|
||||||
this.downloadCurrencies(1);
|
this.downloadCurrencies(1);
|
||||||
},
|
},
|
||||||
downloadCurrencies: function (page) {
|
downloadCurrencies: function (page) {
|
||||||
|
|||||||
@@ -42,6 +42,27 @@
|
|||||||
<h3 class="box-title">{{ $t('firefly.header_exchange_rates_table') }}</h3>
|
<h3 class="box-title">{{ $t('firefly.header_exchange_rates_table') }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body no-padding">
|
<div class="box-body no-padding">
|
||||||
|
<nav v-if="totalPages > 1">
|
||||||
|
<ul class="pagination">
|
||||||
|
<li v-if="1 === this.page" class="page-item disabled" aria-disabled="true" :aria-label="$t('pagination.previous')">
|
||||||
|
<span class="page-link" aria-hidden="true">‹</span>
|
||||||
|
</li>
|
||||||
|
<li class="page-item" v-if="1 !== this.page">
|
||||||
|
<a class="page-link" :href="'/exchange-rates/'+from_code+'/'+to_code+'?page=' + (this.page-1)" rel="prev" :aria-label="$t('pagination.next')">‹</a>
|
||||||
|
</li>
|
||||||
|
<li v-for="item in this.totalPages" :class="item === page ? 'page-item active' : 'page-item'" aria-current="page">
|
||||||
|
<span v-if="item === page" class="page-link" v-text="item"></span>
|
||||||
|
<a v-if="item !== page" class="page-link" :href="'/exchange-rates/'+from_code+'/'+to_code+'?page=' + item" v-text="item"></a>
|
||||||
|
</li>
|
||||||
|
<li v-if="totalPages !== page" class="page-item">
|
||||||
|
<a class="page-link" :href="'/exchange-rates/'+from_code+'/'+to_code+'?page=' + (this.page+1)" rel="next" :aria-label="$t('pagination.next')">›</a>
|
||||||
|
</li>
|
||||||
|
<li v-if="totalPages === page" class="page-item disabled" aria-disabled="true" :aria-label="$t('pagination.next')">
|
||||||
|
<span class="page-link" aria-hidden="true">›</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<table class="table table-responsive table-hover">
|
<table class="table table-responsive table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -98,6 +119,28 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<nav v-if="totalPages > 1">
|
||||||
|
<ul class="pagination">
|
||||||
|
<li v-if="1 === this.page" class="page-item disabled" aria-disabled="true" :aria-label="$t('pagination.previous')">
|
||||||
|
<span class="page-link" aria-hidden="true">‹</span>
|
||||||
|
</li>
|
||||||
|
<li class="page-item" v-if="1 !== this.page">
|
||||||
|
<a class="page-link" :href="'/exchange-rates/'+from_code+'/'+to_code+'?page=' + (this.page-1)" rel="prev" :aria-label="$t('pagination.next')">‹</a>
|
||||||
|
</li>
|
||||||
|
<li v-for="item in this.totalPages" :class="item === page ? 'page-item active' : 'page-item'" aria-current="page">
|
||||||
|
<span v-if="item === page" class="page-link" v-text="item"></span>
|
||||||
|
<a v-if="item !== page" class="page-link" :href="'/exchange-rates/'+from_code+'/'+to_code+'?page=' + item" v-text="item"></a>
|
||||||
|
</li>
|
||||||
|
<li v-if="totalPages !== page" class="page-item">
|
||||||
|
<a class="page-link" :href="'/exchange-rates/'+from_code+'/'+to_code+'?page=' + (this.page+1)" rel="next" :aria-label="$t('pagination.next')">›</a>
|
||||||
|
</li>
|
||||||
|
<li v-if="totalPages === page" class="page-item disabled" aria-disabled="true" :aria-label="$t('pagination.next')">
|
||||||
|
<span class="page-link" aria-hidden="true">›</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -167,6 +210,8 @@ export default {
|
|||||||
loading: true,
|
loading: true,
|
||||||
posting: false,
|
posting: false,
|
||||||
updating: false,
|
updating: false,
|
||||||
|
page: 1,
|
||||||
|
totalPages: 1,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -175,8 +220,16 @@ export default {
|
|||||||
let parts = window.location.href.split('/');
|
let parts = window.location.href.split('/');
|
||||||
this.from_code = parts[parts.length - 2].substring(0, 3);
|
this.from_code = parts[parts.length - 2].substring(0, 3);
|
||||||
this.to_code = parts[parts.length - 1].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.downloadCurrencies();
|
||||||
this.downloadRates(1);
|
this.rates = [];
|
||||||
|
this.downloadRates(this.page);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submitRate: function(e) {
|
submitRate: function(e) {
|
||||||
@@ -203,16 +256,11 @@ export default {
|
|||||||
return ('' === this.rates[index].rate && '' === this.rates[index].inverse) || this.updating;
|
return ('' === this.rates[index].rate && '' === this.rates[index].inverse) || this.updating;
|
||||||
},
|
},
|
||||||
updateRate: function (index) {
|
updateRate: function (index) {
|
||||||
// console.log('Update!');
|
|
||||||
// console.log(this.rates[index].key);
|
|
||||||
let parts = this.spliceKey(this.rates[index].key);
|
let parts = this.spliceKey(this.rates[index].key);
|
||||||
if (0 === parts.length) {
|
if (0 === parts.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ('' !== this.rates[index].rate) {
|
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;
|
this.updating = true;
|
||||||
axios.put("./api/v1/exchange-rates/" + this.rates[index].rate_id, {rate: this.rates[index].rate})
|
axios.put("./api/v1/exchange-rates/" + this.rates[index].rate_id, {rate: this.rates[index].rate})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -220,9 +268,6 @@ export default {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ('' !== this.rates[index].inverse) {
|
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;
|
this.updating = true;
|
||||||
axios.put("./api/v1/exchange-rates/" + this.rates[index].inverse_id, {rate: this.rates[index].inverse})
|
axios.put("./api/v1/exchange-rates/" + this.rates[index].inverse_id, {rate: this.rates[index].inverse})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -281,7 +326,6 @@ export default {
|
|||||||
},
|
},
|
||||||
downloadRates: function (page) {
|
downloadRates: function (page) {
|
||||||
this.tempRates = {};
|
this.tempRates = {};
|
||||||
this.rates = [];
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
axios.get("./api/v1/exchange-rates/rates/" + this.from_code + '/' + this.to_code + '?page=' + page).then((response) => {
|
axios.get("./api/v1/exchange-rates/rates/" + this.from_code + '/' + this.to_code + '?page=' + page).then((response) => {
|
||||||
for (let i in response.data.data) {
|
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.totalPages = parseInt(response.data.meta.pagination.total_pages);
|
||||||
this.downloadRates(page + 1);
|
this.loading = false;
|
||||||
}
|
this.rates = Object.values(this.tempRates);
|
||||||
if (parseInt(response.data.meta.pagination.current_page) === parseInt(response.data.meta.pagination.total_pages)) {
|
console.log('Do not download more pages. Now on page ' + this.page + ' of ' + this.totalPages);
|
||||||
this.loading = false;
|
|
||||||
this.rates = Object.values(this.tempRates);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user