mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-04 05:15:39 +00:00 
			
		
		
		
	Experiment with forage store.
This commit is contained in:
		@@ -35,6 +35,8 @@
 | 
			
		||||
        "icheck-bootstrap": "^3.0.1",
 | 
			
		||||
        "jquery-ui": "^1.12.1",
 | 
			
		||||
        "leaflet": "^1.7.1",
 | 
			
		||||
        "localforage": "^1.9.0",
 | 
			
		||||
        "localforage-memoryStorageDriver": "^0.9.2",
 | 
			
		||||
        "overlayscrollbars": "^1.13.1",
 | 
			
		||||
        "sortablejs": "^1.13.0",
 | 
			
		||||
        "v-calendar": "^2.3.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -33,11 +33,9 @@
 | 
			
		||||
    <div class="row">
 | 
			
		||||
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
 | 
			
		||||
        <div class="card">
 | 
			
		||||
          <div class="card-header">
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="card-body p-0">
 | 
			
		||||
            <b-table id="my-table" striped hover responsive="md" primary-key="id" :no-local-sorting="true"
 | 
			
		||||
                     :items="itemsProvider" :fields="fields"
 | 
			
		||||
            <b-table id="my-table" striped hover responsive="md" primary-key="id" :no-local-sorting="false"
 | 
			
		||||
                     :items="accounts" :fields="fields"
 | 
			
		||||
                     :per-page="perPage"
 | 
			
		||||
                     sort-icon-left
 | 
			
		||||
                     ref="table"
 | 
			
		||||
@@ -46,13 +44,14 @@
 | 
			
		||||
                     :sort-by.sync="sortBy"
 | 
			
		||||
                     :sort-desc.sync="sortDesc"
 | 
			
		||||
            >
 | 
			
		||||
              <template #table-busy>
 | 
			
		||||
                <i class="fa fa-spinner"></i>
 | 
			
		||||
              </template>
 | 
			
		||||
              <template #cell(name)="data">
 | 
			
		||||
                <a :class="false === data.item.active ? 'text-muted' : ''" :href="'./accounts/show/' + data.item.id" :title="data.value">{{ data.value }}</a>
 | 
			
		||||
              </template>
 | 
			
		||||
              <template #cell(number)="data">
 | 
			
		||||
                <span v-if="null !== data.item.iban && null === data.item.account_number">{{ data.item.iban }}</span>
 | 
			
		||||
                <span v-if="null === data.item.iban && null !== data.item.account_number">{{ data.item.account_number }}</span>
 | 
			
		||||
                <span v-if="null !== data.item.iban && null !== data.item.account_number">{{ data.item.iban }} ({{ data.item.account_number }})</span>
 | 
			
		||||
              <template #cell(acct_number)="data">
 | 
			
		||||
                {{ data.item.acct_number }}
 | 
			
		||||
              </template>
 | 
			
		||||
              <template #cell(last_activity)="data">
 | 
			
		||||
                <span v-if="'asset' === type && 'loading' === data.item.last_activity">
 | 
			
		||||
@@ -150,10 +149,21 @@
 | 
			
		||||
          </div>
 | 
			
		||||
          <div class="card-footer">
 | 
			
		||||
            <a :href="'./accounts/create/' + type" class="btn btn-success" :title="$t('firefly.create_new_' + type)">{{ $t('firefly.create_new_' + type) }}</a>
 | 
			
		||||
            <a href="#" class="btn btn-info"><i class="fas fa-sync"></i></a>
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="row">
 | 
			
		||||
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
 | 
			
		||||
        <b-pagination
 | 
			
		||||
            v-model="currentPage"
 | 
			
		||||
            :total-rows="total"
 | 
			
		||||
            :per-page="perPage"
 | 
			
		||||
            aria-controls="my-table"
 | 
			
		||||
        ></b-pagination>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
@@ -162,10 +172,12 @@
 | 
			
		||||
import {mapGetters} from "vuex";
 | 
			
		||||
import Sortable from "sortablejs";
 | 
			
		||||
import format from "date-fns/format";
 | 
			
		||||
import {setup} from 'axios-cache-adapter'
 | 
			
		||||
import {setup} from 'axios-cache-adapter';
 | 
			
		||||
// import {cacheAdapterEnhancer} from 'axios-extensions';
 | 
			
		||||
// pas wat teruggeven als die pagina ook gevraagd wordt, anders een empty array
 | 
			
		||||
// van X lang?
 | 
			
		||||
import {configureAxios} from "../../shared/forageStore";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// get all and cache, dont keep the table busy.
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
  name: "Index",
 | 
			
		||||
