filesafe/dist/js/dashboard.js.map

1 line
154 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"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","document","querySelector","classList","add","remove","error","console","content","createElement","innerHTML","toString","swal","title","icon","statusText","response","status","description","data","verifyToken","window","location","apiVersion","match","src","text","buttons","confirm","closeModal","then","reload","reloadOnError","axios","post","success","removeItem","defaults","headers","common","version","checkClientVersion","prepareDashboard","catch","onAxiosError","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","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","pages","Math","ceil","count","files","autoPage","basedomain","max","pagination","paginate","extraControls","escape","controls","bottomExtraControls","replace","bottomPagination","unselected","showOriginalNames","hasExpiryDateColumn","some","file","expirydate","thumb","extname","toLowerCase","previewable","name","original","prettyBytes","getPrettyBytes","size","prettyDate","getPrettyDate","timestamp","prettyExpiryDate","appendix","userid","albumid","table","upload","div","appendChild","querySelectorAll","allAlbums","tr","ip","checked","fadeInDom","scrollToDom","update","undefined","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","homeDomain","createNewAlbum","albumUrlText","identifier","albumUrl","hasZip","zipSize","prettyZipDate","zipGeneratedAt","isZipExpired","editedAt","enabled","download","public","urlPath","requestLink","purge","albumsSidebar","oldAlbums","diffCount","innerText","collapsed","textExpand","textCollapse","collapse","li","a","sendNewPassword","pass","password","admin","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","onError","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,gBACTC,WAAY,qBAIVM,KAAO,CAEXC,QAAS,KA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iBAAkBnU,SAASoU,iBAC/BpU,SAASoU,gBAAgBlU,UAAUC,IAAI,YAIzC,IADA7C,IAAM+W,EAAe,CAAC,UAAW,aAAc,SAAU,YAAa,SAC7DrQ,EAAI,EAAGA,EAAIqQ,EAAa3P,OAAQV,IAAK,CAC5C1G,IAAMgX,EAAKlW,aAAab,OAAOK,SAASyW,EAAarQ,KACjDsQ,IAAIrW,KAAKL,SAASyW,EAAarQ,IAAM0I,KAAK6H,MAAMD,IAGtDrW,KAAKuW,cAELvW,KAAKoB,YAAc,IAAIoV,YAAY,iBAEnCxW,KAAKoB,YAAYqV,GAAG,WAAS,WAC3B,OAAO/T,KAAK,GAAI,yCAA0C,UAAW,CACnEe,SAAS,EACTsD,MAAO,UAIX/G,KAAKoB,YAAYqV,GAAG,QAASzW,KAAKuV,SAElCvV,KAAKqB,SAAW,IAAIqV,SAEpB1W,KAAKsB,sBAAwBS,SAASC,cAAc,0BAGpDhC,KAAKuB,yBAA2B,IAAIoV,iBAAiB5U,SAASC,cAAc,mBAC5EhC,KAAKuB,yBAAyBkV,GAAG,iBAAe,SAAE5R,GAChD7E,KAAKsB,sBAAsBqR,UAAY3S,KAAKsB,sBAAsBmG,QAAQqL,gBAE5E9S,KAAKuB,yBAAyBkV,GAAG,mBAAiB,SAAE5R,GAClD7E,KAAKsB,sBAAsBqR,UAAY3S,KAAKsB,sBAAsBmG,QAAQoL","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\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 console.error(error)\n\n // Better Cloudflare errors\n const 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 const statusText = 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, true)\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, reloadOnError) => {\n axios.post('api/tokens/verify', { token }).then(response => {\n if (response.data.success === false) {\n return swal({\n title: 'An error occurred!',\n text: response.data.description,\n icon: 'error'\n }).then(() => {\n if (!reloadOnError) return\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n })\n }\n\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(page.onAxiosError)\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 '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 pretend 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 pages = Math.ceil(response.data.count / 25)\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) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, 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 showOriginalNames = page.views[page.currentView].originalNames\n const hasExpiryDateColumn = files.some(file => typeof file.expirydate !== 'undefined')\n\n for (let i = 0; i < files.length; i++) {\n // Build full URLs\n files[i].file = `${basedomain}/${files[i].name}`\n if (files[i].thumb) {\n files[i].thumb = `${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].prettyBytes = page.getPrettyBytes(parseInt(files[i].size))\n files[i].prettyDate = page.getPrettyDate(new Date(files[i].timestamp * 1000))\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) unselected = true\n\n // Appendix (display album or user)\n if (params.all) {\n files[i].appendix = files[i].userid\n ? users[files[i].userid] || ''\n : ''\n } else if (typeof params.album === 'undefined') {\n files[i].appendix = files[i].albumid\n ? albums[files[i].albumid] || ''\n : ''\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 const div = document.createElement('div')\n div.className = 'image-container column'\n div.dataset.id = upload.id\n\n if (typeof upload.thumb !== 'undefined') {\n div.innerHTML = `<a class=\"image\" href=\"${upload.file}\" target=\"_blank\"><img alt=\"${upload.name}\" data-src=\"${upload.thumb}\"/></a>`\n } else {\n div.innerHTML = `<a class=\"image\" href=\"${upload.file}\" target=\"_blank\"><h1 class=\"title\">${upload.extname || 'N/A'}</h1></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 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\">${upload.appendix ? `<span>${upload.appendix}</span> ` : ''}${upload.prettyBytes}</p>\n ${hasExpiryDateColumn && upload.prettyExpiryDate\n ? `<p class=\"prettyexpirydate\">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 const allAlbums = params.all && params.filters && params.filters.includes('albumid:')\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 ${typeof params.album === 'undefined' ? `<th title=\"Key: ${params.all ? 'userid\">User' : 'albumid\">Album'}</th>` : ''}\n ${allAlbums ? '<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 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 ${typeof params.album === 'undefined' ? `<th class=\"appendix\">${upload.appendix}</th>` : ''}\n ${allAlbums ? `<th class=\"album\">${upload.albumid ? (albums[upload.albumid] || '') : ''}</th>` : ''}\n <td class=\"prettybytes\">${upload.prettyBytes}</td>\n ${params.all ? `<td class=\"ip\">${upload.ip || ''}</td>` : ''}\n <td class=\"prettydate\">${upload.prettyDate}</td>\n ${hasExpiryDateColumn ? `<td class=\"prettyexpirydate\">${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 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 (selectAll && !unselected && files.length) {\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\">${file.name}</div>\n <div>${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 pages = Math.ceil(response.data.count / 25)\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\n\n if (params.pageNum < 0) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, 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-trash\"></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) unselected = true\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 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>${page.getPrettyBytes(album.size)}</td>\n <td>${album.prettyDate}</td>\n <td>${album.hasZip ? page.getPrettyBytes(album.zipSize) : '-'}</td>\n <td${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-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 (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\">Max length is ${page.albumDescMaxLength} characters.</p>\n </div>\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!', 'Your 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.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 pages = Math.ceil(response.data.count / 25)\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) params.pageNum = Math.max(0, pages + params.pageNum)\n const pagination = page.paginate(response.data.count, 25, 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) unselected = true\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 (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 <strong>cannot</strong> 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/master/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\">&hellip;</span></li>\n `\n },\n endDots () {\n template += `\n <li data-action=\"page-ellipsis\"><span class=\"pagination-ellipsis\">&hellip;</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"]}