mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-15 00:46:22 +00:00
1 line
161 KiB
Plaintext
1 line
161 KiB
Plaintext
{"version":3,"sources":["dashboard.js"],"names":["const","lsKeys","token","viewType","uploads","uploadsAll","selected","albums","albumsAll","users","originalNames","page","section","dom","localStorage","username","permissions","menusContainer","menus","currentView","views","type","album","pageNum","filters","all","prevPageNums","checkboxes","lastSelected","selectAlbumContainer","cache","clipboardJS","lazyLoad","albumsSidebarCollapse","albumsSidebarCollapsible","imageExts","videoExts","audioExts","isSomethingLoading","fadingIn","albumTitleMaxLength","albumDescMaxLength","cloudflareErrors","document","querySelector","classList","add","remove","error","console","content","createElement","innerHTML","toString","swal","title","icon","response","onError","statusText","status","description","data","verifyToken","window","location","apiVersion","match","src","text","buttons","confirm","closeModal","then","reload","axios","post","defaults","headers","common","version","checkClientVersion","prepareDashboard","catch","onAxiosError","code","removeItem","addEventListener","domClick","event","target","contains","preventDefault","itemMenus","selector","onclick","getUploads","deleteUploadsByNames","getAlbums","changeToken","changePassword","logout","params","group","getStatistics","getUsers","loop","i","item","warnSomethingLoading","call","Object","assign","trigger","currentTarget","forceScroll","push","length","moderator","unhide","getAlbumsSidebar","prepareShareX","updateTrigger","timer","newState","parentNode","tagName","className","includes","let","element","parent","parseInt","dataset","id","action","hasAttribute","stopPropagation","getItemID","setUploadsView","toggleOriginalNames","addToAlbum","deleteUpload","addSelectedUploadsToAlbum","bulkDeleteUploads","displayPreview","uploadFiltersHelp","filterUploads","submitAlbum","editAlbum","disableAlbum","deleteAlbum","viewAlbumUploads","createUser","editUser","disableUser","deleteUser","viewUserUploads","getNewToken","clearSelection","select","selectAll","focusJumpToPage","switchPage","disableFading","clearTimeout","setTimeout","disableSmooth","scrollIntoView","behavior","block","inline","view","get","func","getByView","goto","jumpToPage","jumpid","checkValidity","parsed","value","isNaN","focus","url","test","minoffset","Date","getTimezoneOffset","success","uploadsPerPage","pages","Math","ceil","count","files","autoPage","basedomain","max","pagination","paginate","extraControls","escape","controls","bottomExtraControls","replace","bottomPagination","unselected","filterAllByAlbums","hasExpiryDateColumn","some","file","expirydate","showOriginalNames","origin","thumb","extname","toLowerCase","previewable","name","original","prettyAlbum","albumid","prettyBytes","getPrettyBytes","size","prettyDate","getPrettyDate","timestamp","prettyUser","userid","prettyExpiryDate","table","upload","appendix","div","undefined","appendChild","querySelectorAll","tr","ip","checked","fadeInDom","scrollToDom","update","onload","body","onerror","setAttribute","splice","indexOf","JSON","stringify","lastElement","thisIndex","index","lastIndex","abs","shiftKey","selectInBetween","suffix","substring","proceed","Boolean","style","trim","filtersid","user","postBulkDeleteUploads","field","values","cb","failed","filter","textArea","seen","names","split","map","trimmed","prototype","hasOwnProperty","join","objective","dangerMode","cancel","Array","isArray","addUploadsToAlbum","ids","callback","choose","added","simple","list","getElementsByTagName","removeAttribute","albumsPerPage","homeDomain","createNewAlbum","albumUrlText","identifier","albumUrl","hasZip","zipSize","prettyZipDate","zipGeneratedAt","isZipExpired","editedAt","enabled","download","public","descriptionHtml","urlPath","requestLink","purge","albumsSidebar","oldAlbums","diffCount","innerText","collapsed","textExpand","textCollapse","collapse","li","a","sendNewPassword","pass","password","admin","usersPerPage","displayGroup","groups","keys","registration","prettyTokenUpdate","usage","groupOptions","g","isHigher","isDisabledHelper","resetPassword","autoClose","displayName","totalItems","itemsPerPage","currentPage","numPages","template","start","end","elementsToShow","step","stats","rows","valKeys","j","totalForPercentage","available","used","total","toFixed","getPrettyUptime","toLocaleString","hrtime","defineProperty","varArgs","arguments$1","arguments","TypeError","to","nextSource","nextKey","writable","configurable","documentElement","selectedKeys","ls","parse","preparePage","ClipboardJS","on","LazyLoad","bulmaCollapsible"],"mappings":"AAEAA,IAAMC,OAAS,CACbC,MAAO,QACPC,SAAU,CACRC,QAAS,kBACTC,WAAY,sBAEdC,SAAU,CACRF,QAAS,kBACTC,WAAY,qBACZE,OAAQ,iBACRC,UAAW,oBACXC,MAAO,iBAETC,cAAe,CACbN,QAAS,gBACT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KAAKoB,YAAY8V,GAAG,WAAS,WAC3B,OAAOvU,KAAK,GAAI,yCAA0C,UAAW,CACnEgB,SAAS,EACTqD,MAAO,MA5zBX,IAg0BAhH,KAAKoB,YAAY8V,GAAG,QAASlX,KAAK+C,SAElC/C,KAAKqB,SAAW,IAAI8V,SAEpBnX,KAAKsB,sBAAwBU,SAASC,cAAc,0BAGpDjC,KAAKuB,yBAA2B,IAAI6V,iBAAiBpV,SAASC,cAAc,mBAC5EjC,KAAKuB,yBAAyB2V,GAAG,iBAAe,SAAEpS,GAChD9E,KAAKsB,sBAAsB8R,UAAYpT,KAAKsB,sBAAsBoG,QAAQ6L,YA7zB5E,IA+zBAvT,KAAKuB,yBAAyB2V,GAAG,mBAAiB,SAAEpS,GAClD9E,KAAKsB,sBAAsB8R,UAAYpT,KAAKsB,sBAAsBoG,QAAQ4L,UA7zB5E,GACF","file":"dashboard.js","sourcesContent":["/* global swal, axios, ClipboardJS, LazyLoad, bulmaCollapsible */\n\nconst lsKeys = {\n token: 'token',\n viewType: {\n uploads: 'viewTypeUploads',\n uploadsAll: 'viewTypeUploadsAll'\n },\n selected: {\n uploads: 'selectedUploads',\n uploadsAll: 'selectedUploadsAll',\n albums: 'selectedAlbums',\n albumsAll: 'selectedAlbumsAll',\n users: 'selectedUsers'\n },\n originalNames: {\n uploads: 'originalNames',\n uploadsAll: 'originalNamesAll'\n }\n}\n\nconst page = {\n // #dashboard\n section: null,\n // #page\n dom: null,\n\n // user token\n token: localStorage[lsKeys.token],\n\n // from api/tokens/verify\n username: null,\n permissions: null,\n\n // sidebar menus\n menusContainer: null,\n menus: [],\n\n currentView: null,\n views: {\n // params of uploads view\n uploads: {\n type: localStorage[lsKeys.viewType.uploads],\n originalNames: localStorage[lsKeys.originalNames.uploads] === '1',\n album: null, // album's id\n pageNum: null\n },\n // params of uploads view (all)\n uploadsAll: {\n type: localStorage[lsKeys.viewType.uploadsAll],\n originalNames: localStorage[lsKeys.originalNames.uploadsAll] === '1',\n filters: null,\n pageNum: null,\n all: true\n },\n // params of albums view\n albums: {\n filters: null,\n pageNum: null\n },\n // params of albums view (all)\n albumsAll: {\n filters: null,\n pageNum: null,\n all: true\n },\n // params of users view\n users: {\n filters: null,\n pageNum: null\n }\n },\n prevPageNums: {\n uploads: null,\n uploadsAll: null,\n albums: null,\n albumsAll: null,\n users: null\n },\n\n // ids of selected items (shared across pages and will be synced with localStorage)\n selected: {\n uploads: [],\n uploadsAll: [],\n albums: [],\n albumsAll: [],\n users: []\n },\n checkboxes: [],\n lastSelected: [],\n\n // select album dom for dialogs/modals\n selectAlbumContainer: null,\n\n // cache for dialogs/modals\n cache: {},\n\n clipboardJS: null,\n lazyLoad: null,\n albumsSidebarCollapse: null,\n albumsSidebarCollapsible: null,\n\n imageExts: ['.gif', '.jpeg', '.jpg', '.png', '.svg', '.tif', '.tiff', '.webp'],\n videoExts: ['.3g2', '.3gp', '.asf', '.avchd', '.avi', '.divx', '.evo', '.flv', '.h264', '.h265', '.hevc', '.m2p', '.m2ts', '.m4v', '.mk3d', '.mkv', '.mov', '.mp4', '.mpeg', '.mpg', '.mxf', '.ogg', '.ogv', '.ps', '.qt', '.rmvb', '.ts', '.vob', '.webm', '.wmv'],\n audioExts: ['.flac', '.mp3', '.wav', '.wma'],\n\n isSomethingLoading: false,\n fadingIn: null,\n\n albumTitleMaxLength: 70,\n albumDescMaxLength: 4000,\n\n // Better Cloudflare errors\n cloudflareErrors: {\n 520: 'Unknown Error',\n 521: 'Web Server Is Down',\n 522: 'Connection Timed Out',\n 523: 'Origin Is Unreachable',\n 524: 'A Timeout Occurred',\n 525: 'SSL Handshake Failed',\n 526: 'Invalid SSL Certificate',\n 527: 'Railgun Error',\n 530: 'Origin DNS Error'\n }\n}\n\npage.unhide = () => {\n document.querySelector('#loader').classList.add('is-hidden')\n page.section.classList.remove('is-hidden')\n}\n\n// Handler for regular JS errors\npage.onError = error => {\n console.error(error)\n\n const content = document.createElement('div')\n content.innerHTML = `\n <p><code>${error.toString()}</code></p>\n <p>Please check your console for more information.</p>\n `\n return swal({\n title: 'An error occurred!',\n icon: 'error',\n content\n })\n}\n\n// Handler for Axios errors\npage.onAxiosError = error => {\n if (!error.response) {\n return page.onError(error)\n }\n\n const statusText = page.cloudflareErrors[error.response.status] || error.response.statusText\n const description = error.response.data && error.response.data.description\n ? error.response.data.description\n : 'There was an error with the request.\\nPlease check the console for more information.'\n\n return swal(`${error.response.status} ${statusText}`, description, 'error')\n}\n\npage.preparePage = () => {\n if (page.token) page.verifyToken(page.token)\n else window.location = 'auth'\n}\n\npage.checkClientVersion = apiVersion => {\n const self = document.querySelector('#mainScript')\n const match = self.src.match(/\\?_=(\\d+)$/)\n if (match && match[1] && match[1] !== apiVersion) {\n return swal({\n title: 'Update detected!',\n text: 'Client assets have been updated. Reload to display the latest version?',\n icon: 'info',\n buttons: {\n confirm: {\n text: 'Reload',\n closeModal: false\n }\n }\n }).then(() => {\n window.location.reload()\n })\n }\n}\n\npage.verifyToken = token => {\n axios.post('api/tokens/verify', { token }).then(response => {\n axios.defaults.headers.common.token = token\n localStorage[lsKeys.token] = token\n\n if (response.data.version) {\n page.checkClientVersion(response.data.version)\n }\n\n page.token = token\n page.username = response.data.username\n page.permissions = response.data.permissions\n page.prepareDashboard()\n }).catch(error => {\n return page.onAxiosError(error).then(() => {\n if (error.response.data && error.response.data.code === 10001) {\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n }\n })\n })\n}\n\npage.prepareDashboard = () => {\n page.section = document.querySelector('#dashboard')\n page.dom = page.section.querySelector('#page')\n\n // Capture all click events\n page.dom.addEventListener('click', page.domClick, true)\n\n // Capture all submit events\n page.dom.addEventListener('submit', event => {\n // Prevent default if necessary\n if (event.target && event.target.classList.contains('prevent-default')) {\n return event.preventDefault()\n }\n }, true)\n\n page.menusContainer = document.querySelector('#menu')\n\n // All item menus in the sidebar\n const itemMenus = [\n { selector: '#itemUploads', onclick: page.getUploads },\n { selector: '#itemDeleteUploadsByNames', onclick: page.deleteUploadsByNames },\n { selector: '#itemManageYourAlbums', onclick: page.getAlbums },\n { selector: '#itemManageToken', onclick: page.changeToken },\n { selector: '#itemChangePassword', onclick: page.changePassword },\n { selector: '#itemLogout', onclick: page.logout },\n { selector: '#itemManageUploads', onclick: page.getUploads, params: { all: true }, group: 'moderator' },\n { selector: '#itemManageAlbums', onclick: page.getAlbums, params: { all: true }, group: 'moderator' },\n { selector: '#itemStatistics', onclick: page.getStatistics, group: 'admin' },\n { selector: '#itemManageUsers', onclick: page.getUsers, group: 'admin' }\n ]\n\n for (let i = 0; i < itemMenus.length; i++) {\n // Skip item menu if not enough permission\n if (itemMenus[i].group && !page.permissions[itemMenus[i].group]) continue\n\n // Add onclick event listener\n const item = document.querySelector(itemMenus[i].selector)\n item.addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n itemMenus[i].onclick.call(null, Object.assign(itemMenus[i].params || {}, {\n trigger: event.currentTarget,\n forceScroll: true\n }))\n })\n\n item.classList.remove('is-hidden')\n page.menus.push(item)\n }\n\n // If at least a moderator, show administration section\n if (page.permissions.moderator) {\n document.querySelector('#itemLabelAdmin').classList.remove('is-hidden')\n document.querySelector('#itemListAdmin').classList.remove('is-hidden')\n }\n\n // Update text of logout button\n document.querySelector('#itemLogout').innerHTML = `Logout ( ${page.username} )`\n\n // Finally display dashboard\n page.unhide()\n\n // Load albums sidebar\n page.getAlbumsSidebar()\n\n if (typeof page.prepareShareX === 'function') page.prepareShareX()\n}\n\npage.logout = params => {\n page.updateTrigger(params.trigger, 'active')\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n}\n\npage.warnSomethingLoading = () => {\n swal('Please wait!', 'Something else is still loading\\u2026', 'warning', {\n buttons: false,\n timer: 3000\n })\n}\n\npage.updateTrigger = (trigger, newState) => {\n if (!trigger) return\n\n // Disable menus container and pagination when loading\n if (newState === 'loading') {\n page.isSomethingLoading = true\n page.section.classList.add('is-loading')\n } else {\n page.section.classList.remove('is-loading')\n page.isSomethingLoading = false\n }\n\n if (newState === 'loading') {\n trigger.classList.add('is-loading')\n } else if (newState === 'active') {\n if (trigger.parentNode.tagName === 'LI' && !trigger.className.includes('pagination-link')) {\n for (let i = 0; i < page.menus.length; i++) {\n page.menus[i].classList.remove('is-active')\n }\n trigger.classList.add('is-active')\n }\n trigger.classList.remove('is-loading')\n } else {\n trigger.classList.remove('is-loading')\n trigger.classList.remove('is-active')\n }\n}\n\npage.getItemID = element => {\n // This expects the item's parent to have the item's ID\n let parent = element.parentNode\n // If the element is part of a set of controls, use the container's parent instead\n if (element.parentNode.classList.contains('controls')) parent = parent.parentNode\n return parseInt(parent.dataset.id)\n}\n\npage.domClick = event => {\n // We are processing clicks this way to avoid using \"onclick\" attribute\n // Apparently we will need to use \"unsafe-inline\" for \"script-src\" directive\n // of Content Security Policy (CSP), if we want to use \"onclick\" attribute\n // Though I think that only applies to some browsers (?)\n // Of course it wouldn't have mattered if we didn't use CSP to begin with\n // Anyway, I personally would rather not use \"onclick\" attribute\n let element = event.target\n if (!element) return\n\n // Delegate click events to their A or BUTTON parents\n if (['I'].includes(element.tagName) && ['SPAN'].includes(element.parentNode.tagName)) {\n element = element.parentNode\n }\n if (['SPAN'].includes(element.tagName) && ['A', 'BUTTON'].includes(element.parentNode.tagName)) {\n element = element.parentNode\n }\n\n // Skip elements that have no action data\n if (!element.dataset || !element.dataset.action) return\n\n // Skip disabled elements\n if (element.hasAttribute('disabled')) return\n\n event.stopPropagation() // maybe necessary\n const id = page.getItemID(element)\n const action = element.dataset.action\n\n switch (action) {\n // Uploads\n case 'view-list':\n return page.setUploadsView('list', element)\n case 'view-thumbs':\n return page.setUploadsView('thumbs', element)\n case 'toggle-original-names':\n return page.toggleOriginalNames(element)\n case 'add-to-album':\n return page.addToAlbum(id)\n case 'delete-upload':\n return page.deleteUpload(id)\n case 'add-selected-uploads-to-album':\n return page.addSelectedUploadsToAlbum()\n case 'bulk-delete-uploads':\n return page.bulkDeleteUploads()\n case 'display-preview':\n return page.displayPreview(id)\n // Manage uploads\n case 'upload-filters-help':\n return page.uploadFiltersHelp(element)\n case 'filter-uploads':\n return page.filterUploads(element)\n // Manage your albums\n case 'submit-album':\n return page.submitAlbum(element)\n case 'edit-album':\n return page.editAlbum(id)\n case 'disable-album':\n return page.disableAlbum(id)\n case 'delete-album':\n return page.deleteAlbum(id)\n case 'view-album-uploads':\n return page.viewAlbumUploads(id, element)\n // Manage users\n case 'create-user':\n return page.createUser()\n case 'edit-user':\n return page.editUser(id)\n case 'disable-user':\n return page.disableUser(id)\n case 'delete-user':\n return page.deleteUser(id)\n case 'view-user-uploads':\n return page.viewUserUploads(id, element)\n // Others\n case 'get-new-token':\n return page.getNewToken(element)\n // Uploads & Users\n case 'clear-selection':\n return page.clearSelection()\n case 'select':\n return page.select(element, event)\n case 'select-all':\n return page.selectAll(element)\n case 'page-ellipsis':\n return page.focusJumpToPage(element)\n case 'page-prev':\n case 'page-next':\n case 'page-goto':\n case 'jump-to-page':\n return page.switchPage(action, element)\n }\n}\n\npage.fadeInDom = disableFading => {\n if (page.fadingIn) {\n clearTimeout(page.fadingIn)\n page.dom.classList.remove('fade-in')\n }\n\n if (!disableFading) {\n page.dom.classList.add('fade-in')\n page.fadingIn = setTimeout(() => {\n page.dom.classList.remove('fade-in')\n }, 500)\n }\n}\n\npage.scrollToDom = disableSmooth => {\n page.dom.scrollIntoView({\n behavior: disableSmooth ? 'auto' : 'smooth',\n block: 'start',\n inline: 'nearest'\n })\n}\n\npage.getByView = (view, get) => {\n switch (view) {\n case 'uploads':\n case 'uploadsAll':\n return {\n type: 'uploads',\n func: page.getUploads\n }[get]\n case 'albums':\n case 'albumsAll':\n return {\n type: 'albums',\n func: page.getAlbums\n }[get]\n case 'users':\n return {\n type: 'users',\n func: page.getUsers\n }[get]\n default:\n return null\n }\n}\n\npage.switchPage = (action, element) => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n const params = Object.assign(page.views[page.currentView], {\n trigger: element\n })\n\n const func = page.getByView(page.currentView, 'func')\n\n switch (action) {\n case 'page-prev':\n params.pageNum = page.views[page.currentView].pageNum - 1\n if (params.pageNum < 0) {\n return swal('An error occurred!', 'This is already the first page.', 'error')\n }\n return func(params)\n case 'page-next':\n params.pageNum = page.views[page.currentView].pageNum + 1\n return func(params)\n case 'page-goto':\n params.pageNum = parseInt(element.dataset.goto)\n return func(params)\n case 'jump-to-page': {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage.checkValidity()) return\n const parsed = parseInt(jumpToPage.value)\n params.pageNum = isNaN(parsed) ? 0 : (parsed - 1)\n if (params.pageNum < 0) params.pageNum = 0\n return func(params)\n }\n }\n}\n\npage.focusJumpToPage = element => {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage) return\n jumpToPage.focus()\n jumpToPage.select()\n}\n\npage.getUploads = (params = {}) => {\n if (params && params.all && !page.permissions.moderator) {\n return swal('An error occurred!', 'You cannot do this!', 'error')\n }\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number' || params.pageNum < 0) {\n params.pageNum = 0\n }\n\n const url = typeof params.album !== 'undefined'\n ? `api/album/${params.album}/${params.pageNum}`\n : `api/uploads/${params.pageNum}`\n\n const headers = {}\n if (params.all) headers.all = '1'\n if (params.filters) {\n headers.filters = params.filters\n // Send client timezone offset if properly using date: and/or :expiry filters\n // Server will assume client is on UTC if unset\n if (/(^|\\s)(date|expiry):[\\d\"]/.test(params.filters)) {\n headers.minoffset = new Date().getTimezoneOffset()\n }\n }\n\n axios.get(url, { headers }).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const uploadsPerPage = response.data.uploadsPerPage || 25\n const pages = Math.ceil(response.data.count / uploadsPerPage)\n const files = response.data.files\n if (params.pageNum && (files.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUploads(params)\n } else {\n return swal('An error occurred!', `There are no more uploads to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = params.all ? 'uploadsAll' : 'uploads'\n page.cache = {}\n\n const albums = response.data.albums\n const users = response.data.users\n const basedomain = response.data.basedomain\n\n if (params.pageNum < 0) {\n params.pageNum = Math.max(0, pages + params.pageNum)\n }\n const pagination = page.paginate(response.data.count, uploadsPerPage, params.pageNum)\n\n const filter = `\n <div class=\"column\">\n <form class=\"prevent-default\">\n <div class=\"field has-addons\">\n <div class=\"control is-expanded\">\n <input id=\"filters\" class=\"input is-small\" type=\"text\" placeholder=\"Filter uploads\" value=\"${page.escape(params.filters || '')}\">\n </div>\n <div class=\"control\">\n <button type=\"button\" class=\"button is-small is-primary is-outlined\" title=\"Help?\" data-action=\"upload-filters-help\"${params.all ? ' data-all=\"true\"' : ''}>\n <span class=\"icon\">\n <i class=\"icon-help-circled\"></i>\n </span>\n </button>\n </div>\n <div class=\"control\">\n <button type=\"submit\" class=\"button is-small is-info is-outlined\" title=\"Filter uploads\" data-action=\"filter-uploads\">\n <span class=\"icon\">\n <i class=\"icon-filter\"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n `\n const extraControls = `\n <div class=\"columns\">\n ${filter}\n <div class=\"column is-one-quarter\">\n <form class=\"prevent-default\">\n <div class=\"field has-addons\">\n <div class=\"control is-expanded\">\n <input id=\"jumpToPage\" class=\"input is-small\" type=\"number\" min=\"1\" max=\"${pages}\" value=\"${params.pageNum + 1}\"${pages === 1 ? ' disabled' : ''}>\n </div>\n <div class=\"control\">\n <button type=\"submit\" class=\"button is-small is-info is-outlined\" title=\"Jump to page\" data-action=\"jump-to-page\">\n <span class=\"icon\">\n <i class=\"icon-paper-plane\"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n </div>\n `\n\n const controls = `\n <div class=\"columns\">\n <div class=\"column exclusive-operations has-text-left\">\n <a class=\"button is-small is-primary is-outlined\" title=\"Toggle original names\" data-action=\"toggle-original-names\">\n <span class=\"icon\">\n <i class=\"icon-exchange\"></i>\n </span>\n <span>Toggle original names</span>\n </a>\n </div>\n <div class=\"column has-text-centered\">\n <a class=\"button is-small is-danger is-outlined\" title=\"List view\" data-action=\"view-list\">\n <span class=\"icon\">\n <i class=\"icon-th-list\"></i>\n </span>\n </a>\n <a class=\"button is-small is-danger is-outlined\" title=\"Thumbs view\" data-action=\"view-thumbs\">\n <span class=\"icon\">\n <i class=\"icon-th-large\"></i>\n </span>\n </a>\n </div>\n <div class=\"column bulk-operations has-text-right\">\n <a class=\"button is-small is-info is-outlined\" title=\"Clear selection\" data-action=\"clear-selection\">\n <span class=\"icon\">\n <i class=\"icon-cancel\"></i>\n </span>\n </a>\n ${params.all\n ? ''\n : `<a class=\"button is-small is-warning is-outlined\" title=\"Bulk add to album\" data-action=\"add-selected-uploads-to-album\">\n <span class=\"icon\">\n <i class=\"icon-plus\"></i>\n </span>\n </a>`}\n <a class=\"button is-small is-danger is-outlined\" title=\"Bulk delete\" data-action=\"bulk-delete-uploads\">\n <span class=\"icon\">\n <i class=\"icon-trash\"></i>\n </span>\n <span>Bulk delete</span>\n </a>\n </div>\n </div>\n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const filterAllByAlbums = params.all && params.filters && params.filters.includes('albumid:')\n const hasExpiryDateColumn = files.some(file => typeof file.expirydate !== 'undefined')\n const showOriginalNames = page.views[page.currentView].originalNames\n\n for (let i = 0; i < files.length; i++) {\n // Build full URLs\n files[i].file = `${basedomain || window.location.origin}/${files[i].name}`\n if (files[i].thumb) {\n files[i].thumb = `${basedomain ? `${basedomain}/` : ''}${files[i].thumb}`\n }\n\n // Determine types\n const extname = files[i].extname.toLowerCase()\n if (page.imageExts.includes(extname)) {\n files[i].type = 'picture'\n } else if (page.videoExts.includes(extname)) {\n files[i].type = 'video'\n } else if (page.audioExts.includes(extname)) {\n files[i].type = 'audio'\n } else {\n files[i].type = 'other'\n }\n\n files[i].previewable = files[i].thumb || files[i].type === 'audio'\n\n // Cache bare minimum data for thumbnails viewer\n page.cache[files[i].id] = {\n name: files[i].name,\n original: files[i].original,\n extname: files[i].extname,\n thumb: files[i].thumb,\n file: files[i].file,\n type: files[i].type,\n previewable: files[i].previewable\n }\n\n // Prettify\n files[i].prettyAlbum = (albums && files[i].albumid && albums[files[i].albumid])\n ? `[${files[i].albumid}] ${albums[files[i].albumid]}` || ''\n : ''\n files[i].prettyBytes = page.getPrettyBytes(parseInt(files[i].size))\n files[i].prettyDate = page.getPrettyDate(new Date(files[i].timestamp * 1000))\n files[i].prettyUser = (users && files[i].userid && users[files[i].userid])\n ? users[files[i].userid]\n : ''\n\n if (hasExpiryDateColumn) {\n files[i].prettyExpiryDate = files[i].expirydate\n ? page.getPrettyDate(new Date(files[i].expirydate * 1000))\n : null\n }\n\n // Update selected status\n files[i].selected = page.selected[page.currentView].includes(files[i].id)\n if (!files[i].selected) {\n unselected = true\n }\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n <div id=\"table\" class=\"columns is-multiline is-mobile is-centered\">\n </div>\n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n let appendix = ''\n if (params.all) {\n appendix += upload.prettyUser ? `<span>${upload.prettyUser}</span> \\u2013 ` : ''\n }\n if (!params.all || filterAllByAlbums) {\n appendix += upload.prettyAlbum ? `<span>${upload.prettyAlbum}</span> \\u2013 ` : ''\n }\n\n const div = document.createElement('div')\n div.className = 'image-container column'\n div.dataset.id = upload.id\n\n if (upload.thumb === undefined) {\n div.innerHTML = `<a class=\"image\" href=\"${upload.file}\" target=\"_blank\"><h1 class=\"title\">${upload.extname || 'N/A'}</h1></a>`\n } else {\n div.innerHTML = `<a class=\"image\" href=\"${upload.file}\" target=\"_blank\"><img alt=\"${upload.name}\" data-src=\"${upload.thumb}\"/></a>`\n }\n\n div.innerHTML += `\n <input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${upload.selected ? ' checked' : ''}>\n <div class=\"controls\">\n ${upload.previewable\n ? `<a class=\"button is-small is-primary\" title=\"Display preview\" data-action=\"display-preview\">\n <span class=\"icon\">\n <i class=\"${upload.type !== 'other' ? `icon-${upload.type}` : 'icon-doc-inv'}\"></i>\n </span>\n </a>`\n : ''}\n <a class=\"button is-small is-info\" title=\"View file info\" href=\"file/${upload.name}\" target=\"_blank\">\n <span class=\"icon\">\n <i class=\"icon-info\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info clipboard-js\" title=\"Copy link to clipboard\" data-clipboard-text=\"${upload.file}\">\n <span class=\"icon\">\n <i class=\"icon-clipboard\"></i>\n </span>\n </a>\n <a class=\"button is-small is-warning\" title=\"Add to album\" data-action=\"add-to-album\">\n <span class=\"icon\">\n <i class=\"icon-plus\"></i>\n </span>\n </a>\n <a class=\"button is-small is-danger\" title=\"Delete\" data-action=\"delete-upload\">\n <span class=\"icon\">\n <i class=\"icon-trash\"></i>\n </span>\n </a>\n </div>\n <div class=\"details\">\n <p class=\"name\" title=\"${upload.file}\">${upload.name}</p>\n ${showOriginalNames ? `<p class=\"originalname\" title=\"${upload.original}\">${upload.original}</p>` : ''}\n <p class=\"prettybytes\" data-bytes=\"${upload.size}\">${appendix}${upload.prettyBytes}</p>\n ${hasExpiryDateColumn && upload.prettyExpiryDate\n ? `<p class=\"prettyexpirydate\"${upload.expirydate ? ` data-timestamp=\"${upload.expirydate}\"` : ''}>EXP: ${upload.prettyExpiryDate}</p>`\n : ''}\n </div>\n `\n\n table.appendChild(div)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n } else {\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n <div class=\"table-container has-text-left\">\n <table class=\"table is-narrow is-fullwidth is-hoverable\">\n <thead>\n <tr>\n <th class=\"controls\"><input id=\"selectAll\" class=\"checkbox\" type=\"checkbox\" title=\"Select all\" data-action=\"select-all\"></th>\n <th title=\"Key: name\">File name</th>\n ${showOriginalNames ? '<th title=\"Key: original\">Original name</th>' : ''}\n ${params.all ? '<th title=\"Key: userid\">User</th>' : ''}\n ${!params.all || filterAllByAlbums ? '<th title=\"Key: albumid\">Album</th>' : ''}\n <th title=\"Key: size\">Size</th>\n ${params.all ? '<th title=\"Key: ip\">IP</th>' : ''}\n <th title=\"Key: timestamp\">Upload date</th>\n ${hasExpiryDateColumn ? '<th title=\"Key: expirydate\">Expiry date</th>' : ''}\n <th class=\"has-text-right\">(${response.data.count} total)</th>\n </tr>\n </thead>\n <tbody id=\"table\">\n </tbody>\n </table>\n </div>\n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < files.length; i++) {\n const upload = files[i]\n\n const tr = document.createElement('tr')\n tr.dataset.id = upload.id\n tr.innerHTML = `\n <td class=\"controls\"><input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${upload.selected ? ' checked' : ''}></td>\n <th class=\"name\"><a href=\"${upload.file}\" target=\"_blank\" title=\"${upload.file}\">${upload.name}</a></th>\n ${showOriginalNames ? `<th class=\"originalname\" title=\"${upload.original}\">${upload.original}</th>` : ''}\n ${params.all ? `<th class=\"appendix\">${upload.prettyUser}</th>` : ''}\n ${!params.all || filterAllByAlbums ? `<th class=\"album\">${upload.prettyAlbum}</th>` : ''}\n <td class=\"prettybytes\" data-bytes=\"${upload.size}\">${upload.prettyBytes}</td>\n ${params.all ? `<td class=\"ip\">${upload.ip || ''}</td>` : ''}\n <td class=\"prettydate\" data-timestamp=\"${upload.timestamp}\">${upload.prettyDate}</td>\n ${hasExpiryDateColumn ? `<td class=\"prettyexpirydate\"${upload.expirydate ? ` data-timestamp=\"${upload.expirydate}\"` : ''}>${upload.prettyExpiryDate || '-'}</td>` : ''}\n <td class=\"controls has-text-right\">\n <a class=\"button is-small is-primary is-outlined\" title=\"${upload.previewable ? 'Display preview' : 'File can\\'t be previewed'}\" data-action=\"display-preview\"${upload.previewable ? '' : ' disabled'}>\n <span class=\"icon\">\n <i class=\"${upload.type !== 'other' ? `icon-${upload.type}` : 'icon-doc-inv'}\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info is-outlined\" title=\"View file info\" href=\"file/${upload.name}\" target=\"_blank\">\n <span class=\"icon\">\n <i class=\"icon-info\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info is-outlined clipboard-js\" title=\"Copy link to clipboard\" data-clipboard-text=\"${upload.file}\">\n <span class=\"icon\">\n <i class=\"icon-clipboard\"></i>\n </span>\n </a>\n ${params.all\n ? ''\n : `<a class=\"button is-small is-warning is-outlined\" title=\"Add to album\" data-action=\"add-to-album\">\n <span class=\"icon\">\n <i class=\"icon-plus\"></i>\n </span>\n </a>`}\n <a class=\"button is-small is-danger is-outlined\" title=\"Delete\" data-action=\"delete-upload\">\n <span class=\"icon\">\n <i class=\"icon-trash\"></i>\n </span>\n </a>\n </td>\n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (files.length && selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = files.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n const disableSmooth = !params.forceScroll && page.views[page.currentView].type === 'thumbs'\n page.scrollToDom(disableSmooth)\n }\n\n if (page.views[page.currentView].type === 'thumbs') {\n page.lazyLoad.update()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'uploads') {\n page.views.uploads.album = params.album\n }\n page.views[page.currentView].filters = params.filters\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.setUploadsView = (view, element) => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (view === 'list') {\n delete localStorage[lsKeys.viewType[page.currentView]]\n page.views[page.currentView].type = undefined\n } else {\n localStorage[lsKeys.viewType[page.currentView]] = view\n page.views[page.currentView].type = view\n }\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n trigger: element\n }))\n}\n\npage.toggleOriginalNames = element => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (page.views[page.currentView].originalNames) {\n delete localStorage[lsKeys.originalNames[page.currentView]]\n page.views[page.currentView].originalNames = false\n } else {\n localStorage[lsKeys.originalNames[page.currentView]] = '1'\n page.views[page.currentView].originalNames = true\n }\n\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n trigger: element\n }))\n}\n\npage.displayPreview = id => {\n const file = page.cache[id]\n if (!file.previewable) return\n\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"content has-text-centered\">\n <p>\n <div class=\"has-text-weight-bold has-word-break-all\">${file.name}</div>\n <div class=\"has-word-break-all\">${file.original}</div>\n </p>\n ${file.thumb\n ? `<p class=\"swal-display-thumb-container\">\n <img id=\"swalThumb\" src=\"${file.thumb}\">\n </p>`\n : ''}\n </div>\n `\n\n if (file.file && ['picture', 'video', 'audio'].includes(file.type)) {\n div.innerHTML += `\n <div class=\"field has-text-centered\">\n <div class=\"controls\">\n <a id=\"swalOriginal\" type=\"button\" class=\"button is-info\">\n <span class=\"icon\">\n <i class=\"icon-${file.type}\"></i>\n </span>\n <span>${file.type === 'picture' ? 'Load original' : 'Play in embedded player'}</span>\n </a>\n </div>\n </div>\n `\n\n if (file.type === 'picture') {\n div.querySelector('#swalOriginal').addEventListener('click', event => {\n const trigger = event.currentTarget\n if (trigger.classList.contains('is-danger')) return\n\n trigger.classList.add('is-loading')\n const thumb = div.querySelector('#swalThumb')\n\n thumb.src = file.file\n thumb.onload = () => {\n trigger.classList.add('is-hidden')\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n }\n thumb.onerror = event => {\n event.currentTarget.classList.add('is-hidden')\n trigger.className = 'button is-danger is-fullwidth'\n trigger.innerHTML = `\n <span class=\"icon\">\n <i class=\"icon-block\"></i>\n </span>\n <span>Unable to load original</span>\n `\n }\n })\n } else {\n const match = file.file.match(/.*\\/(.*)$/)\n if (match || match[1]) {\n div.querySelector('#swalOriginal').setAttribute('href', `v/${match[1]}`)\n div.querySelector('#swalOriginal').setAttribute('target', '_blank')\n }\n }\n }\n\n return swal({\n content: div,\n buttons: false\n }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n}\n\npage.selectAll = element => {\n for (let i = 0; i < page.checkboxes.length; i++) {\n const id = page.getItemID(page.checkboxes[i])\n if (isNaN(id)) continue\n if (page.checkboxes[i].checked !== element.checked) {\n page.checkboxes[i].checked = element.checked\n if (page.checkboxes[i].checked) {\n page.selected[page.currentView].push(id)\n } else {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n }\n\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n element.title = element.checked ? 'Unselect all' : 'Select all'\n}\n\npage.selectInBetween = (element, lastElement) => {\n const thisIndex = parseInt(element.dataset.index)\n const lastIndex = parseInt(lastElement.dataset.index)\n\n const distance = Math.abs(thisIndex - lastIndex)\n if (distance < 2) return\n\n for (let i = 0; i < page.checkboxes.length; i++) {\n if ((thisIndex > lastIndex && i > lastIndex && i < thisIndex) ||\n (thisIndex < lastIndex && i > thisIndex && i < lastIndex)) {\n // Check or uncheck depending on the state of the initial checkbox\n const checked = page.checkboxes[i].checked = lastElement.checked\n const id = page.getItemID(page.checkboxes[i])\n if (!page.selected[page.currentView].includes(id) && checked) {\n page.selected[page.currentView].push(id)\n } else if (page.selected[page.currentView].includes(id) && !checked) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n }\n }\n}\n\npage.select = (element, event) => {\n const id = page.getItemID(element)\n if (isNaN(id)) return\n\n if (event.shiftKey && page.lastSelected) {\n page.selectInBetween(element, page.lastSelected)\n // Check or uncheck depending on the state of the initial checkbox\n element.checked = page.lastSelected.checked\n } else {\n page.lastSelected = element\n }\n\n if (!page.selected[page.currentView].includes(id) && element.checked) {\n page.selected[page.currentView].push(id)\n } else if (page.selected[page.currentView].includes(id) && !element.checked) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n}\n\npage.clearSelection = () => {\n const selected = page.selected[page.currentView]\n const type = page.getByView(page.currentView, 'type')\n const count = selected.length\n if (!count) return swal('An error occurred!', `You have not selected any ${type}.`, 'error')\n\n const suffix = count === 1 ? type.substring(0, type.length - 1) : type\n return swal({\n title: 'Are you sure?',\n text: `You are going to unselect ${count} ${suffix}.`,\n buttons: true\n }).then(proceed => {\n if (!proceed) return\n\n const checkboxes = page.checkboxes\n for (let i = 0; i < checkboxes.length; i++) {\n if (checkboxes[i].checked) {\n checkboxes[i].checked = false\n }\n }\n\n page.selected[page.currentView] = []\n delete localStorage[lsKeys.selected[page.currentView]]\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll) selectAll.checked = false\n\n return swal('Cleared selection!', `Unselected ${count} ${suffix}.`, 'success')\n })\n}\n\npage.uploadFiltersHelp = element => {\n const all = Boolean(element.dataset.all)\n const content = document.createElement('div')\n content.style = 'text-align: left'\n content.innerHTML = `${all\n ? `There are 2 filter keys, namely <b>user</b> (username) and <b>ip</b>.\n These keys can be specified more than once.\n For usernames with whitespaces, wrap them with double quotes (<code>\"</code>).\n Special cases such as uploads by non-registered users or have no IPs respectively, use <code>user:-</code> or <code>ip:-</code>.\n\n To exclude certain users/ips while still listing every other uploads, add negation sign (<code>-</code>) before the keys.\n Negation sign can also be used to exclude the special cases mentioned above (i.e. <code>-user:-</code> or <code>-ip:-</code>).\n\n If you know the ID of a user's album, you can list its uploads with <b>albumid</b> key.\n Negation sign works for this key as well.`\n : `There is only 1 filter key, namely <b>albumid</b>.\n This key can be specified more than once.\n Special case such as uploads with no albums, use <code>albumid:-</code>.\n\n To exclude certain albums while still listing every other uploads, add negation sign (<code>-</code>) before the keys.\n Negation sign can also be used to exclude the special case mentioned above (i.e. <code>-albumid:-</code>).`}\n\n There are 2 range keys: <b>date</b> (upload date) and <b>expiry</b> (expiry date).\n Their format is: <code>\"YYYY/MM/DD HH:MM:SS-YYYY/MM/DD HH:MM:SS\"</code> (\"from\" date and \"to\" date respectively).\n You may specify only one of the dates.\n If \"to\" date is missing, 'now' will be used. If \"from\" date is missing, 'beginning of time' will be used.\n If any of the subsequent date or time units are not specified, their first value will be used (e.g. January for month, 1 for day, and so on).\n If only time is specified, today's date will be used.\n If you do not need to specify both date and time, you may omit the double quotes.\n In conclusion, the following examples are all valid: <code>date:\"2020/01/01 01:23-2018/01/01 06\"</code>, <code>expiry:-2020/05</code>, <code>date:12:34:56</code>.\n These keys can only be specified once each.\n\n <b>Timezone?</b> Feel free to query the dates with your own timezone.\n API requests to the filter endpoint will attach your browser's timezone offset, so the server will automatically calculate timezone differences.\n\n Matches can also be sorted with <b>sort</b> keys.\n Their formats are: <code>sort:columnName[:d[escending]]</code>, where <code>:d[escending]</code> is an optional tag to set the direction to descending.\n This key must be used with internal column names used in the database (<code>id</code>, <code>${all ? 'userid' : 'albumid'}</code>, and so on),\n but there are 2 shortcuts available: <b>date</b> for <code>timestamp</code> column and <b>expiry</b> for <code>expirydate</code> column.\n This key can also be specified more than once, where their order will decide the sorting steps.\n\n Finally, there are type-<b>is</b> keys to refine by types.\n You can use <code>is:image</code>, <code>is:video</code>, and <code>is:audio</code> to list images, videos, audios respectively.\n This will only use image, video and audio extensions that are whitelisted internally in the safe.\n For images and videos specifically, they will be the ones whose thumbnails can be generated by the safe.\n Negation sign works for this key as well.\n Mixing inclusion and exclusion is not allowed (i.e. <code>is:image -is:video</code>, since the second key is redundant).\n\n Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' file names.\n Excluding certain keywords is also supported by adding negation sign before the keywords.\n\n <b>Internal steps:</b>\n ${all\n ? `- Query uploads passing ALL exclusion filter keys OR matching ANY filter keys, if any.\n - Refine matches`\n : '- Filter uploads'} using date key, if any.\n - Refine matches using expiry key, if any.\n - Refine matches using type-is keys, if any.\n - Refine matches using ANY non-keyed keywords, if any.\n - Filter matches using ALL exclusion non-keyed keywords, if any.\n - Sort matches using sorting keys, if any.\n\n <b>Examples:</b>\n ${all\n ? `- Uploads from users named \"demo\" AND/OR \"John Doe\" AND/OR non-registered users:\n <code>user:demo user:\"John Doe\" user:-</code>\n - ALL uploads, but NOT the ones from user named \"demo\" AND \"John Doe\":\n <code>-user:demo -user:\"John Doe\"</code>\n - Uploads from IP \"127.0.0.1\" AND which file names match \"*.rar\" OR \"*.zip\":\n <code>ip:127.0.0.1 *.rar *.zip</code>\n `\n : ''}- Uploads without albums:\n <code>albumid:-</code>\n - ALL uploads, but NOT the ones from album with ID 69:\n <code>-albumid:69</code>\n - Uploads uploaded since \"1 June 2019 00:00:00\":\n <code>date:2019/06</code>\n - Uploads uploaded between \"7 April 2020 12:00:00\" and \"7 April 2020 23:59:59\":\n <code>date:\"2020/04/07 12-2020/04/07 23:59:59\"</code>\n - Uploads uploaded before \"5 February 2020 00:00:00\":\n <code>date:-2020/02/05</code>\n - Uploads which file names match \"*.gz\" but NOT \"*.tar.gz\":\n <code>*.gz -*.tar.gz</code>\n - Sort matches by \"size\" column in ascending and descending order respectively:\n <code>${all ? 'user:\"John Doe\"' : '*.txt'} sort:size</code>\n <code>*.mp4 ${all ? 'user:- ' : ''}sort:size:d</code>\n ${!page.permissions.moderator\n ? '<b>Notice:</b> Regular users may face some limitations in the amount of keys that can be used at a time.'\n : ''}\n <b>Friendly reminder:</b> This window can be scrolled up!\n `.trim().replace(/^\\s*/g, '').replace(/\\n/g, '<br>')\n\n swal({ content }).then(() => {\n // Restore modal size\n document.body.querySelector('.swal-overlay .swal-modal').classList.remove('is-expanded')\n })\n\n // Expand modal size\n document.body.querySelector('.swal-overlay .swal-modal:not(.is-expanded)').classList.add('is-expanded')\n}\n\npage.filterUploads = element => {\n const filters = document.querySelector(`#${element.dataset.filtersid || 'filters'}`).value\n .trim()\n .replace(/\\t/g, ' ')\n .replace(/(^|\\s)((albumid|ip|user|date|expiry|is|sort|orderby):)\\s+/g, '$2')\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n filters,\n pageNum: 0,\n trigger: element\n }))\n}\n\npage.viewUserUploads = (id, element) => {\n const user = page.cache[id]\n if (!user) return\n element.classList.add('is-loading')\n // Wrap username in quotes if it contains whitespaces\n const username = user.username.includes(' ')\n ? `\"${user.username}\"`\n : user.username\n page.getUploads({\n all: true,\n filters: `user:${username}`,\n trigger: document.querySelector('#itemManageUploads')\n })\n}\n\npage.viewAlbumUploads = (id, element) => {\n if (!page.cache[id]) return\n element.classList.add('is-loading')\n // eslint-disable-next-line compat/compat\n const all = page.currentView === 'albumsAll' && page.permissions.moderator\n page.getUploads({\n all,\n filters: `albumid:${id}`,\n trigger: all\n ? document.querySelector('#itemManageUploads')\n : document.querySelector('#itemUploads')\n })\n}\n\npage.deleteUpload = id => {\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: [id],\n cb (failed) {\n // Remove from remembered checkboxes if necessary\n if (!failed.length && page.selected[page.currentView].includes(id)) {\n page.selected[page.currentView].splice(page.selected[page.currentView].indexOf(id), 1)\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n // Reload upload list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.bulkDeleteUploads = () => {\n const count = page.selected[page.currentView].length\n if (!count) return swal('An error occurred!', 'You have not selected any uploads.', 'error')\n\n page.postBulkDeleteUploads({\n all: page.currentView === 'uploadsAll',\n field: 'id',\n values: page.selected[page.currentView],\n cb (failed) {\n // Update state of checkboxes\n if (failed.length) {\n page.selected[page.currentView] = page.selected[page.currentView]\n .filter(id => failed.includes(id))\n } else {\n page.selected[page.currentView] = []\n }\n\n // Update local storage\n if (page.selected[page.currentView].length) {\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n } else {\n delete localStorage[lsKeys.selected[page.currentView]]\n }\n\n // Reload uploads list\n // eslint-disable-next-line compat/compat\n page.getUploads(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }\n })\n}\n\npage.deleteUploadsByNames = (params = {}) => {\n let appendix = ''\n if (page.permissions.moderator) {\n appendix = '<br><b>Hint:</b> You can use this feature to delete uploads by other users.'\n }\n\n page.dom.innerHTML = `\n <form class=\"prevent-default\">\n <div class=\"field\">\n <label class=\"label\">Upload names:</label>\n <div class=\"control\">\n <textarea id=\"bulkDeleteNames\" class=\"textarea\"></textarea>\n </div>\n <p class=\"help\">Separate each entry with a new line.${appendix}</p>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <button type=\"submit\" id=\"submitBulkDelete\" class=\"button is-danger is-outlined is-fullwidth\">\n <span class=\"icon\">\n <i class=\"icon-trash\"></i>\n </span>\n <span>Bulk delete</span>\n </button>\n </div>\n </div>\n </form>\n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#submitBulkDelete').addEventListener('click', () => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n const textArea = document.querySelector('#bulkDeleteNames')\n\n // Clean up\n const seen = {}\n const names = textArea.value\n .split(/\\r?\\n/)\n .map(name => {\n const trimmed = name.trim()\n return /^[^\\s]+$/.test(trimmed)\n ? trimmed\n : ''\n })\n .filter(name => {\n // Filter out invalid and duplicate names\n return (!name || Object.prototype.hasOwnProperty.call(seen, name))\n ? false\n : (seen[name] = true)\n })\n\n // Update textarea with cleaned names\n textArea.value = names.join('\\n')\n\n if (!names.length) {\n return swal('An error occurred!', 'You have not entered any upload names.', 'error')\n }\n\n page.postBulkDeleteUploads({\n all: true,\n field: 'name',\n values: names,\n cb (failed) {\n textArea.value = failed.join('\\n')\n }\n })\n })\n}\n\npage.postBulkDeleteUploads = (params = {}) => {\n const count = params.values.length\n\n const objective = `${params.values.length} upload${count === 1 ? '' : 's'}`\n const boldObjective = objective.replace(/^(\\d*)(.*)/, '<b>$1</b>$2')\n let text = `<p>You won't be able to recover ${boldObjective}!</p>`\n\n if (params.all) {\n const obj1 = count === 1 ? 'an upload' : 'some uploads'\n const obj2 = count === 1 ? 'another user' : 'other users'\n text += `\\n<p><b>Warning:</b> You may be nuking ${obj1} by ${obj2}!</p>`\n }\n\n const content = document.createElement('div')\n content.innerHTML = text\n\n swal({\n title: 'Are you sure?',\n content,\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: `Yes, nuke ${params.values.length === 1 ? 'it' : 'them'}!`,\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/upload/bulkdelete', {\n field: params.field,\n values: params.values\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const failed = Array.isArray(response.data.failed) ? response.data.failed : []\n if (failed.length === params.values.length) {\n swal('An error occurred!', `Unable to delete any of the ${objective}.`, 'error')\n } else if (failed.length && failed.length < params.values.length) {\n swal('Warning!', `From ${objective}, unable to delete ${failed.length} of them.`, 'warning')\n } else {\n swal('Deleted!', `${objective} ${count === 1 ? 'has' : 'have'} been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n }\n\n if (typeof params.cb === 'function') params.cb(failed)\n }).catch(page.onAxiosError)\n })\n}\n\npage.addSelectedUploadsToAlbum = () => {\n if (page.currentView !== 'uploads') return\n\n const count = page.selected[page.currentView].length\n if (!count) return swal('An error occurred!', 'You have not selected any uploads.', 'error')\n\n page.addUploadsToAlbum(page.selected[page.currentView], failed => {\n if (!failed) return\n if (failed.length) {\n page.selected[page.currentView] = page.selected[page.currentView]\n .filter(id => failed.includes(id))\n } else {\n page.selected[page.currentView] = []\n }\n\n localStorage[lsKeys.selected[page.currentView]] = JSON.stringify(page.selected[page.currentView])\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addToAlbum = id => {\n page.addUploadsToAlbum([id], failed => {\n if (!failed) return\n page.getUploads(page.views[page.currentView])\n })\n}\n\npage.addUploadsToAlbum = (ids, callback) => {\n const count = ids.length\n\n const content = document.createElement('div')\n content.innerHTML = `\n <div class=\"field has-text-centered\">\n <p>You are about to add <b>${count}</b> upload${count === 1 ? '' : 's'} to an album.</p>\n <p><b>If an upload is already in an album, it will be moved.</b></p>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <div class=\"select is-fullwidth\">\n <select id=\"swalAlbum\" disabled>\n <option value=\"-1\">Remove from album</option>\n <option value=\"\" selected disabled>Fetching albums list\\u2026</option>\n </select>\n </div>\n </div>\n </div>\n `\n\n swal({\n icon: 'warning',\n content,\n buttons: {\n cancel: true,\n confirm: {\n text: 'OK',\n closeModal: false\n }\n }\n }).then(choose => {\n if (!choose) return\n\n const albumid = parseInt(document.querySelector('#swalAlbum').value)\n if (isNaN(albumid)) return swal('An error occurred!', 'You did not choose an album.', 'error')\n\n axios.post('api/albums/addfiles', {\n ids,\n albumid\n }).then(add => {\n if (!add) return\n\n if (add.data.success === false) {\n if (add.data.description === 'No token provided') {\n page.verifyToken(page.token)\n } else {\n swal('An error occurred!', add.data.description, 'error')\n }\n return\n }\n\n let added = ids.length\n if (add.data.failed && add.data.failed.length) {\n added -= add.data.failed.length\n }\n\n const suffix = `upload${ids.length === 1 ? '' : 's'}`\n if (!added) return swal('An error occurred!', `Could not add the ${suffix} to the album.`, 'error')\n\n swal('Woohoo!', `Successfully ${albumid < 0 ? 'removed' : 'added'} ${added} ${suffix} ${albumid < 0 ? 'from' : 'to'} the album.`, 'success', {\n buttons: false,\n timer: 1500\n })\n callback(add.data.failed)\n }).catch(page.onAxiosError)\n })\n\n // Get albums list then update content of swal\n axios.get('api/albums', { headers: { simple: '1' } }).then(list => {\n if (list.data.success === false) {\n if (list.data.description === 'No token provided') {\n page.verifyToken(page.token)\n } else {\n swal('An error occurred!', list.data.description, 'error')\n }\n return\n }\n\n // If the prompt was replaced, the container would be missing\n const select = document.querySelector('#swalAlbum')\n if (!select) return\n\n select.innerHTML += list.data.albums\n .map(album => {\n return `<option value=\"${album.id}\">${album.name}</option>`\n })\n .join('\\n')\n\n select.getElementsByTagName('option')[1].innerHTML = 'Choose an album'\n select.removeAttribute('disabled')\n }).catch(page.onAxiosError)\n}\n\npage.getAlbums = (params = {}) => {\n if (params && params.all && !page.permissions.moderator) {\n return swal('An error occurred!', 'You cannot do this!', 'error')\n }\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number') params.pageNum = 0\n\n const headers = {}\n if (params.all) headers.all = '1'\n\n const url = `api/albums/${params.pageNum}`\n axios.get(url, { headers }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const albumsPerPage = response.data.albumsPerPage || 25\n const pages = Math.ceil(response.data.count / albumsPerPage)\n const albums = response.data.albums\n if (params.pageNum && (albums.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getAlbums(params)\n } else {\n return swal('An error occurred!', `There are no more albums to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = params.all ? 'albumsAll' : 'albums'\n page.cache = {}\n\n const users = response.data.users\n const homeDomain = response.data.homeDomain || window.location.origin\n\n if (params.pageNum < 0) {\n params.pageNum = Math.max(0, pages + params.pageNum)\n }\n const pagination = page.paginate(response.data.count, albumsPerPage, params.pageNum)\n\n const filter = `\n <div class=\"column\">\n <form class=\"prevent-default\">\n <div class=\"field has-addons\">\n <div class=\"control is-expanded\">\n <input id=\"filters\" class=\"input is-small\" type=\"text\" placeholder=\"Filter albums (WIP)\" value=\"${page.escape(params.filters || '')}\" disabled>\n </div>\n <div class=\"control\">\n <button type=\"button\" class=\"button is-small is-primary is-outlined\" title=\"Help? (WIP)\" data-action=\"album-filters-help\" disabled>\n <span class=\"icon\">\n <i class=\"icon-help-circled\"></i>\n </span>\n </button>\n </div>\n <div class=\"control\">\n <button type=\"submit\" class=\"button is-small is-info is-outlined\" title=\"Filter albums (WIP)\" data-action=\"filter-albums\" disabled>\n <span class=\"icon\">\n <i class=\"icon-filter\"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n `\n const extraControls = `\n <div class=\"columns\">\n ${filter}\n <div class=\"column is-one-quarter\">\n <form class=\"prevent-default\">\n <div class=\"field has-addons\">\n <div class=\"control is-expanded\">\n <input id=\"jumpToPage\" class=\"input is-small\" type=\"number\" min=\"1\" max=\"${pages}\" value=\"${params.pageNum + 1}\"${pages === 1 ? ' disabled' : ''}>\n </div>\n <div class=\"control\">\n <button type=\"submit\" class=\"button is-small is-info is-outlined\" title=\"Jump to page\" data-action=\"jump-to-page\">\n <span class=\"icon\">\n <i class=\"icon-paper-plane\"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n </div>\n `\n\n const controls = `\n <div class=\"columns\">\n <div class=\"column is-hidden-mobile\"></div>\n <div class=\"column bulk-operations has-text-right\">\n <a class=\"button is-small is-info is-outlined\" title=\"Clear selection\" data-action=\"clear-selection\">\n <span class=\"icon\">\n <i class=\"icon-cancel\"></i>\n </span>\n </a>\n <a class=\"button is-small is-dangerish is-outlined\" title=\"Bulk disable (WIP)\" data-action=\"bulk-disable-albums\" disabled>\n <span class=\"icon\">\n <i class=\"icon-cancel\"></i>\n </span>\n ${!params.all ? '<span>Bulk disable</span>' : ''}\n </a>\n ${params.all\n ? `<a class=\"button is-small is-danger is-outlined\" title=\"Bulk delete (WIP)\" data-action=\"bulk-delete-albums\" disabled>\n <span class=\"icon\">\n <i class=\"icon-trash\"></i>\n </span>\n <span>Bulk delete</span>\n </a>`\n : ''}\n </div>\n </div>\n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const createNewAlbum = `\n <h2 class=\"subtitle\">Create new album</h2>\n <form class=\"prevent-default\">\n <div class=\"field\">\n <div class=\"control\">\n <input id=\"albumName\" class=\"input\" type=\"text\" placeholder=\"Name\" maxlength=\"${page.albumTitleMaxLength}\">\n </div>\n <p class=\"help\">Max length is ${page.albumTitleMaxLength} characters.</p>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <textarea id=\"albumDescription\" class=\"textarea\" placeholder=\"Description\" rows=\"1\" maxlength=\"${page.albumDescMaxLength}\"></textarea>\n </div>\n <p class=\"help\">Max length is ${page.albumDescMaxLength} characters.</p>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <button type=\"submit\" id=\"submitAlbum\" class=\"button is-info is-outlined is-fullwidth\" data-action=\"submit-album\">\n <span class=\"icon\">\n <i class=\"icon-paper-plane\"></i>\n </span>\n <span>Create</span>\n </button>\n </div>\n </div>\n </form>\n <hr>\n `\n\n page.dom.innerHTML = `\n ${!params.all ? createNewAlbum : ''}\n ${pagination}\n ${extraControls}\n ${controls}\n <div class=\"table-container has-text-left\">\n <table class=\"table is-narrow is-fullwidth is-hoverable\">\n <thead>\n <tr>\n <th><input id=\"selectAll\" class=\"checkbox\" type=\"checkbox\" title=\"Select all\" data-action=\"select-all\"></th>\n <th>ID</th>\n <th>Name</th>\n ${params.all ? '<th>User</th>' : ''}\n <th>Uploads</th>\n <th>Size</th>\n <th>Created at</th>\n <th>ZIP size</th>\n <th>ZIP generated at</th>\n <th>Public link</th>\n <th class=\"has-text-right\">(${response.data.count} total)</th>\n </tr>\n </thead>\n <tbody id=\"table\">\n </tbody>\n </table>\n </div>\n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const urlPath = '/a/'\n const albumUrlText = urlPath + album.identifier\n const albumUrl = homeDomain + albumUrlText\n\n const selected = page.selected[page.currentView].includes(album.id)\n if (!selected) {\n unselected = true\n }\n\n // Prettify\n album.hasZip = album.zipSize !== null\n album.prettyDate = page.getPrettyDate(new Date(album.timestamp * 1000))\n album.prettyZipDate = album.hasZip ? page.getPrettyDate(new Date(album.zipGeneratedAt * 1000)) : null\n album.isZipExpired = album.hasZip && !(album.zipGeneratedAt > album.editedAt)\n\n // Server-side explicitly expect this value to consider an album as disabled\n const enabled = album.enabled !== 0\n page.cache[album.id] = {\n name: album.name,\n download: album.download,\n public: album.public,\n description: album.description,\n descriptionHtml: album.descriptionHtml,\n enabled,\n homeDomain,\n urlPath,\n identifier: album.identifier\n }\n\n const tr = document.createElement('tr')\n tr.dataset.id = album.id\n tr.innerHTML = `\n <td class=\"controls\"><input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${selected ? ' checked' : ''}></td>\n <th>${album.id}</th>\n <th${enabled ? '' : ' class=\"has-text-grey\"'}>${album.name}</td>\n ${params.all ? `<th>${album.userid ? (users[album.userid] || '') : ''}</th>` : ''}\n <th>${album.uploads}</th>\n <td data-bytes=\"${album.size}\">${page.getPrettyBytes(album.size)}</td>\n <td data-timestamp=\"${album.timestamp}\">${album.prettyDate}</td>\n <td${album.hasZip ? ` data-bytes=\"${album.zipSize}\"` : ''}>${album.hasZip ? page.getPrettyBytes(album.zipSize) : '-'}</td>\n <td${album.hasZip ? ` data-timestamp=\"${album.zipGeneratedAt}\"` : ''}${album.isZipExpired ? ' class=\"has-text-warning\" title=\"This album has been modified since the last time its ZIP was generated.\"' : ''}>${album.hasZip ? album.prettyZipDate : '-'}</td$>\n <td><a ${enabled && album.public ? '' : 'class=\"is-linethrough\" '}href=\"${albumUrl}\" target=\"_blank\">${albumUrlText}</a></td>\n <td class=\"has-text-right\" data-id=\"${album.id}\">\n <a class=\"button is-small is-primary is-outlined\" title=\"Edit album\" data-action=\"edit-album\">\n <span class=\"icon is-small\">\n <i class=\"icon-pencil\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info is-outlined\" title=\"${album.uploads ? 'View uploads' : 'Album doesn\\'t have uploads'}\" data-action=\"view-album-uploads\" ${album.uploads ? '' : 'disabled'}>\n <span class=\"icon\">\n <i class=\"icon-docs\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info is-outlined clipboard-js\" title=\"Copy link to clipboard\" ${album.public ? `data-clipboard-text=\"${albumUrl}\"` : 'disabled'}>\n <span class=\"icon is-small\">\n <i class=\"icon-clipboard\"></i>\n </span>\n </a>\n <a class=\"button is-small is-warning is-outlined\" title=\"Download album\" ${enabled && album.download ? `href=\"api/album/zip/${album.identifier}?v=${album.editedAt}\"` : 'disabled'}>\n <span class=\"icon is-small\">\n <i class=\"icon-download\"></i>\n </span>\n </a>\n <a class=\"button is-small is-dangerish is-outlined\" title=\"Disable album\" data-action=\"disable-album\"${enabled ? '' : ' disabled'}>\n <span class=\"icon is-small\">\n <i class=\"icon-cancel\"></i>\n </span>\n </a>\n ${params.all\n ? `<a class=\"button is-small is-danger is-outlined\" title=\"Delete album\" data-action=\"delete-album\">\n <span class=\"icon is-small\">\n <i class=\"icon-trash\"></i>\n </span>\n </a>`\n : ''}\n </td>\n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (albums.length && selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = albums.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n page.scrollToDom()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'albumsAll') {\n page.views[page.currentView].filters = params.filters\n }\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.editAlbum = id => {\n const album = page.cache[id]\n if (!album) return\n\n const albumUrlText = album.urlPath + album.identifier\n const albumUrl = album.homeDomain + albumUrlText\n\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <div class=\"controls\">\n <input id=\"swalName\" class=\"input\" type=\"text\" placeholder=\"Name\" maxlength=\"${page.albumTitleMaxLength}\" value=\"${(album.name || '').substring(0, page.albumTitleMaxLength)}\">\n </div>\n <p class=\"help\">Max length is ${page.albumTitleMaxLength} characters.</p>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <textarea id=\"swalDescription\" class=\"textarea\" placeholder=\"Description\" rows=\"2\" maxlength=\"${page.albumDescMaxLength}\">${(album.description || '').substring(0, page.albumDescMaxLength)}</textarea>\n </div>\n <p class=\"help\"><b>Markdown supported.</b> Max length is ${page.albumDescMaxLength} characters.</p>\n </div>\n ${album.descriptionHtml\n ? `<div class=\"field\">\n <div class=\"content swal-display-description-preview\">\n ${album.descriptionHtml}\n </div>\n <p class=\"help\">Save changes then re-open this Edit prompt to refresh this preview.</p>\n </div>`\n : ''}\n ${page.currentView === 'albumsAll' && page.permissions.moderator\n ? `<div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalEnabled\" type=\"checkbox\" ${album.enabled ? 'checked' : ''}>\n Enabled\n </label>\n </div>\n </div>`\n : ''}\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalDownload\" type=\"checkbox\" ${album.download ? 'checked' : ''}>\n Enable download\n </label>\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalPublic\" type=\"checkbox\" ${album.public ? 'checked' : ''}>\n Enable public link\n </label>\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalRequestLink\" type=\"checkbox\">\n Request new public link\n </label>\n </div>\n </div>\n <div class=\"field\">\n <p>Current public link: <a href=\"${albumUrl}\" target=\"_blank\" class=\"is-underline\">${albumUrlText}</a></p>\n </div>\n `\n\n swal({\n title: 'Edit album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n const post = {\n id,\n name: document.querySelector('#swalName').value.trim(),\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked,\n requestLink: document.querySelector('#swalRequestLink').checked\n }\n\n if (page.currentView === 'albumsAll' && page.permissions.moderator) {\n post.enabled = document.querySelector('#swalEnabled').checked\n }\n\n axios.post('api/albums/edit', post).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n if (response.data.identifier) {\n swal('Success!', `The album's new identifier is: ${response.data.identifier}.`, 'success')\n } else if (response.data.name !== album.name) {\n swal('Success!', `The album was renamed to: ${response.data.name}.`, 'success')\n } else {\n swal('Success!', 'The album was edited.', 'success', {\n buttons: false,\n timer: 1500\n })\n }\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'This won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads, please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/disable', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Disabled!', 'The album has been disabled.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'You won\\'t be able to recover this album!\\n' +\n 'This also won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, delete it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads, please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Disabled!', 'The album has been deleted.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.submitAlbum = element => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/albums', {\n name: document.querySelector('#albumName').value.trim(),\n description: document.querySelector('#albumDescription').value.trim()\n }).then(response => {\n if (!response) return\n\n page.updateTrigger(element)\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Woohoo!', 'Album was created successfully.', 'success', {\n buttons: false,\n timer: 1500\n })\n page.getAlbumsSidebar()\n page.getAlbums({\n pageNum: -1\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getAlbumsSidebar = () => {\n axios.get('api/albums', { headers: { simple: '1' } }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const albums = response.data.albums\n const count = response.data.count\n const albumsSidebar = document.querySelector('#albumsSidebar')\n\n // Clear albums sidebar if necessary\n const oldAlbums = albumsSidebar.querySelectorAll('li > a')\n const diffCount = oldAlbums.length !== count\n if (oldAlbums.length) {\n for (let i = 0; i < oldAlbums.length; i++) {\n page.menus.splice(page.menus.indexOf(oldAlbums[i]), 1)\n }\n albumsSidebar.innerHTML = ''\n }\n\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapsible.collapsed()\n ? page.albumsSidebarCollapse.dataset.textExpand\n : page.albumsSidebarCollapse.dataset.textCollapse\n\n if (!albums || !albums.length) {\n page.albumsSidebarCollapsible.collapse()\n page.albumsSidebarCollapse.setAttribute('disabled', 'disabled')\n return\n }\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const li = document.createElement('li')\n const a = document.createElement('a')\n a.id = album.id\n a.className = 'is-relative'\n a.innerHTML = album.name\n\n a.addEventListener('click', event => {\n page.getUploads({\n album: parseInt(event.currentTarget.id),\n trigger: event.currentTarget\n })\n })\n page.menus.push(a)\n\n li.appendChild(a)\n albumsSidebar.appendChild(li)\n }\n\n page.albumsSidebarCollapse.removeAttribute('disabled')\n if (!page.albumsSidebarCollapsible.collapsed() && diffCount) {\n // Since it's not possible to refresh collapsible's height with bulmaCollapsible APIs,\n // forcefully collapse albums sidebar if albums count is different with the previous iteration.\n page.albumsSidebarCollapsible.collapse()\n }\n }).catch(page.onAxiosError)\n}\n\npage.changeToken = (params = {}) => {\n page.dom.innerHTML = `\n <div class=\"field\">\n <label class=\"label\">Your current token:</label>\n <div class=\"field\">\n <div class=\"control\">\n <input id=\"token\" readonly class=\"input\" type=\"text\" placeholder=\"Your token\" value=\"${page.token}\">\n </div>\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <a id=\"getNewToken\" class=\"button is-info is-outlined is-fullwidth\">\n <span class=\"icon\">\n <i class=\"icon-arrows-cw\"></i>\n </span>\n <span>Request new token</span>\n </a>\n </div>\n </div>\n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#getNewToken').addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n const trigger = event.currentTarget\n page.updateTrigger(trigger, 'loading')\n axios.post('api/tokens/change').then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n page.updateTrigger(trigger)\n swal({\n title: 'Woohoo!',\n text: 'Your token was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n axios.defaults.headers.common.token = response.data.token\n localStorage[lsKeys.token] = response.data.token\n page.token = response.data.token\n page.changeToken()\n })\n }).catch(error => {\n page.updateTrigger(trigger)\n page.onAxiosError(error)\n })\n })\n}\n\npage.changePassword = (params = {}) => {\n page.dom.innerHTML = `\n <form class=\"prevent-default\">\n <div class=\"field\">\n <label class=\"label\">New password:</label>\n <div class=\"control\">\n <input id=\"password\" class=\"input\" type=\"password\" minlength=\"6\" maxlength=\"64\">\n </div>\n </div>\n <div class=\"field\">\n <label class=\"label\">Re-type new password:</label>\n <div class=\"control\">\n <input id=\"passwordConfirm\" class=\"input\" type=\"password\" minlength=\"6\" maxlength=\"64\">\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <button type=\"submit\" id=\"sendChangePassword\" class=\"button is-info is-outlined is-fullwidth\">\n <span class=\"icon\">\n <i class=\"icon-paper-plane\"></i>\n </span>\n <span>Set new password</span>\n </button>\n </div>\n </div>\n </form>\n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#sendChangePassword').addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (!page.dom.querySelector('form').checkValidity()) return\n\n if (document.querySelector('#password').value === document.querySelector('#passwordConfirm').value) {\n page.sendNewPassword(document.querySelector('#password').value, event.currentTarget)\n } else {\n swal({\n title: 'Password mismatch!',\n text: 'Your passwords do not match, please try again.',\n icon: 'error'\n })\n }\n })\n}\n\npage.sendNewPassword = (pass, element) => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/password/change', { password: pass }).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(element)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n page.updateTrigger(element)\n swal({\n title: 'Woohoo!',\n text: 'Your password was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n page.changePassword()\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getUsers = (params = {}) => {\n if (!page.permissions.admin) return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number') params.pageNum = 0\n\n const url = `api/users/${params.pageNum}`\n axios.get(url).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const usersPerPage = response.data.usersPerPage || 25\n const pages = Math.ceil(response.data.count / usersPerPage)\n const users = response.data.users\n if (params.pageNum && (users.length === 0)) {\n page.updateTrigger(params.trigger)\n if (params.autoPage) {\n params.pageNum = pages - 1\n return page.getUsers(params)\n } else {\n return swal('An error occurred!', `There are no more users to populate page ${params.pageNum + 1}.`, 'error')\n }\n }\n\n page.currentView = 'users'\n page.cache = {}\n\n if (params.pageNum < 0) {\n params.pageNum = Math.max(0, pages + params.pageNum)\n }\n const pagination = page.paginate(response.data.count, usersPerPage, params.pageNum)\n\n const filter = `\n <div class=\"column\">\n <form class=\"prevent-default\">\n <div class=\"field has-addons\">\n <div class=\"control is-expanded\">\n <input id=\"filters\" class=\"input is-small\" type=\"text\" placeholder=\"Filter users (WIP)\" value=\"${page.escape(params.filters || '')}\" disabled>\n </div>\n <div class=\"control\">\n <button type=\"button\" class=\"button is-small is-primary is-outlined\" title=\"Help? (WIP)\" data-action=\"user-filters-help\" disabled>\n <span class=\"icon\">\n <i class=\"icon-help-circled\"></i>\n </span>\n </button>\n </div>\n <div class=\"control\">\n <button type=\"submit\" class=\"button is-small is-info is-outlined\" title=\"Filter users (WIP)\" data-action=\"filter-users\" disabled>\n <span class=\"icon\">\n <i class=\"icon-filter\"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n `\n const extraControls = `\n <div class=\"columns\">\n ${filter}\n <div class=\"column is-one-quarter\">\n <form class=\"prevent-default\">\n <div class=\"field has-addons\">\n <div class=\"control is-expanded\">\n <input id=\"jumpToPage\" class=\"input is-small\" type=\"number\" min=\"1\" max=\"${pages}\" value=\"${params.pageNum + 1}\"${pages === 1 ? ' disabled' : ''}>\n </div>\n <div class=\"control\">\n <button type=\"submit\" class=\"button is-small is-info is-outlined\" title=\"Jump to page\" data-action=\"jump-to-page\">\n <span class=\"icon\">\n <i class=\"icon-paper-plane\"></i>\n </span>\n </button>\n </div>\n </div>\n </form>\n </div>\n </div>\n `\n\n const controls = `\n <div class=\"columns\">\n <div class=\"column exclusive-operations has-text-left\">\n <a class=\"button is-small is-primary is-outlined\" title=\"Create new user\" data-action=\"create-user\">\n <span class=\"icon\">\n <i class=\"icon-plus\"></i>\n </span>\n <span>Create new user</span>\n </a>\n </div>\n <div class=\"column bulk-operations has-text-right\">\n <a class=\"button is-small is-info is-outlined\" title=\"Clear selection\" data-action=\"clear-selection\">\n <span class=\"icon\">\n <i class=\"icon-cancel\"></i>\n </span>\n </a>\n <a class=\"button is-small is-dangerish is-outlined\" title=\"Bulk disable (WIP)\" data-action=\"bulk-disable-users\" disabled>\n <span class=\"icon\">\n <i class=\"icon-hammer\"></i>\n </span>\n </a>\n <a class=\"button is-small is-danger is-outlined\" title=\"Bulk delete (WIP)\" data-action=\"bulk-delete-users\" disabled>\n <span class=\"icon\">\n <i class=\"icon-trash\"></i>\n </span>\n <span>Bulk delete</span>\n </a>\n </div>\n </div>\n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n page.dom.innerHTML = `\n ${pagination}\n ${extraControls}\n ${controls}\n <div class=\"table-container has-text-left\">\n <table class=\"table is-narrow is-fullwidth is-hoverable\">\n <thead>\n <tr>\n <th><input id=\"selectAll\" class=\"checkbox\" type=\"checkbox\" title=\"Select all\" data-action=\"select-all\"></th>\n <th title=\"Key: username\">Username</th>\n <th>Uploads</th>\n <th>Usage</th>\n <th title=\"Key: permission\">Group</th>\n <th title=\"Key: registration\">Registration date</th>\n <th title=\"Key: timestamp\">Last token update</th>\n <th class=\"has-text-right\">(${response.data.count} total)</th>\n </tr>\n </thead>\n <tbody id=\"table\">\n </tbody>\n </table>\n </div>\n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < users.length; i++) {\n const user = users[i]\n const selected = page.selected[page.currentView].includes(user.id)\n if (!selected) {\n unselected = true\n }\n\n let displayGroup = null\n const groups = Object.keys(user.groups)\n for (let i = 0; i < groups.length; i++) {\n if (!user.groups[groups[i]]) break\n displayGroup = groups[i]\n }\n\n // Server-side explicitly expects either of these two values to consider a user as disabled\n const enabled = user.enabled !== false && user.enabled !== 0\n page.cache[user.id] = {\n username: user.username,\n groups: user.groups,\n enabled,\n displayGroup\n }\n\n const prettyDate = user.registration\n ? page.getPrettyDate(new Date(user.registration * 1000))\n : '-'\n const prettyTokenUpdate = user.timestamp\n ? page.getPrettyDate(new Date(user.timestamp * 1000))\n : '-'\n\n const tr = document.createElement('tr')\n tr.dataset.id = user.id\n tr.innerHTML = `\n <td class=\"controls\"><input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${selected ? ' checked' : ''}></td>\n <th${enabled ? '' : ' class=\"has-text-grey\"'}>${user.username}</td>\n <th>${user.uploads}</th>\n <td>${page.getPrettyBytes(user.usage)}</td>\n <td>${displayGroup}</td>\n <td>${prettyDate}</td>\n <td>${prettyTokenUpdate}</td>\n <td class=\"controls has-text-right\">\n <a class=\"button is-small is-primary is-outlined\" title=\"Edit user\" data-action=\"edit-user\">\n <span class=\"icon\">\n <i class=\"icon-pencil\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info is-outlined\" title=\"${user.uploads ? 'View uploads' : 'User doesn\\'t have uploads'}\" data-action=\"view-user-uploads\" ${user.uploads ? '' : 'disabled'}>\n <span class=\"icon\">\n <i class=\"icon-docs\"></i>\n </span>\n </a>\n <a class=\"button is-small is-dangerish is-outlined\" title=\"${enabled ? 'Disable user' : 'User is disabled'}\" data-action=\"disable-user\" ${enabled ? '' : 'disabled'}>\n <span class=\"icon\">\n <i class=\"icon-hammer\"></i>\n </span>\n </a>\n <a class=\"button is-small is-danger is-outlined\" title=\"Delete user\" data-action=\"delete-user\">\n <span class=\"icon\">\n <i class=\"icon-trash\"></i>\n </span>\n </a>\n </td>\n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (users.length && selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = users.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n page.scrollToDom()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.createUser = () => {\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return `<option value=\"${g}\"${disabled ? ' disabled' : ''}>${g}</option>`\n }).join('\\n')\n\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <label class=\"label\">Username</label>\n <div class=\"controls\">\n <input id=\"swalUsername\" class=\"input\" type=\"text\">\n </div>\n </div>\n <div class=\"field\">\n <label class=\"label\">Password (optional)</label>\n <div class=\"controls\">\n <input id=\"swalPassword\" class=\"input\" type=\"text\">\n </div>\n </div>\n <div class=\"field\">\n <label class=\"label\">User group</label>\n <div class=\"control\">\n <div class=\"select is-fullwidth\">\n <select id=\"swalGroup\">\n ${groupOptions}\n </select>\n </div>\n </div>\n </div>\n `\n\n swal({\n title: 'Create new user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/create', {\n username: document.querySelector('#swalUsername').value,\n password: document.querySelector('#swalPassword').value,\n group: document.querySelector('#swalGroup').value\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const div = document.createElement('div')\n div.innerHTML = `\n <p>Username: <b>${response.data.username}</b></p>\n <p>Password: <code>${response.data.password}</code></p>\n <p>User group: <b>${response.data.group}</b></p>\n `\n swal({\n title: 'Created a new user!',\n icon: 'success',\n content: div\n })\n\n // Load last page of users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n pageNum: -1\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.editUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n let isHigher = false\n const groupOptions = Object.keys(page.permissions).map((g, i, a) => {\n const selected = g === user.displayGroup\n if (selected) {\n isHigher = typeof a[i + 1] !== 'undefined' && page.permissions[a[i + 1]]\n }\n const disabled = !(a[i + 1] && page.permissions[a[i + 1]])\n return `<option value=\"${g}\"${selected ? ' selected' : ''}${disabled ? ' disabled' : ''}>${g}</option>`\n }).join('\\n')\n\n const isDisabledHelper = isHigher ? '' : ' disabled'\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <p>User ID: ${id}</p>\n </div>\n <div class=\"field\">\n <label class=\"label\">Username</label>\n <div class=\"controls\">\n <input id=\"swalUsername\" class=\"input\" type=\"text\" value=\"${user.username || ''}\"${isDisabledHelper}>\n </div>\n </div>\n <div class=\"field\">\n <label class=\"label\">User group</label>\n <div class=\"control\">\n <div class=\"select is-fullwidth\">\n <select id=\"swalGroup\"${isDisabledHelper}>\n ${groupOptions}\n </select>\n </div>\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalEnabled\" type=\"checkbox\"${user.enabled ? ' checked' : ''}${isDisabledHelper}>\n Enabled\n </label>\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalResetPassword\" type=\"checkbox\"${isDisabledHelper}>\n Reset password\n </label>\n </div>\n </div>\n ${isHigher\n ? ''\n : `<div class=\"notification is-danger\">\n You <b>cannot</b> modify user in the same or higher group as you.\n </div>`\n }\n `\n\n swal({\n title: 'Edit user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/edit', {\n id,\n username: document.querySelector('#swalUsername').value,\n group: document.querySelector('#swalGroup').value,\n enabled: document.querySelector('#swalEnabled').checked,\n resetPassword: document.querySelector('#swalResetPassword').checked\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n let autoClose = true\n const div = document.createElement('div')\n\n let displayName = user.username\n if (response.data.update.username !== user.username) {\n div.innerHTML += `<p>${user.username} was renamed into: <b>${response.data.update.username}</b>.</p>`\n autoClose = false\n displayName = response.data.update.username\n }\n\n if (response.data.update.password) {\n div.innerHTML += `\n <p>${displayName}'s new password is:</p>\n <p><code>${response.data.update.password}</code></p>\n `\n autoClose = false\n }\n\n if (response.data.update.enabled !== user.enabled) {\n div.innerHTML += `<p>${displayName} has been ${response.data.update.enabled ? 'enabled' : 'disabled'}!</p>`\n }\n\n if (!div.innerHTML) {\n div.innerHTML = `<p>${displayName} was edited!</p>`\n }\n\n swal({\n title: 'Success!',\n icon: 'success',\n content: div,\n buttons: !autoClose,\n timer: autoClose ? 1500 : null\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableUser = id => {\n const user = page.cache[id]\n if (!user || !user.enabled) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n <p>You will be disabling a user named <b>${page.cache[id].username}</b>.</p>\n <p>Their files will remain.</p>\n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable them!',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/disable', { id }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Success!', `${page.cache[id].username} has been disabled.`, 'success', {\n buttons: false,\n timer: 1500\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n <p>You will be deleting a user named <b>${page.cache[id].username}</b>.<p>\n <p>Their uploads will still remain, unless you choose otherwise.</p>\n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, ONLY the user!',\n closeModal: false\n },\n purge: {\n text: 'Yes, AND their uploads too!',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the user's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Success!', `${page.cache[id].username} has been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n\n // Reload users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\n// Roughly based on https://github.com/mayuska/pagination/blob/03cac0fb8af3a759bc1220bd3c011b67dbc5e909/index.js\npage.paginate = (totalItems, itemsPerPage, currentPage) => {\n currentPage = currentPage + 1\n const step = 3\n const numPages = Math.ceil(totalItems / itemsPerPage)\n\n let template = ''\n const elementsToShow = step * 2\n const add = {\n pageNum (start, end) {\n for (let i = start; i <= end; ++i) {\n template += `<li><a class=\"button pagination-link ${i === currentPage ? ' is-current' : ''}\" aria-label=\"Goto page ${i}\" data-action=\"page-goto\" data-goto=\"${i - 1}\">${i}</a></li>`\n }\n },\n startDots () {\n template += `\n <li><a class=\"button pagination-link\" aria-label=\"Goto page 1\" data-action=\"page-goto\" data-goto=\"0\">1</a></li>\n <li data-action=\"page-ellipsis\"><span class=\"pagination-ellipsis\">…</span></li>\n `\n },\n endDots () {\n template += `\n <li data-action=\"page-ellipsis\"><span class=\"pagination-ellipsis\">…</span></li>\n <li><a class=\"button pagination-link\" aria-label=\"Goto page ${numPages}\" data-action=\"page-goto\" data-goto=\"${numPages - 1}\">${numPages}</a></li>\n `\n }\n }\n\n if (elementsToShow + 1 >= numPages) {\n add.pageNum(1, numPages)\n } else if (currentPage < elementsToShow) {\n add.pageNum(1, elementsToShow)\n add.endDots()\n } else if (currentPage > numPages - elementsToShow + 1) {\n add.startDots()\n add.pageNum(numPages - elementsToShow + 1, numPages)\n } else {\n add.startDots()\n add.pageNum(currentPage - step + 1, currentPage + step - 1)\n add.endDots()\n }\n\n return `\n <nav class=\"pagination is-centered is-small\">\n <a class=\"button pagination-previous\" data-action=\"page-prev\"${currentPage === 1 ? ' disabled' : ''}>Previous</a>\n <a class=\"button pagination-next\" data-action=\"page-next\"${currentPage >= numPages ? ' disabled' : ''}>Next page</a>\n <ul class=\"pagination-list\">${template}</ul>\n </nav>\n `\n}\n\npage.getStatistics = (params = {}) => {\n if (!page.permissions.admin) return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n const url = 'api/stats'\n axios.get(url).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n let content = ''\n const keys = Object.keys(response.data.stats)\n for (let i = 0; i < keys.length; i++) {\n let rows = ''\n if (!response.data.stats[keys[i]]) {\n rows += `\n <tr>\n <td>Generating, please try again later\\u2026</td>\n <td></td>\n </tr>\n `\n } else {\n try {\n const valKeys = Object.keys(response.data.stats[keys[i]])\n for (let j = 0; j < valKeys.length; j++) {\n const data = response.data.stats[keys[i]][valKeys[j]]\n const type = typeof data === 'object' ? data.type : 'auto'\n const value = typeof data === 'object' ? data.value : data\n\n let parsed\n switch (type) {\n case 'byte':\n parsed = page.getPrettyBytes(value)\n break\n case 'byteUsage': {\n // Reasoning: https://github.com/sebhildebrandt/systeminformation/issues/464#issuecomment-756406053\n const totalForPercentage = typeof value.available !== 'undefined'\n ? (value.used + value.available)\n : value.total\n parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${(value.used / totalForPercentage * 100).toFixed(2)}%)`\n break\n }\n case 'uptime':\n parsed = page.getPrettyUptime(value)\n break\n case 'auto':\n switch (typeof value) {\n case 'number':\n parsed = value.toLocaleString()\n break\n default:\n parsed = value\n }\n break\n default:\n parsed = value\n }\n\n rows += `\n <tr>\n <th>${valKeys[j]}</th>\n <td>${parsed}</td>\n </tr>\n `\n }\n } catch (error) {\n rows = `\n <tr>\n <td>Error parsing response. Try again?</td>\n <td></td>\n </tr>\n `\n page.onError(error)\n }\n }\n\n content += `\n <div class=\"table-container has-text-left\">\n <table id=\"statistics\" class=\"table is-narrow is-fullwidth is-hoverable\">\n <thead>\n <tr>\n <th class=\"capitalize\">${keys[i]}</th>\n <td></td>\n </tr>\n </thead>\n <tbody>\n ${rows}\n </tbody>\n </table>\n </div>\n `\n }\n\n if (Array.isArray(response.data.hrtime)) {\n content += `\n <article class=\"message is-size-7\">\n <div class=\"message-body has-text-left\">\n Time taken: ${response.data.hrtime[0]}s ${Math.ceil(response.data.hrtime[1] / 1000000)}ms.\n </div>\n </article>\n `\n }\n\n page.dom.innerHTML = content\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n // Polyfill Object.assign()\n // eslint-disable-next-line compat/compat\n if (typeof Object.assign !== 'function') {\n // Must be writable: true, enumerable: false, configurable: true\n Object.defineProperty(Object, 'assign', {\n value: function assign (target, varArgs) { // .length of function is 2\n 'use strict'\n if (target === null || typeof target === 'undefined') {\n throw new TypeError('Cannot convert undefined or null to object')\n }\n const to = Object(target)\n for (let i = 1; i < arguments.length; i++) {\n const nextSource = arguments[i]\n if (nextSource !== null && typeof nextSource !== 'undefined') {\n for (const nextKey in nextSource) {\n // Avoid bugs when hasOwnProperty is shadowed\n if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {\n to[nextKey] = nextSource[nextKey]\n }\n }\n }\n }\n return to\n },\n writable: true,\n configurable: true\n })\n }\n\n // Add 'no-touch' class to non-touch devices\n if (!('ontouchstart' in document.documentElement)) {\n document.documentElement.classList.add('no-touch')\n }\n\n const selectedKeys = ['uploads', 'uploadsAll', 'albums', 'albumsAll', 'users']\n for (let i = 0; i < selectedKeys.length; i++) {\n const ls = localStorage[lsKeys.selected[selectedKeys[i]]]\n if (ls) page.selected[selectedKeys[i]] = JSON.parse(ls)\n }\n\n page.preparePage()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad()\n\n page.albumsSidebarCollapse = document.querySelector('#albumsSidebarCollapse')\n\n /* eslint-disable-next-line new-cap */\n page.albumsSidebarCollapsible = new bulmaCollapsible(document.querySelector('#albumsSidebar'))\n page.albumsSidebarCollapsible.on('before:expand', event => {\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapse.dataset.textCollapse\n })\n page.albumsSidebarCollapsible.on('before:collapse', event => {\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapse.dataset.textExpand\n })\n})\n"]} |