@@ -197,13 +209,13 @@ export default {
 | 
			
		||||
  },
 | 
			
		||||
  watch: {
 | 
			
		||||
    storeReady: function () {
 | 
			
		||||
      //this.getAccountList();
 | 
			
		||||
      this.getAccountList();
 | 
			
		||||
    },
 | 
			
		||||
    start: function () {
 | 
			
		||||
      //this.getAccountList();
 | 
			
		||||
      this.getAccountList();
 | 
			
		||||
    },
 | 
			
		||||
    end: function () {
 | 
			
		||||
      //this.getAccountList();
 | 
			
		||||
      this.getAccountList();
 | 
			
		||||
    },
 | 
			
		||||
    orderMode: function (value) {
 | 
			
		||||
      // update the table headers
 | 
			
		||||
@@ -263,25 +275,25 @@ export default {
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  methods: {
 | 
			
		||||
    itemsProvider: function (ctx, callback) {
 | 
			
		||||
      console.log('itemsProvider()');
 | 
			
		||||
      console.log('ctx.currentPage = ' + ctx.currentPage);
 | 
			
		||||
      console.log('this.currentPage = ' + this.currentPage);
 | 
			
		||||
      if (ctx.currentPage === this.currentPage) {
 | 
			
		||||
        let direction = this.sortDesc ? '-' : '+';
 | 
			
		||||
        let url = 'api/v1/accounts?type=' + this.type + '&page=' + ctx.currentPage + '&sort=' + direction + this.sortBy;
 | 
			
		||||
        this.api.get(url)
 | 
			
		||||
            .then(async (response) => {
 | 
			
		||||
                    this.total = parseInt(response.data.meta.pagination.total);
 | 
			
		||||
                    let items = this.parseAccountsAndReturn(response.data.data);
 | 
			
		||||
                    items = this.filterAccountListAndReturn(items);
 | 
			
		||||
                    callback(items);
 | 
			
		||||
                  }
 | 
			
		||||
            );
 | 
			
		||||
        return null;
 | 
			
		||||
      }
 | 
			
		||||
      return [];
 | 
			
		||||
    },
 | 
			
		||||
    // itemsProvider: function (ctx, callback) {
 | 
			
		||||
    //   console.log('itemsProvider()');
 | 
			
		||||
    //   console.log('ctx.currentPage = ' + ctx.currentPage);
 | 
			
		||||
    //   console.log('this.currentPage = ' + this.currentPage);
 | 
			
		||||
    //   if (ctx.currentPage === this.currentPage) {
 | 
			
		||||
    //     let direction = this.sortDesc ? '-' : '+';
 | 
			
		||||
    //     let url = 'api/v1/accounts?type=' + this.type + '&page=' + ctx.currentPage + '&sort=' + direction + this.sortBy;
 | 
			
		||||
    //     this.api.get(url)
 | 
			
		||||
    //         .then(async (response) => {
 | 
			
		||||
    //                 this.total = parseInt(response.data.meta.pagination.total);
 | 
			
		||||
    //                 let items = this.parseAccountsAndReturn(response.data.data);
 | 
			
		||||
    //                 items = this.filterAccountListAndReturn(items);
 | 
			
		||||
    //                 callback(items);
 | 
			
		||||
    //               }
 | 
			
		||||
    //         );
 | 
			
		||||
    //     return null;
 | 
			
		||||
    //   }
 | 
			
		||||
    //   return [];
 | 
			
		||||
    // },
 | 
			
		||||
 | 
			
		||||
    saveAccountSort: function (event) {
 | 
			
		||||
      let oldIndex = parseInt(event.oldIndex);
 | 
			
		||||
@@ -333,7 +345,7 @@ export default {
 | 
			
		||||
        this.fields.push({key: 'interest', label: this.$t('list.interest') + ' (' + this.$t('list.interest_period') + ')', sortable: !this.orderMode});
 | 
			
		||||
      }
 | 
			
		||||
      // add the rest
 | 
			
		||||
      this.fields.push({key: 'number', label: this.$t('list.iban'), sortable: !this.orderMode});
 | 
			
		||||
      this.fields.push({key: 'acct_number', label: this.$t('list.iban'), sortable: !this.orderMode});
 | 
			
		||||
      this.fields.push({key: 'current_balance', label: this.$t('list.currentBalance'), sortable: !this.orderMode});
 | 
			
		||||
      if ('liabilities' === this.type) {
 | 
			
		||||
        this.fields.push({key: 'amount_due', label: this.$t('firefly.left_in_debt'), sortable: !this.orderMode});
 | 
			
		||||
@@ -344,45 +356,50 @@ export default {
 | 
			
		||||
      this.fields.push({key: 'menu', label: ' ', sortable: false});
 | 
			
		||||
    },
 | 
			
		||||
    getAccountList: function () {
 | 
			
		||||
      // console.log('getAccountList()');
 | 
			
		||||
      console.log('getAccountList()');
 | 
			
		||||
      if (this.indexReady && !this.loading && !this.downloaded) {
 | 
			
		||||
        // console.log('Index ready, not loading and not already downloaded. Reset.');
 | 
			
		||||
        console.log('Index ready, not loading and not already downloaded. Reset.');
 | 
			
		||||
        this.loading = true;
 | 
			
		||||
        this.perPage = this.listPageSize ?? 51;
 | 
			
		||||
        this.accounts = [];
 | 
			
		||||
        this.allAccounts = [];
 | 
			
		||||
        //this.downloadAccountList(1);
 | 
			
		||||
        this.downloadAccountList(1);
 | 
			
		||||
      }
 | 
			
		||||
      if (this.indexReady && !this.loading && this.downloaded) {
 | 
			
		||||
        // console.log('Index ready, not loading and not downloaded.');
 | 
			
		||||
        console.log('Index ready, not loading and not downloaded.');
 | 
			
		||||
        this.loading = true;
 | 
			
		||||
        this.filterAccountList();
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    downloadAccountList: function (page) {
 | 
			
		||||
      const http = axios.create({
 | 
			
		||||
                                  baseURL: './',
 | 
			
		||||
                                  headers: {'Cache-Control': 'no-cache'},
 | 
			
		||||
                                });
 | 
			
		||||
      console.log('downloadAccountList(' + page + ')');
 | 
			
		||||
 | 
			
		||||
      // console.log('downloadAccountList(' + page + ')');
 | 
			
		||||
      http.get('./api/v1/accounts?type=' + this.type + '&page=' + page)
 | 
			
		||||
          .then(response => {
 | 
			
		||||
                  let currentPage = parseInt(response.data.meta.pagination.current_page);
 | 
			
		||||
                  let totalPage = parseInt(response.data.meta.pagination.total_pages);
 | 
			
		||||
                  this.total = parseInt(response.data.meta.pagination.total);
 | 
			
		||||
                  this.parseAccounts(response.data.data);
 | 
			
		||||
                  if (currentPage < totalPage) {
 | 
			
		||||
                    let nextPage = currentPage + 1;
 | 
			
		||||
                    this.downloadAccountList(nextPage);
 | 
			
		||||
      // configure().then(async (api) => {
 | 
			
		||||
      //   const response = await api.get('/url')
 | 
			
		||||
      //
 | 
			
		||||
      //   // Display something beautiful with `response.data` ;)
 | 
			
		||||
      // })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      configureAxios().then(async (api) => {
 | 
			
		||||
        api.get('./api/v1/accounts?type=' + this.type + '&page=' + page)
 | 
			
		||||
            .then(response => {
 | 
			
		||||
                    let currentPage = parseInt(response.data.meta.pagination.current_page);
 | 
			
		||||
                    let totalPage = parseInt(response.data.meta.pagination.total_pages);
 | 
			
		||||
                    this.total = parseInt(response.data.meta.pagination.total);
 | 
			
		||||
                    this.parseAccounts(response.data.data);
 | 
			
		||||
                    if (currentPage < totalPage) {
 | 
			
		||||
                      let nextPage = currentPage + 1;
 | 
			
		||||
                      this.downloadAccountList(nextPage);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (currentPage >= totalPage) {
 | 
			
		||||
                      // console.log('Looks like all downloaded.');
 | 
			
		||||
                      this.downloaded = true;
 | 
			
		||||
                      this.filterAccountList();
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                  if (currentPage >= totalPage) {
 | 
			
		||||
                    // console.log('Looks like all downloaded.');
 | 
			
		||||
                    this.downloaded = true;
 | 
			
		||||
                    this.filterAccountList();
 | 
			
		||||
                  }
 | 
			
		||||
                }
 | 
			
		||||
          );
 | 
			
		||||
            );
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    filterAccountListAndReturn: function (allAccounts) {
 | 
			
		||||
      console.log('filterAccountListAndReturn()');
 | 
			
		||||
@@ -439,51 +456,51 @@ export default {
 | 
			
		||||
    },
 | 
			
		||||
    parsePages: function (data) {
 | 
			
		||||
      this.total = parseInt(data.pagination.total);
 | 
			
		||||
      //console.log('Total is now ' + this.total);
 | 
			
		||||
    },
 | 
			
		||||
    parseAccountsAndReturn: function (data) {
 | 
			
		||||
      console.log('In parseAccountsAndReturn()');
 | 
			
		||||
      let allAccounts = [];
 | 
			
		||||
      for (let key in data) {
 | 
			
		||||
        if (data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
 | 
			
		||||
          let current = data[key];
 | 
			
		||||
          let acct = {};
 | 
			
		||||
          acct.id = parseInt(current.id);
 | 
			
		||||
          acct.order = current.attributes.order;
 | 
			
		||||
          acct.name = current.attributes.name;
 | 
			
		||||
          acct.active = current.attributes.active;
 | 
			
		||||
          acct.role = this.roleTranslate(current.attributes.account_role);
 | 
			
		||||
          acct.account_number = current.attributes.account_number;
 | 
			
		||||
          acct.current_balance = current.attributes.current_balance;
 | 
			
		||||
          acct.currency_code = current.attributes.currency_code;
 | 
			
		||||
 | 
			
		||||
          if ('liabilities' === this.type) {
 | 
			
		||||
            acct.liability_type = this.$t('firefly.account_type_' + current.attributes.liability_type);
 | 
			
		||||
            acct.liability_direction = this.$t('firefly.liability_direction_' + current.attributes.liability_direction + '_short');
 | 
			
		||||
            acct.interest = current.attributes.interest;
 | 
			
		||||
            acct.interest_period = this.$t('firefly.interest_calc_' + current.attributes.interest_period);
 | 
			
		||||
            acct.amount_due = current.attributes.current_debt;
 | 
			
		||||
          }
 | 
			
		||||
          acct.balance_diff = 'loading';
 | 
			
		||||
          acct.last_activity = 'loading';
 | 
			
		||||
 | 
			
		||||
          if (null !== current.attributes.iban) {
 | 
			
		||||
            acct.iban = current.attributes.iban.match(/.{1,4}/g).join(' ');
 | 
			
		||||
          }
 | 
			
		||||
          if (null === current.attributes.iban) {
 | 
			
		||||
            acct.iban = null;
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          allAccounts.push(acct);
 | 
			
		||||
          if ('asset' === this.type) {
 | 
			
		||||
            // TODO
 | 
			
		||||
            //this.getAccountBalanceDifference(this.allAccounts.length - 1, current);
 | 
			
		||||
            //this.getAccountLastActivity(this.allAccounts.length - 1, current);
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return allAccounts;
 | 
			
		||||
      console.log('Total is now ' + this.total);
 | 
			
		||||
    },
 | 
			
		||||
    // parseAccountsAndReturn: function (data) {
 | 
			
		||||
    //   console.log('In parseAccountsAndReturn()');
 | 
			
		||||
    //   let allAccounts = [];
 | 
			
		||||
    //   for (let key in data) {
 | 
			
		||||
    //     if (data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
 | 
			
		||||
    //       let current = data[key];
 | 
			
		||||
    //       let acct = {};
 | 
			
		||||
    //       acct.id = parseInt(current.id);
 | 
			
		||||
    //       acct.order = current.attributes.order;
 | 
			
		||||
    //       acct.name = current.attributes.name;
 | 
			
		||||
    //       acct.active = current.attributes.active;
 | 
			
		||||
    //       acct.role = this.roleTranslate(current.attributes.account_role);
 | 
			
		||||
    //       acct.account_number = current.attributes.account_number;
 | 
			
		||||
    //       acct.current_balance = current.attributes.current_balance;
 | 
			
		||||
    //       acct.currency_code = current.attributes.currency_code;
 | 
			
		||||
    //
 | 
			
		||||
    //       if ('liabilities' === this.type) {
 | 
			
		||||
    //         acct.liability_type = this.$t('firefly.account_type_' + current.attributes.liability_type);
 | 
			
		||||
    //         acct.liability_direction = this.$t('firefly.liability_direction_' + current.attributes.liability_direction + '_short');
 | 
			
		||||
    //         acct.interest = current.attributes.interest;
 | 
			
		||||
    //         acct.interest_period = this.$t('firefly.interest_calc_' + current.attributes.interest_period);
 | 
			
		||||
    //         acct.amount_due = current.attributes.current_debt;
 | 
			
		||||
    //       }
 | 
			
		||||
    //       acct.balance_diff = 'loading';
 | 
			
		||||
    //       acct.last_activity = 'loading';
 | 
			
		||||
    //
 | 
			
		||||
    //       if (null !== current.attributes.iban) {
 | 
			
		||||
    //         acct.iban = current.attributes.iban.match(/.{1,4}/g).join(' ');
 | 
			
		||||
    //       }
 | 
			
		||||
    //       if (null === current.attributes.iban) {
 | 
			
		||||
    //         acct.iban = null;
 | 
			
		||||
    //       }
 | 
			
		||||
    //
 | 
			
		||||
    //       allAccounts.push(acct);
 | 
			
		||||
    //       if ('asset' === this.type) {
 | 
			
		||||
    //         // TODO
 | 
			
		||||
    //         //this.getAccountBalanceDifference(this.allAccounts.length - 1, current);
 | 
			
		||||
    //         //this.getAccountLastActivity(this.allAccounts.length - 1, current);
 | 
			
		||||
    //       }
 | 
			
		||||
    //     }
 | 
			
		||||
    //   }
 | 
			
		||||
    //   return allAccounts;
 | 
			
		||||
    // },
 | 
			
		||||
    parseAccounts: function (data) {
 | 
			
		||||
      // console.log('In parseAccounts()');
 | 
			
		||||
      for (let key in data) {
 | 
			
		||||
@@ -495,7 +512,32 @@ export default {
 | 
			
		||||
          acct.name = current.attributes.name;
 | 
			
		||||
          acct.active = current.attributes.active;
 | 
			
		||||
          acct.role = this.roleTranslate(current.attributes.account_role);
 | 
			
		||||
          acct.account_number = current.attributes.account_number;
 | 
			
		||||
 | 
			
		||||
          // account number in 'acct_number'
 | 
			
		||||
          acct.acct_number = '';
 | 
			
		||||
          let iban = null;
 | 
			
		||||
          let acctNr = null;
 | 
			
		||||
          acct.acct_number = '';
 | 
			
		||||
          if (null !== current.attributes.iban) {
 | 
			
		||||
            iban = current.attributes.iban.match(/.{1,4}/g).join(' ');
 | 
			
		||||
          }
 | 
			
		||||
          if (null !== current.attributes.account_number) {
 | 
			
		||||
            acctNr = current.attributes.account_number;
 | 
			
		||||
          }
 | 
			
		||||
          // only account nr
 | 
			
		||||
          if(null === iban && null !== acctNr) {
 | 
			
		||||
            acct.acct_number = acctNr;
 | 
			
		||||
          }
 | 
			
		||||
          // only iban
 | 
			
		||||
          if(null !== iban && null === acctNr) {
 | 
			
		||||
            acct.acct_number = iban;
 | 
			
		||||
          }
 | 
			
		||||
          // both:
 | 
			
		||||
          if(null !== iban && null !== acctNr) {
 | 
			
		||||
            acct.acct_number = iban + ' (' + acctNr + ')';
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
          acct.current_balance = current.attributes.current_balance;
 | 
			
		||||
          acct.currency_code = current.attributes.currency_code;
 | 
			
		||||
 | 
			
		||||
@@ -509,13 +551,6 @@ export default {
 | 
			
		||||
          acct.balance_diff = 'loading';
 | 
			
		||||
          acct.last_activity = 'loading';
 | 
			
		||||
 | 
			
		||||
          if (null !== current.attributes.iban) {
 | 
			
		||||
            acct.iban = current.attributes.iban.match(/.{1,4}/g).join(' ');
 | 
			
		||||
          }
 | 
			
		||||
          if (null === current.attributes.iban) {
 | 
			
		||||
            acct.iban = null;
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
          this.allAccounts.push(acct);
 | 
			
		||||
          if ('asset' === this.type) {
 | 
			
		||||
            this.getAccountBalanceDifference(this.allAccounts.length - 1, current);
 | 
			
		||||
@@ -566,7 +601,3 @@ export default {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style scoped>
 | 
			
		||||
 | 
			
		||||
</style>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										61
									
								
								frontend/src/shared/forageStore.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								frontend/src/shared/forageStore.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
/*
 | 
			
		||||
 * forageStore.js
 | 
			
		||||
 * Copyright (c) 2021 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 <https://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import localforage from 'localforage'
 | 
			
		||||
import memoryDriver from 'localforage-memoryStorageDriver'
 | 
			
		||||
import {setup} from 'axios-cache-adapter'
 | 
			
		||||
 | 
			
		||||
// `async` wrapper to configure `localforage` and instantiate `axios` with `axios-cache-adapter`
 | 
			
		||||
export async function configureAxios() {
 | 
			
		||||
    // Register the custom `memoryDriver` to `localforage`
 | 
			
		||||
    await localforage.defineDriver(memoryDriver)
 | 
			
		||||
 | 
			
		||||
    // Create `localforage` instance
 | 
			
		||||
    const forageStore = localforage.createInstance({
 | 
			
		||||
                                                       // List of drivers used
 | 
			
		||||
                                                       driver: [
 | 
			
		||||
                                                           localforage.INDEXEDDB,
 | 
			
		||||
                                                           localforage.LOCALSTORAGE,
 | 
			
		||||
                                                           memoryDriver._driver
 | 
			
		||||
                                                       ],
 | 
			
		||||
                                                       // Prefix all storage keys to prevent conflicts
 | 
			
		||||
                                                       name: 'my-cache'
 | 
			
		||||
                                                   })
 | 
			
		||||
 | 
			
		||||
    // Create `axios` instance with pre-configured `axios-cache-adapter` using a `localforage` store
 | 
			
		||||
    let token = document.head.querySelector('meta[name="csrf-token"]');
 | 
			
		||||
    return setup({
 | 
			
		||||
                     // `axios` options
 | 
			
		||||
                     baseURL: './',
 | 
			
		||||
                     headers: {'X-CSRF-TOKEN': token.content, 'X-James-Rocks': 'oh yes'},
 | 
			
		||||
                     cache: {
 | 
			
		||||
                         // `axios-cache-adapter` options
 | 
			
		||||
                         maxAge: 24 * 60 * 60 * 1000, // one day.
 | 
			
		||||
                         readHeaders: false,
 | 
			
		||||
                         exclude: {
 | 
			
		||||
                             query: false,
 | 
			
		||||
                         },
 | 
			
		||||
                         debug: true,
 | 
			
		||||
                         store: forageStore,
 | 
			
		||||
                     }
 | 
			
		||||
                 }
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -1088,9 +1088,9 @@
 | 
			
		||||
  integrity sha512-1z8k4wzFnNjVK/tlxvrWuK5WMt6mydWWP7+zvH5eFep4oj+UkrfiJTRtjCeBXNpwaA/FYqqtb4/QS4ianFpIRA==
 | 
			
		||||
 | 
			
		||||
"@types/node@*":
 | 
			
		||||
  version "15.6.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/@types/node/-/node-15.6.0.tgz#f0ddca5a61e52627c9dcb771a6039d44694597bc"
 | 
			
		||||
  integrity sha512-gCYSfQpy+LYhOFTKAeE8BkyGqaxmlFxe+n4DKM6DR0wzw/HISUE/hAmkC/KT8Sw5PCJblqg062b3z9gucv3k0A==
 | 
			
		||||
  version "15.6.1"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/@types/node/-/node-15.6.1.tgz#32d43390d5c62c5b6ec486a9bc9c59544de39a08"
 | 
			
		||||
  integrity sha512-7EIraBEyRHEe7CH+Fm1XvgqU6uwZN8Q7jppJGcqjROMT29qhAuuOxYB1uEY5UMYQKEmA5D+5tBnhdaPXSsLONA==
 | 
			
		||||
 | 
			
		||||
"@types/parse-glob@*":
 | 
			
		||||
  version "3.0.29"
 | 
			
		||||
@@ -2107,9 +2107,9 @@ chart.js@^2.9.4:
 | 
			
		||||
    moment "^2.10.2"
 | 
			
		||||
 | 
			
		||||
chart.js@^3.2.0:
 | 
			
		||||
  version "3.2.1"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-3.2.1.tgz#1a17d6a88cef324ef711949e227eb51d6c4c26d3"
 | 
			
		||||
  integrity sha512-XsNDf3854RGZkLCt+5vWAXGAtUdKP2nhfikLGZqud6G4CvRE2ts64TIxTTfspOin2kEZvPgomE29E6oU02dYjQ==
 | 
			
		||||
  version "3.3.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-3.3.0.tgz#c5be3807cf902b19bfe166ef853d786f66a53f8b"
 | 
			
		||||
  integrity sha512-3pO3kL2st1Lzhw+HTGvDwcNYWustHwvApM/v7b2td6CrthyEygbPoXaN/iGZfUpfuovZfJ4dy129RCr39BR1Bg==
 | 
			
		||||
 | 
			
		||||
chartjs-color-string@^0.6.0:
 | 
			
		||||
  version "0.6.0"
 | 
			
		||||
@@ -2570,9 +2570,9 @@ css-declaration-sorter@^4.0.1:
 | 
			
		||||
    timsort "^0.3.0"
 | 
			
		||||
 | 
			
		||||
css-loader@^5.0.0:
 | 
			
		||||
  version "5.2.5"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-5.2.5.tgz#cdd18d6fe42748990793b4a7ec32eb16f36ba9d7"
 | 
			
		||||
  integrity sha512-bH6QQacvSRtLX0lycAOs43S173n+lfXxB5cx4FjVkTLw5tAEwk5bxNLbkt5K1iETd5KxazRx70GpqOxsuwKiFA==
 | 
			
		||||
  version "5.2.6"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-5.2.6.tgz#c3c82ab77fea1f360e587d871a6811f4450cc8d1"
 | 
			
		||||
  integrity sha512-0wyN5vXMQZu6BvjbrPdUJvkCzGEO24HC7IS7nW4llc6BBFC+zwR9CKtYGv63Puzsg10L/o12inMY5/2ByzfD6w==
 | 
			
		||||
  dependencies:
 | 
			
		||||
    icss-utils "^5.1.0"
 | 
			
		||||
    loader-utils "^2.0.0"
 | 
			
		||||
@@ -3116,9 +3116,9 @@ dns-equal@^1.0.0:
 | 
			
		||||
  integrity sha1-s55/HabrCnW6nBcySzR1PEfgZU0=
 | 
			
		||||
 | 
			
		||||
dns-packet@^1.3.1:
 | 
			
		||||
  version "1.3.1"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-1.3.1.tgz#12aa426981075be500b910eedcd0b47dd7deda5a"
 | 
			
		||||
  integrity sha512-0UxfQkMhYAUaZI+xrNZOz/as5KgDU0M/fQ9b6SpkyLbk3GEswDi6PADJVaYJradtRVsRIlF1zLyOodbcTCDzUg==
 | 
			
		||||
  version "1.3.3"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-1.3.3.tgz#7b62ee6e6aaac0c2de27cfc4a06af59cacb9cb38"
 | 
			
		||||
  integrity sha512-dDwDMOJU+m6Qx+LhltSV+BWNrMaTqx3eXkAqgt/iouWTXGZMffg1rOSnG2xa3lWqmJ9xTBc7fgIe/css4S1rxA==
 | 
			
		||||
  dependencies:
 | 
			
		||||
    ip "^1.1.0"
 | 
			
		||||
    safe-buffer "^5.0.1"
 | 
			
		||||
@@ -3241,9 +3241,9 @@ ekko-lightbox@^5.3.0:
 | 
			
		||||
  integrity sha512-mbacwySuVD3Ad6F2hTkjSTvJt59bcVv2l/TmBerp4xZnLak8tPtA4AScUn4DL42c1ksTiAO6sGhJZ52P/1Qgew==
 | 
			
		||||
 | 
			
		||||
electron-to-chromium@^1.3.723:
 | 
			
		||||
  version "1.3.735"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.735.tgz#fa1a8660f2790662291cb2136f0e446a444cdfdc"
 | 
			
		||||
  integrity sha512-cp7MWzC3NseUJV2FJFgaiesdrS+A8ZUjX5fLAxdRlcaPDkaPGFplX930S5vf84yqDp4LjuLdKouWuVOTwUfqHQ==
 | 
			
		||||
  version "1.3.738"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.738.tgz#aec24b091c82acbfabbdcce08076a703941d17ca"
 | 
			
		||||
  integrity sha512-vCMf4gDOpEylPSLPLSwAEsz+R3ShP02Y3cAKMZvTqule3XcPp7tgc/0ESI7IS6ZeyBlGClE50N53fIOkcIVnpw==
 | 
			
		||||
 | 
			
		||||
elliptic@^6.5.3:
 | 
			
		||||
  version "6.5.4"
 | 
			
		||||
@@ -3299,9 +3299,9 @@ error-ex@^1.3.1:
 | 
			
		||||
    is-arrayish "^0.2.1"
 | 
			
		||||
 | 
			
		||||
es-abstract@^1.17.2, es-abstract@^1.18.0-next.2:
 | 
			
		||||
  version "1.18.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0.tgz#ab80b359eecb7ede4c298000390bc5ac3ec7b5a4"
 | 
			
		||||
  integrity sha512-LJzK7MrQa8TS0ja2w3YNLzUgJCGPdPOV1yVvezjNnS89D+VR08+Szt2mz3YB2Dck/+w5tfIq/RoUAFqJJGM2yw==
 | 
			
		||||
  version "1.18.1"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.1.tgz#6ea1152314618f2d7ab572e9d86c715f4ca08d24"
 | 
			
		||||
  integrity sha512-LEPRJp87wbQP5Skd3aMpAQePWPC3axO9VD3WmgFYL96dylzMi4xd2G4e/6lrH+wkSYchcPO+0hrSTugYOBjMdQ==
 | 
			
		||||
  dependencies:
 | 
			
		||||
    call-bind "^1.0.2"
 | 
			
		||||
    es-to-primitive "^1.2.1"
 | 
			
		||||
@@ -3311,14 +3311,14 @@ es-abstract@^1.17.2, es-abstract@^1.18.0-next.2:
 | 
			
		||||
    has-symbols "^1.0.2"
 | 
			
		||||
    is-callable "^1.2.3"
 | 
			
		||||
    is-negative-zero "^2.0.1"
 | 
			
		||||
    is-regex "^1.1.2"
 | 
			
		||||
    is-string "^1.0.5"
 | 
			
		||||
    object-inspect "^1.9.0"
 | 
			
		||||
    is-regex "^1.1.3"
 | 
			
		||||
    is-string "^1.0.6"
 | 
			
		||||
    object-inspect "^1.10.3"
 | 
			
		||||
    object-keys "^1.1.1"
 | 
			
		||||
    object.assign "^4.1.2"
 | 
			
		||||
    string.prototype.trimend "^1.0.4"
 | 
			
		||||
    string.prototype.trimstart "^1.0.4"
 | 
			
		||||
    unbox-primitive "^1.0.0"
 | 
			
		||||
    unbox-primitive "^1.0.1"
 | 
			
		||||
 | 
			
		||||
es-module-lexer@^0.4.0:
 | 
			
		||||
  version "0.4.1"
 | 
			
		||||
@@ -3675,9 +3675,9 @@ fastq@^1.6.0:
 | 
			
		||||
    reusify "^1.0.4"
 | 
			
		||||
 | 
			
		||||
faye-websocket@^0.11.3:
 | 
			
		||||
  version "0.11.3"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.3.tgz#5c0e9a8968e8912c286639fde977a8b209f2508e"
 | 
			
		||||
  integrity sha512-D2y4bovYpzziGgbHYtGCMjlJM36vAl/y+xUyn1C+FVx8szd1E+86KwVw6XvYSzOP8iMpm1X0I4xJD+QtUb36OA==
 | 
			
		||||
  version "0.11.4"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da"
 | 
			
		||||
  integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g==
 | 
			
		||||
  dependencies:
 | 
			
		||||
    websocket-driver ">=0.5.1"
 | 
			
		||||
 | 
			
		||||
@@ -4621,7 +4621,7 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4:
 | 
			
		||||
  dependencies:
 | 
			
		||||
    isobject "^3.0.1"
 | 
			
		||||
 | 
			
		||||
is-regex@^1.0.4, is-regex@^1.1.2:
 | 
			
		||||
is-regex@^1.0.4, is-regex@^1.1.3:
 | 
			
		||||
  version "1.1.3"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.3.tgz#d029f9aff6448b93ebbe3f33dac71511fdcbef9f"
 | 
			
		||||
  integrity sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ==
 | 
			
		||||
@@ -4639,7 +4639,7 @@ is-stream@^2.0.0:
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3"
 | 
			
		||||
  integrity sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==
 | 
			
		||||
 | 
			
		||||
is-string@^1.0.5:
 | 
			
		||||
is-string@^1.0.5, is-string@^1.0.6:
 | 
			
		||||
  version "1.0.6"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.6.tgz#3fe5d5992fb0d93404f32584d4b0179a71b54a5f"
 | 
			
		||||
  integrity sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w==
 | 
			
		||||
@@ -4927,6 +4927,13 @@ levn@~0.3.0:
 | 
			
		||||
    prelude-ls "~1.1.2"
 | 
			
		||||
    type-check "~0.3.2"
 | 
			
		||||
 | 
			
		||||
lie@3.1.1:
 | 
			
		||||
  version "3.1.1"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e"
 | 
			
		||||
  integrity sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=
 | 
			
		||||
  dependencies:
 | 
			
		||||
    immediate "~3.0.5"
 | 
			
		||||
 | 
			
		||||
lie@~3.3.0:
 | 
			
		||||
  version "3.3.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/lie/-/lie-3.3.0.tgz#dcf82dee545f46074daf200c7c1c5a08e0f40f6a"
 | 
			
		||||
@@ -4971,6 +4978,20 @@ loader-utils@^2.0.0:
 | 
			
		||||
    emojis-list "^3.0.0"
 | 
			
		||||
    json5 "^2.1.2"
 | 
			
		||||
 | 
			
		||||
localforage-memoryStorageDriver@^0.9.2:
 | 
			
		||||
  version "0.9.2"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/localforage-memoryStorageDriver/-/localforage-memoryStorageDriver-0.9.2.tgz#2e0f7ff2acb0e9ff5e82c52c9e2eb3d63b998d30"
 | 
			
		||||
  integrity sha1-Lg9/8qyw6f9egsUsni6z1juZjTA=
 | 
			
		||||
  dependencies:
 | 
			
		||||
    localforage ">=1.4.0"
 | 
			
		||||
 | 
			
		||||
localforage@>=1.4.0, localforage@^1.9.0:
 | 
			
		||||
  version "1.9.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.9.0.tgz#f3e4d32a8300b362b4634cc4e066d9d00d2f09d1"
 | 
			
		||||
  integrity sha512-rR1oyNrKulpe+VM9cYmcFn6tsHuokyVHFaCM3+osEmxaHTbEk8oQu6eGDfS6DQLWi/N67XRmB8ECG37OES368g==
 | 
			
		||||
  dependencies:
 | 
			
		||||
    lie "3.1.1"
 | 
			
		||||
 | 
			
		||||
locate-path@^5.0.0:
 | 
			
		||||
  version "5.0.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
 | 
			
		||||
@@ -5454,7 +5475,7 @@ object-copy@^0.1.0:
 | 
			
		||||
    define-property "^0.2.5"
 | 
			
		||||
    kind-of "^3.0.3"
 | 
			
		||||
 | 
			
		||||
object-inspect@^1.6.0, object-inspect@^1.9.0:
 | 
			
		||||
object-inspect@^1.10.3, object-inspect@^1.6.0:
 | 
			
		||||
  version "1.10.3"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.10.3.tgz#c2aa7d2d09f50c99375704f7a0adf24c5782d369"
 | 
			
		||||
  integrity sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==
 | 
			
		||||
@@ -5744,9 +5765,9 @@ path-key@^3.0.0, path-key@^3.1.0:
 | 
			
		||||
  integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
 | 
			
		||||
 | 
			
		||||
path-parse@^1.0.6:
 | 
			
		||||
  version "1.0.6"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
 | 
			
		||||
  integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
 | 
			
		||||
  version "1.0.7"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735"
 | 
			
		||||
  integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==
 | 
			
		||||
 | 
			
		||||
path-to-regexp@0.1.7:
 | 
			
		||||
  version "0.1.7"
 | 
			
		||||
@@ -7333,7 +7354,7 @@ typedarray@^0.0.6:
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
 | 
			
		||||
  integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
 | 
			
		||||
 | 
			
		||||
unbox-primitive@^1.0.0:
 | 
			
		||||
unbox-primitive@^1.0.1:
 | 
			
		||||
  version "1.0.1"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471"
 | 
			
		||||
  integrity sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==
 | 
			
		||||
@@ -7832,9 +7853,9 @@ wrappy@1:
 | 
			
		||||
  integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
 | 
			
		||||
 | 
			
		||||
ws@^7.4.4:
 | 
			
		||||
  version "7.4.5"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.5.tgz#a484dd851e9beb6fdb420027e3885e8ce48986c1"
 | 
			
		||||
  integrity sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==
 | 
			
		||||
  version "7.4.6"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c"
 | 
			
		||||
  integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==
 | 
			
		||||
 | 
			
		||||
xmldoc@^1.1.2:
 | 
			
		||||
  version "1.1.2"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user