Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/ts.corals.io/frontend/mixins/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ts.corals.io/frontend/mixins/serverTableMixin.js
const serverTableMixin = {
  data() {
    return {
      formModalId: '',
      deleteRecordId: null,
      editRecordId: null,
      cloneRecordId: null,
      showRecordId: null,
      listFilters: null,
      filterBy: [],
      defaultOptions: {
        hideCreate: false,
        headings: {},
        columnsDropdown: false,
        initialPage: 1,
        perPageValues: [],
        perPage: 25,
        debounce: 1000,
        filterByColumn: true,
        responseAdapter({data}) {
          return {
            data: data.data,
            count: data.meta.pagination.total,
          }
        },
        requestAdapter: (data) => {
          this.$router.replace({
            query: {
              ...this.$route.query,
              'page': data.page
            }
          }).catch(() => {
          });

          data['query'] = Object.assign(data['query'], this.filterBy);

          return data;
        },
        sortIcon: {base: 'ts-ico', up: 'ts-up', down: 'ts-down', is: 'ts-sort'},
        sortable: [],
        filterable: [],
        customColumns: [],
        requestKeys: {
          query: 'query',
          limit: 'limit',
          orderBy: 'orderBy',
          ascending: 'ascending',
          page: 'page',
          byColumn: 'byColumn'
        },
        initFilters: {},
        templates: {},
        listColumns: {}
      },
      listTableRefs: 'listTable'
    }
  },
  beforeMount() {
    let query = this.$route.query;

    this.defaultOptions.initialPage = query.page ? parseInt(query.page) : 1;
  },
  mounted() {
    this.formModalId = `${this.resourceURL}Table`;
  },
  computed: {
    deleteURL() {
      return this.deleteHref || this.resourceURL;
    },
    editURL() {
      return this.editHref || this.resourceURL;
    },
    cloneURL() {
      return this.cloneHref || this.resourceURL;
    },
  },
  methods: {
    onSubmit() {
      if (this.editRecordId) {
        this.form.put(`${this.editURL}/${this.editRecordId}`).then((response) => {
          this.handleFormHidden();
          this.$emit('formUpdated', response.data);
        });
      } else {
        this.form.post(`${this.resourceURL}`).then((response) => {
          this.handleFormHidden();
          this.$emit('formStored', response.data);
        });
      }
    },
    tableOptions(options = {}) {
      let defaultOptions = this.defaultOptions;

      return Object.assign(defaultOptions, options);
    },
    showDeleteModal(id, index) {
      this.deleteRecordId = id;

      this.$swal.fire({
        title: 'Are you sure?',
        text: "You won't be able to revert this!",
        icon: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#d33',
        cancelButtonColor: '#d7d7d7',
        confirmButtonText: 'Yes, delete it!'
      }).then((result) => {
        if (result.value) {
          this.doDeleteRecord();
        }
      })
    },

    doDeleteRecord() {
      this.$axios.delete(`${this.deleteURL}/${this.deleteRecordId}`)
        .then(response => {
          this.refresh();

          if (response.data.message) {
            this.$toast.success(response.data.message);
          }
        }).catch(err => {
        let message = err.message;
        if (err.response && err.response.data && err.response.data.message) {
          message = err.response.data.message;
        }
        this.$toast.error(message);
      })
    },
    refresh() {
      this.$refs[this.listTableRefs].refresh();
    },
    showFormModal() {
      this.$bvModal.show(this.formModalId);
    },
    handleFormHidden() {
      this.editRecordId = null;
      this.$bvModal.hide(this.formModalId);
      this.refresh();
    },
    handleShowHidden() {
      this.showRecordId = null;
    },
    cloneRecord(recordId, cloneAttr) {
      this.$axios
        .get(`${this.cloneURL}/${recordId}?edit=1`)
        .then(({data: record}) => {
          this.cloneRecordId = recordId;

          this.form.cloneReplace(record.data, cloneAttr);

          this.showFormModal();
        }).catch(err => {
        this.$toast.error(err.message);
      });
    },
    editRecord(recordId) {
      this.$axios
        .get(`${this.editURL}/${recordId}?edit=1`)
        .then(({data: record}) => {
          this.editRecordId = recordId;

          this.form.replace(record.data);

          this.showFormModal();
        }).catch(err => {
        this.$toast.error(err.message);
      });
    },
    replace(data, object) {
      for (let field in data) {
        object[field] = data[field];
      }
      return object;
    },
    showRecord(recordId) {
      this.showRecordId = recordId;
    },
  }
};

export default serverTableMixin;

Spamworldpro Mini