Skip to content

Commit

Permalink
Merge pull request #824 from telosnetwork/develop
Browse files Browse the repository at this point in the history
save user pagination settings
  • Loading branch information
donnyquixotic authored Dec 21, 2023
2 parents 0f87815 + ed0b9bf commit 37aadec
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
8 changes: 3 additions & 5 deletions src/components/AccountCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default defineComponent({
const createTransaction = ref<string>('');
const creatingAccount = ref('');
const system_account = ref('eosio');
const system_null = ref('eosio.null');
const isLoading = ref<boolean>(true);
const tokensLoading = ref<boolean>(true);
Expand Down Expand Up @@ -178,7 +177,7 @@ export default defineComponent({
const loadResources = () => {
let ramDenominator;
if (props.account !== system_account.value && props.account !== system_null.value) {
if (props.account !== system_account.value) {
// display max resource unit value for readability
const ramMaxNumber = Number(accountData.value.ram_quota);
const ramUnitResult = determineUnit(ramMaxNumber);
Expand Down Expand Up @@ -327,7 +326,7 @@ export default defineComponent({
return total;
};
const fixDec = (val: number): number => parseFloat(val.toFixed(3));
const fixDec = (val: number): number => Math.abs(parseFloat(val.toFixed(3)));
const loadSystemToken = (): void => {
if (token.value.symbol === '') {
Expand Down Expand Up @@ -445,7 +444,6 @@ export default defineComponent({
rexDeposits,
none,
system_account,
system_null,
radius,
availableTokens,
createTime,
Expand Down Expand Up @@ -519,7 +517,7 @@ export default defineComponent({
</div>
<q-space/>
</div>
<div v-if="account !== system_account && account !== system_null" class="resources">
<div v-if="account !== system_account" class="resources">
<PercentCircle
v-if="!accountPageSettings.hideCpuInfo"
:radius="radius"
Expand Down
8 changes: 3 additions & 5 deletions src/components/AccountSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ export default defineComponent({
};
const accounts = await api.getTableByScope(request);
// because the get table by scope for userres does not include eosio system or null accounts
// get table by scope for userres does not include system account
if (value.includes('eosio')) {
accounts.push(...[{
accounts.unshift({
payer: 'eosio',
} as TableByScope, {
payer: 'eosio.null',
} as TableByScope]);
} as TableByScope);
}
if (accounts.length > 0) {
Expand Down
10 changes: 4 additions & 6 deletions src/components/HeaderSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default defineComponent({
isLoading.value = false;
};
const onInput = debounce(fetchData, 100);
const onInput = debounce(fetchData, 200);
watch(inputValue, onInput);
Expand All @@ -53,13 +53,11 @@ export default defineComponent({
};
const accounts = await api.getTableByScope(request);
// because the get table by scope for userres does not include eosio system or null accounts
// get table by scope for userres does not include system account
if (value.includes('eosio')) {
accounts.unshift(...[{
accounts.unshift({
payer: 'eosio',
} as TableByScope, {
payer: 'eosio.null',
} as TableByScope]);
} as TableByScope);
}
if (accounts.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/PercentCircle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default defineComponent({
const fractionUnits = computed(
() => `${fraction.value}${unit.value}/${total.value}${unit.value}`,
);
const available = computed(() => (total.value - fraction.value).toFixed(3));
const available = computed(() => Math.abs(total.value - fraction.value).toFixed(3));
const dashArray = computed(() => {
if (Number.isNaN(formatResourcePercent.value)) {
return '0';
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProposalAuthorization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default defineComponent({
});
if (accounts.length > 0) {
// because the get table by scope for userres does not include eosio account
// get table by scope for userres does not include system account
if ('eosio'.includes(value)) {
actorsOptions.value.push('eosio');
}
Expand Down
27 changes: 21 additions & 6 deletions src/components/TransactionsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ const chain: Chain = getChain();
const TWO_SECONDS = 2000;
const pageSizeOptions = [10, 20, 50, 100, 200];
const getStoredRowSetting = () => {
const savedRowsPerPage = localStorage.getItem('txRowsPerPage');
let rowsPerPageNum = parseInt(savedRowsPerPage);
// if saved value was NOT integer (valid)
if (isNaN(rowsPerPageNum)) {
// then use a valid value and replace invalid value in localStorage
rowsPerPageNum = pageSizeOptions[0];
localStorage.setItem('txRowsPerPage', rowsPerPageNum.toString());
}
return rowsPerPageNum;
};
export default defineComponent({
name: 'TransactionsTable',
components: {
Expand Down Expand Up @@ -73,10 +87,6 @@ export default defineComponent({
setup(props) {
const route = useRoute();
const router = useRouter();
const pagination = computed(
() => (route.query['page'] as string) || '1,10',
);
const pageSizeOptions = [10, 20, 50, 100, 200];
const { account, actions } = toRefs(props);
const columns = [
{
Expand Down Expand Up @@ -123,17 +133,22 @@ export default defineComponent({
paginationSettings.value.rowsPerPage = size;
paginationSettings.value.page = 1;
await onPaginationChange({ pagination: paginationSettings.value });
localStorage.setItem('txRowsPerPage', size.toString());
};
const changePagination = async (page: number, size: number) => {
paginationSettings.value.page = page;
paginationSettings.value.rowsPerPage = size;
await onPaginationChange({ pagination: paginationSettings.value });
};
const pagination = computed(
() => (route.query['page'] as string) || `1,${getStoredRowSetting()}`,
);
const paginationSettings = ref<PaginationSettings>({
sortBy: 'timestamp',
descending: true,
page: 1,
rowsPerPage: pageSizeOptions[0],
rowsPerPage: getStoredRowSetting(),
rowsNumber: 10000,
});
Expand Down Expand Up @@ -454,7 +469,7 @@ export default defineComponent({
async () => {
let pageValue = pagination.value;
let page = 1;
let size = pageSizeOptions[0];
let size = getStoredRowSetting();
// we also allow to pass a single number as the page number
if (typeof pageValue === 'number') {
Expand Down

0 comments on commit 37aadec

Please sign in to comment.