Plugin Directory

Changeset 2725849


Ignore:
Timestamp:
05/18/2022 07:34:00 AM (4 years ago)
Author:
123on
Message:

fix: bug with custom image

Location:
123on
Files:
68 added
2 edited

Legend:

Unmodified
Added
Removed
  • 123on/trunk/assets/js/admin.js

    r2722762 r2725849  
    101101
    102102"use strict";
    103 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n  name: 'Hotspot Table',\n  props: ['table_rows'],\n\n  data() {\n    return {\n      pages: [],\n      products: [],\n      data_to_upload: []\n    };\n  },\n\n  methods: {\n    p123on_add_table_row() {\n      this.table_rows.push({\n        \"id\": this.table_rows.length + 1,\n        \"startTime\": \"\",\n        \"stopTime\": \"\",\n        \"option\": 'link',\n        \"btn_option\": \"1\",\n        \"value\": \"\",\n        \"position_x\": \"50\",\n        \"position_y\": \"50\",\n        \"product_id\": \"\",\n        \"custom_product\": {\n          name: \"\",\n          price: \"\",\n          link: \"\",\n          image_url: \"\"\n        }\n      });\n    },\n\n    p123on_remove_table_row() {\n      this.table_rows.splice(this.table_rows.length - 1, 1);\n    },\n\n    p123on_get_pages() {\n      axios__WEBPACK_IMPORTED_MODULE_0___default.a.get('/wp-json/v2/video_123on/pages').then(response => {\n        this.pages = response.data;\n      }).catch(error => {\n        console.log(error);\n      });\n    },\n\n    p123on_get_products() {\n      axios__WEBPACK_IMPORTED_MODULE_0___default.a.get('/wp-json/v2/video_123on/products').then(response => {\n        this.products = response.data;\n      }).catch(error => {\n        console.log(error);\n      });\n    },\n\n    p123on_set_product_data(index, hotspotID) {\n      this.table_rows[hotspotID - 1].product_id = this.products[index - 1].ID;\n    },\n\n    p123on_get_image(event, hotspotID) {\n      const file = event.target.files[0];\n      const data_to_upload = [];\n      this.table_rows[hotspotID - 1].custom_product.image_url = URL.createObjectURL(file);\n      let form_data = new FormData();\n      form_data.append('file', file);\n      let config = {\n        headers: {\n          'X-WP-Nonce': wpApiSettings.nonce\n        }\n      };\n      data_to_upload[0] = form_data;\n      data_to_upload[1] = config;\n      this.data_to_upload = data_to_upload;\n      this.p123on_upload_image(hotspotID);\n    },\n\n    p123on_upload_image(hotspotID) {\n      const API_URL = '/wp-json/wp/v2/media';\n      return axios__WEBPACK_IMPORTED_MODULE_0___default.a.post(API_URL, this.data_to_upload[0], this.data_to_upload[1]).then(response => {});\n    }\n\n  },\n\n  mounted() {\n    this.p123on_get_pages();\n    this.p123on_get_products();\n    this.table_rows.push({\n      \"id\": 1,\n      \"startTime\": \"\",\n      \"stopTime\": \"\",\n      \"option\": 'link',\n      \"btn_option\": \"1\",\n      \"value\": \"\",\n      \"position_x\": \"50\",\n      \"position_y\": \"50\",\n      \"product_id\": \"\",\n      \"custom_product\": {\n        name: \"\",\n        price: \"\",\n        link: \"\",\n        image_url: \"\"\n      }\n    });\n  }\n\n});\n\n//# sourceURL=webpack:///./src/admin/pages/HotspotTable.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options");
     103eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! axios */ \"./node_modules/axios/index.js\");\n/* harmony import */ var axios__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(axios__WEBPACK_IMPORTED_MODULE_0__);\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n  name: 'Hotspot Table',\n  props: ['table_rows'],\n\n  data() {\n    return {\n      pages: [],\n      products: [],\n      data_to_upload: []\n    };\n  },\n\n  methods: {\n    p123on_add_table_row() {\n      this.table_rows.push({\n        \"id\": this.table_rows.length + 1,\n        \"startTime\": \"\",\n        \"stopTime\": \"\",\n        \"option\": 'link',\n        \"btn_option\": \"1\",\n        \"value\": \"\",\n        \"position_x\": \"50\",\n        \"position_y\": \"50\",\n        \"product_id\": \"\",\n        \"custom_product\": {\n          name: \"\",\n          price: \"\",\n          link: \"\",\n          image_url: \"\"\n        }\n      });\n    },\n\n    p123on_remove_table_row() {\n      this.table_rows.splice(this.table_rows.length - 1, 1);\n    },\n\n    p123on_get_pages() {\n      axios__WEBPACK_IMPORTED_MODULE_0___default.a.get('/wp-json/v2/video_123on/pages').then(response => {\n        this.pages = response.data;\n      }).catch(error => {\n        console.log(error);\n      });\n    },\n\n    p123on_get_products() {\n      axios__WEBPACK_IMPORTED_MODULE_0___default.a.get('/wp-json/v2/video_123on/products').then(response => {\n        this.products = response.data;\n      }).catch(error => {\n        console.log(error);\n      });\n    },\n\n    p123on_set_product_data(index, hotspotID) {\n      this.table_rows[hotspotID - 1].product_id = this.products[index - 1].ID;\n    },\n\n    p123on_get_image(event, hotspotID) {\n      const file = event.target.files[0];\n      const data_to_upload = [];\n      let form_data = new FormData();\n      form_data.append('file', file);\n      let config = {\n        headers: {\n          'X-WP-Nonce': wpApiSettings.nonce\n        }\n      };\n      data_to_upload[0] = form_data;\n      data_to_upload[1] = config;\n      this.data_to_upload = data_to_upload;\n      this.p123on_upload_image(hotspotID);\n    },\n\n    p123on_upload_image(hotspotID) {\n      const API_URL = '/wp-json/wp/v2/media';\n      return axios__WEBPACK_IMPORTED_MODULE_0___default.a.post(API_URL, this.data_to_upload[0], this.data_to_upload[1]).then(response => {\n        this.table_rows[hotspotID - 1].custom_product.image_url = response.data.guid.rendered;\n      });\n    }\n\n  },\n\n  mounted() {\n    this.p123on_get_pages();\n    this.p123on_get_products();\n    this.table_rows.push({\n      \"id\": 1,\n      \"startTime\": \"\",\n      \"stopTime\": \"\",\n      \"option\": 'link',\n      \"btn_option\": \"1\",\n      \"value\": \"\",\n      \"position_x\": \"50\",\n      \"position_y\": \"50\",\n      \"product_id\": \"\",\n      \"custom_product\": {\n        name: \"\",\n        price: \"\",\n        link: \"\",\n        image_url: \"\"\n      }\n    });\n  }\n\n});\n\n//# sourceURL=webpack:///./src/admin/pages/HotspotTable.vue?./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options");
    104104
    105105/***/ }),
     
    473473  !*** ./src/admin/pages/HotspotTable.vue ***!
    474474  \******************************************/
    475 /*! no static exports found */
    476 /***/ (function(module, __webpack_exports__, __webpack_require__) {
    477 
    478 "use strict";
    479 eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _HotspotTable_vue_vue_type_template_id_2cda6363_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HotspotTable.vue?vue&type=template&id=2cda6363&scoped=true& */ \"./src/admin/pages/HotspotTable.vue?vue&type=template&id=2cda6363&scoped=true&\");\n/* harmony import */ var _HotspotTable_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HotspotTable.vue?vue&type=script&lang=js& */ \"./src/admin/pages/HotspotTable.vue?vue&type=script&lang=js&\");\n/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _HotspotTable_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__) if([\"default\"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _HotspotTable_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__[key]; }) }(__WEBPACK_IMPORT_KEY__));\n/* harmony import */ var _HotspotTable_vue_vue_type_style_index_0_id_2cda6363_scoped_true_lang_less___WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./HotspotTable.vue?vue&type=style&index=0&id=2cda6363&scoped=true&lang=less& */ \"./src/admin/pages/HotspotTable.vue?vue&type=style&index=0&id=2cda6363&scoped=true&lang=less&\");\n/* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ \"./node_modules/vue-loader/lib/runtime/componentNormalizer.js\");\n\n\n\n\n\n\n/* normalize component */\n\nvar component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(\n  _HotspotTable_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n  _HotspotTable_vue_vue_type_template_id_2cda6363_scoped_true___WEBPACK_IMPORTED_MODULE_0__[\"render\"],\n  _HotspotTable_vue_vue_type_template_id_2cda6363_scoped_true___WEBPACK_IMPORTED_MODULE_0__[\"staticRenderFns\"],\n  false,\n  null,\n  \"2cda6363\",\n  null\n  \n)\n\n/* hot reload */\nif (false) { var api; }\ncomponent.options.__file = \"src/admin/pages/HotspotTable.vue\"\n/* harmony default export */ __webpack_exports__[\"default\"] = (component.exports);\n\n//# sourceURL=webpack:///./src/admin/pages/HotspotTable.vue?");
     475/*! exports provided: default */
     476/***/ (function(module, __webpack_exports__, __webpack_require__) {
     477
     478"use strict";
     479eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _HotspotTable_vue_vue_type_template_id_2cda6363_scoped_true___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HotspotTable.vue?vue&type=template&id=2cda6363&scoped=true& */ \"./src/admin/pages/HotspotTable.vue?vue&type=template&id=2cda6363&scoped=true&\");\n/* harmony import */ var _HotspotTable_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HotspotTable.vue?vue&type=script&lang=js& */ \"./src/admin/pages/HotspotTable.vue?vue&type=script&lang=js&\");\n/* empty/unused harmony star reexport *//* harmony import */ var _HotspotTable_vue_vue_type_style_index_0_id_2cda6363_scoped_true_lang_less___WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./HotspotTable.vue?vue&type=style&index=0&id=2cda6363&scoped=true&lang=less& */ \"./src/admin/pages/HotspotTable.vue?vue&type=style&index=0&id=2cda6363&scoped=true&lang=less&\");\n/* harmony import */ var _node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js */ \"./node_modules/vue-loader/lib/runtime/componentNormalizer.js\");\n\n\n\n\n\n\n/* normalize component */\n\nvar component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_3__[\"default\"])(\n  _HotspotTable_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n  _HotspotTable_vue_vue_type_template_id_2cda6363_scoped_true___WEBPACK_IMPORTED_MODULE_0__[\"render\"],\n  _HotspotTable_vue_vue_type_template_id_2cda6363_scoped_true___WEBPACK_IMPORTED_MODULE_0__[\"staticRenderFns\"],\n  false,\n  null,\n  \"2cda6363\",\n  null\n  \n)\n\n/* hot reload */\nif (false) { var api; }\ncomponent.options.__file = \"src/admin/pages/HotspotTable.vue\"\n/* harmony default export */ __webpack_exports__[\"default\"] = (component.exports);\n\n//# sourceURL=webpack:///./src/admin/pages/HotspotTable.vue?");
    480480
    481481/***/ }),
     
    485485  !*** ./src/admin/pages/HotspotTable.vue?vue&type=script&lang=js& ***!
    486486  \*******************************************************************/
    487 /*! no static exports found */
     487/*! exports provided: default */
    488488/***/ (function(module, __webpack_exports__, __webpack_require__) {
    489489
  • 123on/trunk/src/admin/pages/HotspotTable.vue

    r2722762 r2725849  
    9393      pages: [],
    9494      products: [],
    95       data_to_upload: []
     95      data_to_upload: [],
    9696    };
    9797  },
     
    145145      const file = event.target.files[0];
    146146      const data_to_upload = [];
    147       this.table_rows[hotspotID-1].custom_product.image_url = URL.createObjectURL(file);
    148147
    149148      let form_data = new FormData();
     
    170169      ).then(
    171170        response => {
     171           this.table_rows[hotspotID-1].custom_product.image_url = response.data.guid.rendered;
    172172        }
    173173      )
Note: See TracChangeset for help on using the changeset viewer.