| @@ -1,30 +1,127 @@ | ||
| 1 | -/******/ (function() { // webpackBootstrap | |
| 1 | +/******/ (() => { // webpackBootstrap | |
| 2 | +/******/ "use strict"; | |
| 3 | +/******/ var __webpack_modules__ = ({ | |
| 4 | + | |
| 5 | +/***/ "./assets/src/apps/js/admin/api.js": | |
| 6 | +/*!*****************************************!*\ | |
| 7 | + !*** ./assets/src/apps/js/admin/api.js ***! | |
| 8 | + \*****************************************/ | |
| 9 | +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { | |
| 10 | + | |
| 11 | +__webpack_require__.r(__webpack_exports__); | |
| 12 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 13 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 14 | +/* harmony export */ }); | |
| 15 | +/** | |
| 16 | + * List API on backend | |
| 17 | + */ | |
| 18 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ | |
| 19 | + apiAdminNotice: lpGlobalSettings.rest + 'lp/v1/admin/tools/admin-notices', | |
| 20 | + apiAdminOrderStatic: lpGlobalSettings.rest + 'lp/v1/orders/statistic', | |
| 21 | + apiAddons: lpGlobalSettings.rest + 'lp/v1/addon/all', | |
| 22 | + apiAddonAction: lpGlobalSettings.rest + 'lp/v1/addon/action' | |
| 23 | +}); | |
| 24 | + | |
| 25 | +/***/ }) | |
| 26 | + | |
| 27 | +/******/ }); | |
| 28 | +/************************************************************************/ | |
| 29 | +/******/ // The module cache | |
| 30 | +/******/ var __webpack_module_cache__ = {}; | |
| 31 | +/******/ | |
| 32 | +/******/ // The require function | |
| 33 | +/******/ function __webpack_require__(moduleId) { | |
| 34 | +/******/ // Check if module is in cache | |
| 35 | +/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 36 | +/******/ if (cachedModule !== undefined) { | |
| 37 | +/******/ return cachedModule.exports; | |
| 38 | +/******/ } | |
| 39 | +/******/ // Create a new module (and put it into the cache) | |
| 40 | +/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 41 | +/******/ // no module.id needed | |
| 42 | +/******/ // no module.loaded needed | |
| 43 | +/******/ exports: {} | |
| 44 | +/******/ }; | |
| 45 | +/******/ | |
| 46 | +/******/ // Execute the module function | |
| 47 | +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | |
| 48 | +/******/ | |
| 49 | +/******/ // Return the exports of the module | |
| 50 | +/******/ return module.exports; | |
| 51 | +/******/ } | |
| 52 | +/******/ | |
| 53 | +/************************************************************************/ | |
| 54 | +/******/ /* webpack/runtime/define property getters */ | |
| 55 | +/******/ (() => { | |
| 56 | +/******/ // define getter functions for harmony exports | |
| 57 | +/******/ __webpack_require__.d = (exports, definition) => { | |
| 58 | +/******/ for(var key in definition) { | |
| 59 | +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 60 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 61 | +/******/ } | |
| 62 | +/******/ } | |
| 63 | +/******/ }; | |
| 64 | +/******/ })(); | |
| 65 | +/******/ | |
| 66 | +/******/ /* webpack/runtime/hasOwnProperty shorthand */ | |
| 67 | +/******/ (() => { | |
| 68 | +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | |
| 69 | +/******/ })(); | |
| 70 | +/******/ | |
| 71 | +/******/ /* webpack/runtime/make namespace object */ | |
| 72 | +/******/ (() => { | |
| 73 | +/******/ // define __esModule on exports | |
| 74 | +/******/ __webpack_require__.r = (exports) => { | |
| 75 | +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 76 | +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | |
| 77 | +/******/ } | |
| 78 | +/******/ Object.defineProperty(exports, '__esModule', { value: true }); | |
| 79 | +/******/ }; | |
| 80 | +/******/ })(); | |
| 81 | +/******/ | |
| 82 | +/************************************************************************/ | |
| 2 | 83 | var __webpack_exports__ = {}; |
| 3 | 84 | /*!*****************************************************!*\ |
| 4 | 85 | !*** ./assets/src/apps/js/admin/pages/dashboard.js ***! |
| 5 | 86 | \*****************************************************/ |
| 6 | -document.addEventListener('DOMContentLoaded', function (event) { | |
| 7 | - const elements = document.querySelector('ul.lp_append_data'); | |
| 87 | +__webpack_require__.r(__webpack_exports__); | |
| 88 | +/* harmony import */ var _api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../api */ "./assets/src/apps/js/admin/api.js"); | |
| 89 | +/** | |
| 90 | + * Scripts run on the Dashboard of WordPress | |
| 91 | + * | |
| 92 | + * @since 3.0.0 | |
| 93 | + * @version 1.0.1 | |
| 94 | + */ | |
| 8 | 95 | |
| 9 | - const getResponse = async ele => { | |
| 10 | - try { | |
| 11 | - const response = await wp.apiFetch({ | |
| 12 | - path: wp.url.addQueryArgs('lp/v1/orders/statistic'), | |
| 13 | - method: 'GET' | |
| 14 | - }); | |
| 15 | 96 | |
| 16 | - if (response.status === 'success' && response.data) { | |
| 17 | - ele.innerHTML = response.data; | |
| 18 | - } else { | |
| 19 | - ele.innerHTML = `<div class="lp-ajax-message error" style="display:block">${response.message && response.message}</div>`; | |
| 20 | - } | |
| 21 | - } catch (error) { | |
| 22 | - ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${error.message && error.message}</div>`; | |
| 97 | +let dataOrderStatic = null; | |
| 98 | +let elOrderStatic = null; | |
| 99 | +const callAPIOrderStatic = () => { | |
| 100 | + if (!lpGlobalSettings.is_admin) { | |
| 101 | + return; | |
| 102 | + } | |
| 103 | + fetch(_api__WEBPACK_IMPORTED_MODULE_0__["default"].apiAdminOrderStatic, { | |
| 104 | + method: 'GET' | |
| 105 | + }).then(res => { | |
| 106 | + return res.json(); | |
| 107 | + }).then(res => { | |
| 108 | + dataOrderStatic = res; | |
| 109 | + }).catch(err => { | |
| 110 | + console.log(err); | |
| 111 | + }); | |
| 112 | +}; | |
| 113 | +callAPIOrderStatic(); | |
| 114 | +const interval = setInterval(() => { | |
| 115 | + elOrderStatic = document.querySelector('ul.lp-order-statuses'); | |
| 116 | + if (elOrderStatic && dataOrderStatic !== null) { | |
| 117 | + if (dataOrderStatic.status === 'success' && dataOrderStatic.data) { | |
| 118 | + elOrderStatic.innerHTML = dataOrderStatic.data; | |
| 119 | + } else { | |
| 120 | + elOrderStatic.innerHTML = `<div class="error">${dataOrderStatic.message}</div>`; | |
| 23 | 121 | } |
| 24 | - }; | |
| 25 | - | |
| 26 | - getResponse(elements); | |
| 27 | -}); | |
| 122 | + clearInterval(interval); | |
| 123 | + } | |
| 124 | +}, 1); | |
| 28 | 125 | /******/ })() |
| 29 | 126 | ; |
| 30 | 127 | //# sourceMappingURL=dashboard.js.map |