mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
1 line
158 KiB
Plaintext
1 line
158 KiB
Plaintext
{"version":3,"sources":["dashboard.js"],"names":["const","lsKeys","token","viewType","uploads","uploadsAll","selected","albums","albumsAll","users","originalNames","page","section","dom","localStorage","username","permissions","menusContainer","menus","currentView","views","type","album","pageNum","filters","all","prevPageNums","checkboxes","lastSelected","selectAlbumContainer","cache","clipboardJS","lazyLoad","albumsSidebarCollapse","albumsSidebarCollapsible","imageExts","videoExts","audioExts","isSomethingLoading","fadingIn","albumTitleMaxLength","albumDescMaxLength","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","axios","post","defaults","headers","common","version","checkClientVersion","prepareDashboard","catch","code","removeItem","addEventListener","domClick","event","target","contains","preventDefault","itemMenus","selector","onclick","getUploads","deleteUploadsByNames","getAlbums","changeToken","changePassword","logout","params","group","getStatistics","getUsers","loop","i","item","warnSomethingLoading","call","Object","assign","trigger","currentTarget","forceScroll","push","length","moderator","unhide","getAlbumsSidebar","prepareShareX","updateTrigger","timer","newState","parentNode","tagName","className","includes","let","element","parent","parseInt","dataset","id","action","hasAttribute","stopPropagation","getItemID","setUploadsView","toggleOriginalNames","addToAlbum","deleteUpload","addSelectedUploadsToAlbum","bulkDeleteUploads","displayPreview","uploadFiltersHelp","filterUploads","submitAlbum","editAlbum","disableAlbum","deleteAlbum","viewAlbumUploads","createUser","editUser","disableUser","deleteUser","viewUserUploads","getNewToken","clearSelection","select","selectAll","focusJumpToPage","switchPage","disableFading","clearTimeout","setTimeout","disableSmooth","scrollIntoView","behavior","block","inline","view","get","func","getByView","goto","jumpToPage","jumpid","checkValidity","parsed","value","isNaN","focus","url","test","minoffset","Date","getTimezoneOffset","success","pages","Math","ceil","count","files","autoPage","basedomain","max","pagination","paginate","extraControls","escape","controls","bottomExtraControls","replace","bottomPagination","unselected","showOriginalNames","hasExpiryDateColumn","some","file","expirydate","origin","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","onAxiosError","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","descriptionHtml","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,KAETC,IAAK,KAGLX,MAAOY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CACzCxG,IAAM6W,EAAaH,EAAUlQ,GAC7B,GAAIqQ,MAAAA,EACF,IAAK7W,IAAM8W,KAAWD,EAEhBjQ,OAAOuK,UAAUC,eAAezK,KAAKkQ,EAAYC,KACnDF,EAAGE,GAAWD,EAAWC,IAKjC,OAAOF,GAETG,UAAU,EACVC,cAAc,IAKZ,iBAAkBtU,SAASuU,iBAC/BvU,SAASuU,gBAAgBrU,UAAUC,IAAI,YAIzC,IADA7C,IAAMkX,EAAe,CAAC,UAAW,aAAc,SAAU,YAAa,SAC7D1Q,EAAI,EAAGA,EAAI0Q,EAAahQ,OAAQV,IAAK,CAC5CxG,IAAMmX,EAAKrW,aAAab,OAAOK,SAAS4W,EAAa1Q,KACjD2Q,IAAIxW,KAAKL,SAAS4W,EAAa1Q,IAAM8I,KAAK8H,MAAMD,IAGtDxW,KAAK0W,cAEL1W,KAAKoB,YAAc,IAAIuV,YAAY,iBAEnC3W,KAAKoB,YAAYwV,GAAG,WAAS,WAC3B,OAAOlU,KAAK,GAAI,yCAA0C,UAAW,CACnEe,SAAS,EACToD,MAAO,UAIX7G,KAAKoB,YAAYwV,GAAG,QAAS5W,KAAK0V,SAElC1V,KAAKqB,SAAW,IAAIwV,SAEpB7W,KAAKsB,sBAAwBS,SAASC,cAAc,0BAGpDhC,KAAKuB,yBAA2B,IAAIuV,iBAAiB/U,SAASC,cAAc,mBAC5EhC,KAAKuB,yBAAyBqV,GAAG,iBAAe,SAAEjS,GAChD3E,KAAKsB,sBAAsBwR,UAAY9S,KAAKsB,sBAAsBiG,QAAQ0L,gBAE5EjT,KAAKuB,yBAAyBqV,GAAG,mBAAiB,SAAEjS,GAClD3E,KAAKsB,sBAAsBwR,UAAY9S,KAAKsB,sBAAsBiG,QAAQyL","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)\n else window.location = 'auth'\n}\n\npage.checkClientVersion = apiVersion => {\n const self = document.querySelector('#mainScript')\n const match = self.src.match(/\\?_=(\\d+)$/)\n if (match && match[1] && match[1] !== apiVersion) {\n return swal({\n title: 'Update detected!',\n text: 'Client assets have been updated. Reload to display the latest version?',\n icon: 'info',\n buttons: {\n confirm: {\n text: 'Reload',\n closeModal: false\n }\n }\n }).then(() => {\n window.location.reload()\n })\n }\n}\n\npage.verifyToken = token => {\n axios.post('api/tokens/verify', { token }).then(response => {\n axios.defaults.headers.common.token = token\n localStorage[lsKeys.token] = token\n\n if (response.data.version) {\n page.checkClientVersion(response.data.version)\n }\n\n page.token = token\n page.username = response.data.username\n page.permissions = response.data.permissions\n page.prepareDashboard()\n }).catch(error => {\n return swal({\n title: 'An error occurred!',\n text: error.response.data ? error.response.data.description : error.toString(),\n icon: 'error'\n }).then(() => {\n if (error.response.data && error.response.data.code === 10001) {\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n }\n })\n })\n}\n\npage.prepareDashboard = () => {\n page.section = document.querySelector('#dashboard')\n page.dom = page.section.querySelector('#page')\n\n // Capture all click events\n page.dom.addEventListener('click', page.domClick, true)\n\n // Capture all submit events\n page.dom.addEventListener('submit', event => {\n // Prevent default if necessary\n if (event.target && event.target.classList.contains('prevent-default')) {\n return event.preventDefault()\n }\n }, true)\n\n page.menusContainer = document.querySelector('#menu')\n\n // All item menus in the sidebar\n const itemMenus = [\n { selector: '#itemUploads', onclick: page.getUploads },\n { selector: '#itemDeleteUploadsByNames', onclick: page.deleteUploadsByNames },\n { selector: '#itemManageYourAlbums', onclick: page.getAlbums },\n { selector: '#itemManageToken', onclick: page.changeToken },\n { selector: '#itemChangePassword', onclick: page.changePassword },\n { selector: '#itemLogout', onclick: page.logout },\n { selector: '#itemManageUploads', onclick: page.getUploads, params: { all: true }, group: 'moderator' },\n { selector: '#itemManageAlbums', onclick: page.getAlbums, params: { all: true }, group: 'moderator' },\n { selector: '#itemStatistics', onclick: page.getStatistics, group: 'admin' },\n { selector: '#itemManageUsers', onclick: page.getUsers, group: 'admin' }\n ]\n\n for (let i = 0; i < itemMenus.length; i++) {\n // Skip item menu if not enough permission\n if (itemMenus[i].group && !page.permissions[itemMenus[i].group]) continue\n\n // Add onclick event listener\n const item = document.querySelector(itemMenus[i].selector)\n item.addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n itemMenus[i].onclick.call(null, Object.assign(itemMenus[i].params || {}, {\n trigger: event.currentTarget,\n forceScroll: true\n }))\n })\n\n item.classList.remove('is-hidden')\n page.menus.push(item)\n }\n\n // If at least a moderator, show administration section\n if (page.permissions.moderator) {\n document.querySelector('#itemLabelAdmin').classList.remove('is-hidden')\n document.querySelector('#itemListAdmin').classList.remove('is-hidden')\n }\n\n // Update text of logout button\n document.querySelector('#itemLogout').innerHTML = `Logout ( ${page.username} )`\n\n // Finally display dashboard\n page.unhide()\n\n // Load albums sidebar\n page.getAlbumsSidebar()\n\n if (typeof page.prepareShareX === 'function') page.prepareShareX()\n}\n\npage.logout = params => {\n page.updateTrigger(params.trigger, 'active')\n localStorage.removeItem(lsKeys.token)\n window.location = 'auth'\n}\n\npage.warnSomethingLoading = () => {\n swal('Please wait!', 'Something else is still loading\\u2026', 'warning', {\n buttons: false,\n timer: 3000\n })\n}\n\npage.updateTrigger = (trigger, newState) => {\n if (!trigger) return\n\n // Disable menus container and pagination when loading\n if (newState === 'loading') {\n page.isSomethingLoading = true\n page.section.classList.add('is-loading')\n } else {\n page.section.classList.remove('is-loading')\n page.isSomethingLoading = false\n }\n\n if (newState === 'loading') {\n trigger.classList.add('is-loading')\n } else if (newState === 'active') {\n if (trigger.parentNode.tagName === 'LI' && !trigger.className.includes('pagination-link')) {\n for (let i = 0; i < page.menus.length; i++) {\n page.menus[i].classList.remove('is-active')\n }\n trigger.classList.add('is-active')\n }\n trigger.classList.remove('is-loading')\n } else {\n trigger.classList.remove('is-loading')\n trigger.classList.remove('is-active')\n }\n}\n\npage.getItemID = element => {\n // This expects the item's parent to have the item's ID\n let parent = element.parentNode\n // If the element is part of a set of controls, use the container's parent instead\n if (element.parentNode.classList.contains('controls')) parent = parent.parentNode\n return parseInt(parent.dataset.id)\n}\n\npage.domClick = event => {\n // We are processing clicks this way to avoid using \"onclick\" attribute\n // Apparently we will need to use \"unsafe-inline\" for \"script-src\" directive\n // of Content Security Policy (CSP), if we want to use \"onclick\" attribute\n // Though I think that only applies to some browsers (?)\n // Of course it wouldn't have mattered if we didn't use CSP to begin with\n // Anyway, I personally would rather not use \"onclick\" attribute\n let element = event.target\n if (!element) return\n\n // Delegate click events to their A or BUTTON parents\n if (['I'].includes(element.tagName) && ['SPAN'].includes(element.parentNode.tagName)) {\n element = element.parentNode\n }\n if (['SPAN'].includes(element.tagName) && ['A', 'BUTTON'].includes(element.parentNode.tagName)) {\n element = element.parentNode\n }\n\n // Skip elements that have no action data\n if (!element.dataset || !element.dataset.action) return\n\n // Skip disabled elements\n if (element.hasAttribute('disabled')) return\n\n event.stopPropagation() // maybe necessary\n const id = page.getItemID(element)\n const action = element.dataset.action\n\n switch (action) {\n // Uploads\n case 'view-list':\n return page.setUploadsView('list', element)\n case 'view-thumbs':\n return page.setUploadsView('thumbs', element)\n case 'toggle-original-names':\n return page.toggleOriginalNames(element)\n case 'add-to-album':\n return page.addToAlbum(id)\n case 'delete-upload':\n return page.deleteUpload(id)\n case 'add-selected-uploads-to-album':\n return page.addSelectedUploadsToAlbum()\n case 'bulk-delete-uploads':\n return page.bulkDeleteUploads()\n case 'display-preview':\n return page.displayPreview(id)\n // Manage uploads\n case 'upload-filters-help':\n return page.uploadFiltersHelp(element)\n case 'filter-uploads':\n return page.filterUploads(element)\n // Manage your albums\n case 'submit-album':\n return page.submitAlbum(element)\n case 'edit-album':\n return page.editAlbum(id)\n case 'disable-album':\n return page.disableAlbum(id)\n case 'delete-album':\n return page.deleteAlbum(id)\n case 'view-album-uploads':\n return page.viewAlbumUploads(id, element)\n // Manage users\n case 'create-user':\n return page.createUser()\n case 'edit-user':\n return page.editUser(id)\n case 'disable-user':\n return page.disableUser(id)\n case 'delete-user':\n return page.deleteUser(id)\n case 'view-user-uploads':\n return page.viewUserUploads(id, element)\n // Others\n case 'get-new-token':\n return page.getNewToken(element)\n // Uploads & Users\n case 'clear-selection':\n return page.clearSelection()\n case 'select':\n return page.select(element, event)\n case 'select-all':\n return page.selectAll(element)\n case 'page-ellipsis':\n return page.focusJumpToPage(element)\n case 'page-prev':\n case 'page-next':\n case 'page-goto':\n case 'jump-to-page':\n return page.switchPage(action, element)\n }\n}\n\npage.fadeInDom = disableFading => {\n if (page.fadingIn) {\n clearTimeout(page.fadingIn)\n page.dom.classList.remove('fade-in')\n }\n\n if (!disableFading) {\n page.dom.classList.add('fade-in')\n page.fadingIn = setTimeout(() => {\n page.dom.classList.remove('fade-in')\n }, 500)\n }\n}\n\npage.scrollToDom = disableSmooth => {\n page.dom.scrollIntoView({\n behavior: disableSmooth ? 'auto' : 'smooth',\n block: 'start',\n inline: 'nearest'\n })\n}\n\npage.getByView = (view, get) => {\n switch (view) {\n case 'uploads':\n case 'uploadsAll':\n return {\n type: 'uploads',\n func: page.getUploads\n }[get]\n case 'albums':\n case 'albumsAll':\n return {\n type: 'albums',\n func: page.getAlbums\n }[get]\n case 'users':\n return {\n type: 'users',\n func: page.getUsers\n }[get]\n default:\n return null\n }\n}\n\npage.switchPage = (action, element) => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n // eslint-disable-next-line compat/compat\n const params = Object.assign(page.views[page.currentView], {\n trigger: element\n })\n\n const func = page.getByView(page.currentView, 'func')\n\n switch (action) {\n case 'page-prev':\n params.pageNum = page.views[page.currentView].pageNum - 1\n if (params.pageNum < 0) {\n return swal('An error occurred!', 'This is already the first page.', 'error')\n }\n return func(params)\n case 'page-next':\n params.pageNum = page.views[page.currentView].pageNum + 1\n return func(params)\n case 'page-goto':\n params.pageNum = parseInt(element.dataset.goto)\n return func(params)\n case 'jump-to-page': {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage.checkValidity()) return\n const parsed = parseInt(jumpToPage.value)\n params.pageNum = isNaN(parsed) ? 0 : (parsed - 1)\n if (params.pageNum < 0) params.pageNum = 0\n return func(params)\n }\n }\n}\n\npage.focusJumpToPage = element => {\n const jumpToPage = document.querySelector(`#${element.dataset.jumpid || 'jumpToPage'}`)\n if (!jumpToPage) return\n jumpToPage.focus()\n jumpToPage.select()\n}\n\npage.getUploads = (params = {}) => {\n if (params && params.all && !page.permissions.moderator) {\n return swal('An error occurred!', 'You cannot do this!', 'error')\n }\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number' || params.pageNum < 0) {\n params.pageNum = 0\n }\n\n const url = typeof params.album !== 'undefined'\n ? `api/album/${params.album}/${params.pageNum}`\n : `api/uploads/${params.pageNum}`\n\n const headers = {}\n if (params.all) headers.all = '1'\n if (params.filters) {\n headers.filters = params.filters\n // Send client timezone offset if properly using date: and/or :expiry filters\n // Server will 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 || window.location.origin}/${files[i].name}`\n if (files[i].thumb) {\n files[i].thumb = `${basedomain ? `${basedomain}/` : ''}${files[i].thumb}`\n }\n\n // Determine types\n const extname = files[i].extname.toLowerCase()\n if (page.imageExts.includes(extname)) {\n files[i].type = 'picture'\n } else if (page.videoExts.includes(extname)) {\n files[i].type = 'video'\n } else if (page.audioExts.includes(extname)) {\n files[i].type = 'audio'\n } else {\n files[i].type = 'other'\n }\n\n files[i].previewable = files[i].thumb || files[i].type === 'audio'\n\n // Cache bare minimum data for thumbnails viewer\n page.cache[files[i].id] = {\n name: files[i].name,\n original: files[i].original,\n extname: files[i].extname,\n thumb: files[i].thumb,\n file: files[i].file,\n type: files[i].type,\n previewable: files[i].previewable\n }\n\n // Prettify\n files[i].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\" data-bytes=\"${upload.size}\">${upload.appendix ? `<span>${upload.appendix}</span> – ` : ''}${upload.prettyBytes}</p>\n ${hasExpiryDateColumn && upload.prettyExpiryDate\n ? `<p class=\"prettyexpirydate\"${upload.expirydate ? ` data-timestamp=\"${upload.expirydate}\"` : ''}>EXP: ${upload.prettyExpiryDate}</p>`\n : ''}\n </div>\n `\n\n table.appendChild(div)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n } else {\n 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\" data-bytes=\"${upload.size}\">${upload.prettyBytes}</td>\n ${params.all ? `<td class=\"ip\">${upload.ip || ''}</td>` : ''}\n <td class=\"prettydate\" data-timestamp=\"${upload.timestamp}\">${upload.prettyDate}</td>\n ${hasExpiryDateColumn ? `<td class=\"prettyexpirydate\"${upload.expirydate ? ` data-timestamp=\"${upload.expirydate}\"` : ''}>${upload.prettyExpiryDate || '-'}</td>` : ''}\n <td class=\"controls has-text-right\">\n <a class=\"button is-small is-primary is-outlined\" title=\"${upload.previewable ? 'Display preview' : 'File can\\'t be previewed'}\" data-action=\"display-preview\"${upload.previewable ? '' : ' disabled'}>\n <span class=\"icon\">\n <i class=\"${upload.type !== 'other' ? `icon-${upload.type}` : 'icon-doc-inv'}\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info is-outlined 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 || window.location.origin\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-cancel\"></i>\n </span>\n ${!params.all ? '<span>Bulk disable</span>' : ''}\n </a>\n ${params.all\n ? `<a class=\"button is-small is-danger is-outlined\" title=\"Bulk delete (WIP)\" data-action=\"bulk-delete-albums\" disabled>\n <span class=\"icon\">\n <i class=\"icon-trash\"></i>\n </span>\n <span>Bulk delete</span>\n </a>`\n : ''}\n </div>\n </div>\n `\n\n // Do some string replacements for bottom controls\n const bottomFiltersId = 'bFilters'\n const bottomJumpId = 'bJumpToPage'\n const bottomExtraControls = extraControls\n .replace(/id=\"filters\"/, `id=\"${bottomFiltersId}\"`)\n .replace(/(data-action=\"filter-uploads\")/, `$1 data-filtersid=\"${bottomFiltersId}\"`)\n .replace(/id=\"jumpToPage\"/, `id=\"${bottomJumpId}\"`)\n .replace(/(data-action=\"jump-to-page\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n const bottomPagination = pagination\n .replace(/(data-action=\"page-ellipsis\")/g, `$1 data-jumpid=\"${bottomJumpId}\"`)\n\n // Whether there are any unselected items\n let unselected = false\n\n const createNewAlbum = `\n <h2 class=\"subtitle\">Create new album</h2>\n <form class=\"prevent-default\">\n <div class=\"field\">\n <div class=\"control\">\n <input id=\"albumName\" class=\"input\" type=\"text\" placeholder=\"Name\" maxlength=\"${page.albumTitleMaxLength}\">\n </div>\n <p class=\"help\">Max length is ${page.albumTitleMaxLength} characters.</p>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <textarea id=\"albumDescription\" class=\"textarea\" placeholder=\"Description\" rows=\"1\" maxlength=\"${page.albumDescMaxLength}\"></textarea>\n </div>\n <p class=\"help\">Max length is ${page.albumDescMaxLength} characters.</p>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <button type=\"submit\" id=\"submitAlbum\" class=\"button is-info is-outlined is-fullwidth\" data-action=\"submit-album\">\n <span class=\"icon\">\n <i class=\"icon-paper-plane\"></i>\n </span>\n <span>Create</span>\n </button>\n </div>\n </div>\n </form>\n <hr>\n `\n\n page.dom.innerHTML = `\n ${!params.all ? createNewAlbum : ''}\n ${pagination}\n ${extraControls}\n ${controls}\n <div class=\"table-container has-text-left\">\n <table class=\"table is-narrow is-fullwidth is-hoverable\">\n <thead>\n <tr>\n <th><input id=\"selectAll\" class=\"checkbox\" type=\"checkbox\" title=\"Select all\" data-action=\"select-all\"></th>\n <th>ID</th>\n <th>Name</th>\n ${params.all ? '<th>User</th>' : ''}\n <th>Uploads</th>\n <th>Size</th>\n <th>Created at</th>\n <th>ZIP size</th>\n <th>ZIP generated at</th>\n <th>Public link</th>\n <th class=\"has-text-right\">(${response.data.count} total)</th>\n </tr>\n </thead>\n <tbody id=\"table\">\n </tbody>\n </table>\n </div>\n ${controls}\n ${bottomExtraControls}\n ${bottomPagination}\n `\n\n const table = document.querySelector('#table')\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const urlPath = '/a/'\n const albumUrlText = urlPath + album.identifier\n const albumUrl = homeDomain + albumUrlText\n\n const selected = page.selected[page.currentView].includes(album.id)\n if (!selected) 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 descriptionHtml: album.descriptionHtml,\n enabled,\n homeDomain,\n urlPath,\n identifier: album.identifier\n }\n\n const tr = document.createElement('tr')\n tr.dataset.id = album.id\n tr.innerHTML = `\n <td class=\"controls\"><input type=\"checkbox\" class=\"checkbox\" title=\"Select\" data-index=\"${i}\" data-action=\"select\"${selected ? ' checked' : ''}></td>\n <th>${album.id}</th>\n <th${enabled ? '' : ' class=\"has-text-grey\"'}>${album.name}</td>\n ${params.all ? `<th>${album.userid ? (users[album.userid] || '') : ''}</th>` : ''}\n <th>${album.uploads}</th>\n <td data-bytes=\"${album.size}\">${page.getPrettyBytes(album.size)}</td>\n <td data-timestamp=\"${album.timestamp}\">${album.prettyDate}</td>\n <td${album.hasZip ? ` data-bytes=\"${album.zipSize}\"` : ''}>${album.hasZip ? page.getPrettyBytes(album.zipSize) : '-'}</td>\n <td${album.hasZip ? ` data-timestamp=\"${album.zipGeneratedAt}\"` : ''}${album.isZipExpired ? ' class=\"has-text-warning\" title=\"This album has been modified since the last time its ZIP was generated.\"' : ''}>${album.hasZip ? album.prettyZipDate : '-'}</td$>\n <td><a ${enabled && album.public ? '' : 'class=\"is-linethrough\" '}href=\"${albumUrl}\" target=\"_blank\">${albumUrlText}</a></td>\n <td class=\"has-text-right\" data-id=\"${album.id}\">\n <a class=\"button is-small is-primary is-outlined\" title=\"Edit album\" data-action=\"edit-album\">\n <span class=\"icon is-small\">\n <i class=\"icon-pencil\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info is-outlined\" title=\"${album.uploads ? 'View uploads' : 'Album doesn\\'t have uploads'}\" data-action=\"view-album-uploads\" ${album.uploads ? '' : 'disabled'}>\n <span class=\"icon\">\n <i class=\"icon-docs\"></i>\n </span>\n </a>\n <a class=\"button is-small is-info is-outlined clipboard-js\" title=\"Copy link to clipboard\" ${album.public ? `data-clipboard-text=\"${albumUrl}\"` : 'disabled'}>\n <span class=\"icon is-small\">\n <i class=\"icon-clipboard\"></i>\n </span>\n </a>\n <a class=\"button is-small is-warning is-outlined\" title=\"Download album\" ${enabled && album.download ? `href=\"api/album/zip/${album.identifier}?v=${album.editedAt}\"` : 'disabled'}>\n <span class=\"icon is-small\">\n <i class=\"icon-download\"></i>\n </span>\n </a>\n <a class=\"button is-small is-dangerish is-outlined\" title=\"Disable album\" data-action=\"disable-album\"${enabled ? '' : ' disabled'}>\n <span class=\"icon is-small\">\n <i class=\"icon-cancel\"></i>\n </span>\n </a>\n ${params.all\n ? `<a class=\"button is-small is-danger is-outlined\" title=\"Delete album\" data-action=\"delete-album\">\n <span class=\"icon is-small\">\n <i class=\"icon-trash\"></i>\n </span>\n </a>`\n : ''}\n </td>\n `\n\n table.appendChild(tr)\n page.checkboxes = table.querySelectorAll('.checkbox[data-action=\"select\"]')\n }\n\n const selectAll = document.querySelector('#selectAll')\n if (selectAll && !unselected) {\n selectAll.checked = true\n selectAll.title = 'Unselect all'\n }\n\n page.fadeInDom()\n\n const pageNum = albums.length ? params.pageNum : 0\n if (params.forceScroll ||\n page.prevPageNums[page.currentView] === null ||\n page.prevPageNums[page.currentView] !== pageNum) {\n page.scrollToDom()\n }\n\n page.updateTrigger(params.trigger, 'active')\n\n if (page.currentView === 'albumsAll') {\n page.views[page.currentView].filters = params.filters\n }\n page.views[page.currentView].pageNum = page.prevPageNums[page.currentView] = pageNum\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\npage.editAlbum = id => {\n const album = page.cache[id]\n if (!album) return\n\n const albumUrlText = album.urlPath + album.identifier\n const albumUrl = album.homeDomain + albumUrlText\n\n const div = document.createElement('div')\n div.innerHTML = `\n <div class=\"field\">\n <div class=\"controls\">\n <input id=\"swalName\" class=\"input\" type=\"text\" placeholder=\"Name\" maxlength=\"${page.albumTitleMaxLength}\" value=\"${(album.name || '').substring(0, page.albumTitleMaxLength)}\">\n </div>\n <p class=\"help\">Max length is ${page.albumTitleMaxLength} characters.</p>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <textarea id=\"swalDescription\" class=\"textarea\" placeholder=\"Description\" rows=\"2\" maxlength=\"${page.albumDescMaxLength}\">${(album.description || '').substring(0, page.albumDescMaxLength)}</textarea>\n </div>\n <p class=\"help\"><b>Markdown supported.</b> Max length is ${page.albumDescMaxLength} characters.</p>\n </div>\n ${album.descriptionHtml\n ? `<div class=\"field\">\n <div class=\"content swal-display-description-preview\">\n ${album.descriptionHtml}\n </div>\n <p class=\"help\">Save changes then re-open this Edit prompt to refresh this preview.</p>\n </div>`\n : ''}\n ${page.currentView === 'albumsAll' && page.permissions.moderator\n ? `<div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalEnabled\" type=\"checkbox\" ${album.enabled ? 'checked' : ''}>\n Enabled\n </label>\n </div>\n </div>`\n : ''}\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalDownload\" type=\"checkbox\" ${album.download ? 'checked' : ''}>\n Enable download\n </label>\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalPublic\" type=\"checkbox\" ${album.public ? 'checked' : ''}>\n Enable public link\n </label>\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <label class=\"checkbox\">\n <input id=\"swalRequestLink\" type=\"checkbox\">\n Request new public link\n </label>\n </div>\n </div>\n <div class=\"field\">\n <p>Current public link: <a href=\"${albumUrl}\" target=\"_blank\" class=\"is-underline\">${albumUrlText}</a></p>\n </div>\n `\n\n swal({\n title: 'Edit album',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(value => {\n if (!value) return\n\n const post = {\n id,\n name: document.querySelector('#swalName').value.trim(),\n description: document.querySelector('#swalDescription').value.trim(),\n download: document.querySelector('#swalDownload').checked,\n public: document.querySelector('#swalPublic').checked,\n requestLink: document.querySelector('#swalRequestLink').checked\n }\n\n if (page.currentView === 'albumsAll' && page.permissions.moderator) {\n post.enabled = document.querySelector('#swalEnabled').checked\n }\n\n axios.post('api/albums/edit', post).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n if (response.data.identifier) {\n swal('Success!', `The album's new identifier is: ${response.data.identifier}.`, 'success')\n } else if (response.data.name !== album.name) {\n swal('Success!', `The album was renamed to: ${response.data.name}.`, 'success')\n } else {\n swal('Success!', 'The album was edited.', 'success', {\n buttons: false,\n timer: 1500\n })\n }\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'This won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads, please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/disable', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Disabled!', 'The album has been disabled.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteAlbum = id => {\n swal({\n title: 'Are you sure?',\n text: 'You won\\'t be able to recover this album!\\n' +\n 'This also won\\'t delete the uploads associated with the album!',\n icon: 'warning',\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, delete it!',\n closeModal: false\n },\n purge: {\n text: 'Umm, delete the uploads, please?',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/albums/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the album's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Disabled!', 'The album has been deleted.', 'success', {\n buttons: false,\n timer: 1500\n })\n\n page.getAlbumsSidebar()\n // Reload albums list\n // eslint-disable-next-line compat/compat\n page.getAlbums(Object.assign(page.views[page.currentView], {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\npage.submitAlbum = element => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/albums', {\n name: document.querySelector('#albumName').value.trim(),\n description: document.querySelector('#albumDescription').value.trim()\n }).then(response => {\n if (!response) return\n\n page.updateTrigger(element)\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Woohoo!', 'Album was created successfully.', 'success', {\n buttons: false,\n timer: 1500\n })\n page.getAlbumsSidebar()\n page.getAlbums({\n pageNum: -1\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getAlbumsSidebar = () => {\n axios.get('api/albums', { headers: { simple: '1' } }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const albums = response.data.albums\n const count = response.data.count\n const albumsSidebar = document.querySelector('#albumsSidebar')\n\n // Clear albums sidebar if necessary\n const oldAlbums = albumsSidebar.querySelectorAll('li > a')\n const diffCount = oldAlbums.length !== count\n if (oldAlbums.length) {\n for (let i = 0; i < oldAlbums.length; i++) {\n page.menus.splice(page.menus.indexOf(oldAlbums[i]), 1)\n }\n albumsSidebar.innerHTML = ''\n }\n\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapsible.collapsed()\n ? page.albumsSidebarCollapse.dataset.textExpand\n : page.albumsSidebarCollapse.dataset.textCollapse\n\n if (!albums || !albums.length) {\n page.albumsSidebarCollapsible.collapse()\n page.albumsSidebarCollapse.setAttribute('disabled', 'disabled')\n return\n }\n\n for (let i = 0; i < albums.length; i++) {\n const album = albums[i]\n const li = document.createElement('li')\n const a = document.createElement('a')\n a.id = album.id\n a.className = 'is-relative'\n a.innerHTML = album.name\n\n a.addEventListener('click', event => {\n page.getUploads({\n album: parseInt(event.currentTarget.id),\n trigger: event.currentTarget\n })\n })\n page.menus.push(a)\n\n li.appendChild(a)\n albumsSidebar.appendChild(li)\n }\n\n page.albumsSidebarCollapse.removeAttribute('disabled')\n if (!page.albumsSidebarCollapsible.collapsed() && diffCount) {\n // Since it's not possible to refresh collapsible's height with bulmaCollapsible APIs,\n // forcefully collapse albums sidebar if albums count is different with the previous iteration.\n page.albumsSidebarCollapsible.collapse()\n }\n }).catch(page.onAxiosError)\n}\n\npage.changeToken = (params = {}) => {\n page.dom.innerHTML = `\n <div class=\"field\">\n <label class=\"label\">Your current token:</label>\n <div class=\"field\">\n <div class=\"control\">\n <input id=\"token\" readonly class=\"input\" type=\"text\" placeholder=\"Your token\" value=\"${page.token}\">\n </div>\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <a id=\"getNewToken\" class=\"button is-info is-outlined is-fullwidth\">\n <span class=\"icon\">\n <i class=\"icon-arrows-cw\"></i>\n </span>\n <span>Request new token</span>\n </a>\n </div>\n </div>\n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#getNewToken').addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n const trigger = event.currentTarget\n page.updateTrigger(trigger, 'loading')\n axios.post('api/tokens/change').then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n page.updateTrigger(trigger)\n swal({\n title: 'Woohoo!',\n text: 'Your token was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n axios.defaults.headers.common.token = response.data.token\n localStorage[lsKeys.token] = response.data.token\n page.token = response.data.token\n page.changeToken()\n })\n }).catch(error => {\n page.updateTrigger(trigger)\n page.onAxiosError(error)\n })\n })\n}\n\npage.changePassword = (params = {}) => {\n page.dom.innerHTML = `\n <form class=\"prevent-default\">\n <div class=\"field\">\n <label class=\"label\">New password:</label>\n <div class=\"control\">\n <input id=\"password\" class=\"input\" type=\"password\" minlength=\"6\" maxlength=\"64\">\n </div>\n </div>\n <div class=\"field\">\n <label class=\"label\">Re-type new password:</label>\n <div class=\"control\">\n <input id=\"passwordConfirm\" class=\"input\" type=\"password\" minlength=\"6\" maxlength=\"64\">\n </div>\n </div>\n <div class=\"field\">\n <div class=\"control\">\n <button type=\"submit\" id=\"sendChangePassword\" class=\"button is-info is-outlined is-fullwidth\">\n <span class=\"icon\">\n <i class=\"icon-paper-plane\"></i>\n </span>\n <span>Set new password</span>\n </button>\n </div>\n </div>\n </form>\n `\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n\n document.querySelector('#sendChangePassword').addEventListener('click', event => {\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n if (!page.dom.querySelector('form').checkValidity()) return\n\n if (document.querySelector('#password').value === document.querySelector('#passwordConfirm').value) {\n page.sendNewPassword(document.querySelector('#password').value, event.currentTarget)\n } else {\n swal({\n title: 'Password mismatch!',\n text: 'Your passwords do not match, please try again.',\n icon: 'error'\n })\n }\n })\n}\n\npage.sendNewPassword = (pass, element) => {\n page.updateTrigger(element, 'loading')\n\n axios.post('api/password/change', { password: pass }).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(element)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n page.updateTrigger(element)\n swal({\n title: 'Woohoo!',\n text: 'Your password was successfully changed.',\n icon: 'success',\n buttons: false,\n timer: 1500\n }).then(() => {\n page.changePassword()\n })\n }).catch(error => {\n page.updateTrigger(element)\n page.onAxiosError(error)\n })\n}\n\npage.getUsers = (params = {}) => {\n if (!page.permissions.admin) return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n if (typeof params.pageNum !== 'number') params.pageNum = 0\n\n const url = `api/users/${params.pageNum}`\n axios.get(url).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n const 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 <b>cannot</b> modify user in the same or higher group as you.\n </div>`\n }\n `\n\n swal({\n title: 'Edit user',\n icon: 'info',\n content: div,\n buttons: {\n cancel: true,\n confirm: {\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/edit', {\n id,\n username: document.querySelector('#swalUsername').value,\n group: document.querySelector('#swalGroup').value,\n enabled: document.querySelector('#swalEnabled').checked,\n resetPassword: document.querySelector('#swalResetPassword').checked\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n let autoClose = true\n const div = document.createElement('div')\n\n let displayName = user.username\n if (response.data.update.username !== user.username) {\n div.innerHTML += `<p>${user.username} was renamed into: <b>${response.data.update.username}</b>.</p>`\n autoClose = false\n displayName = response.data.update.username\n }\n\n if (response.data.update.password) {\n div.innerHTML += `\n <p>${displayName}'s new password is:</p>\n <p><code>${response.data.update.password}</code></p>\n `\n autoClose = false\n }\n\n if (response.data.update.enabled !== user.enabled) {\n div.innerHTML += `<p>${displayName} has been ${response.data.update.enabled ? 'enabled' : 'disabled'}!</p>`\n }\n\n if (!div.innerHTML) {\n div.innerHTML = `<p>${displayName} was edited!</p>`\n }\n\n swal({\n title: 'Success!',\n icon: 'success',\n content: div,\n buttons: !autoClose,\n timer: autoClose ? 1500 : null\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.disableUser = id => {\n const user = page.cache[id]\n if (!user || !user.enabled) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n <p>You will be disabling a user named <b>${page.cache[id].username}</b>.</p>\n <p>Their files will remain.</p>\n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, disable them!',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/disable', { id }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Success!', `${page.cache[id].username} has been disabled.`, 'success', {\n buttons: false,\n timer: 1500\n })\n page.getUsers(page.views.users)\n }).catch(page.onAxiosError)\n })\n}\n\npage.deleteUser = id => {\n const user = page.cache[id]\n if (!user) return\n\n const content = document.createElement('div')\n content.innerHTML = `\n <p>You will be deleting a user named <b>${page.cache[id].username}</b>.<p>\n <p>Their uploads will still remain, unless you choose otherwise.</p>\n `\n\n swal({\n title: 'Are you sure?',\n icon: 'warning',\n content,\n dangerMode: true,\n buttons: {\n cancel: true,\n confirm: {\n text: 'Yes, ONLY the user!',\n closeModal: false\n },\n purge: {\n text: 'Yes, AND their uploads too!',\n value: 'purge',\n className: 'swal-button--danger',\n closeModal: false\n }\n }\n }).then(proceed => {\n if (!proceed) return\n\n axios.post('api/users/delete', {\n id,\n purge: proceed === 'purge'\n }).then(response => {\n if (!response) return\n\n if (response.data.success === false) {\n const failed = Array.isArray(response.data.failed)\n ? response.data.failed\n : []\n\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else if (failed.length) {\n return swal('An error occurred!', `Unable to delete ${failed.length} of the user's upload${failed.length === 1 ? '' : 's'}.`, 'error')\n } else {\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n swal('Success!', `${page.cache[id].username} has been deleted.`, 'success', {\n buttons: false,\n timer: 1500\n })\n\n // Reload users list\n // eslint-disable-next-line compat/compat\n page.getUsers(Object.assign(page.views.users, {\n autoPage: true\n }))\n }).catch(page.onAxiosError)\n })\n}\n\n// Roughly based on https://github.com/mayuska/pagination/blob/03cac0fb8af3a759bc1220bd3c011b67dbc5e909/index.js\npage.paginate = (totalItems, itemsPerPage, currentPage) => {\n currentPage = currentPage + 1\n const step = 3\n const numPages = Math.ceil(totalItems / itemsPerPage)\n\n let template = ''\n const elementsToShow = step * 2\n const add = {\n pageNum (start, end) {\n for (let i = start; i <= end; ++i) {\n template += `<li><a class=\"button pagination-link ${i === currentPage ? ' is-current' : ''}\" aria-label=\"Goto page ${i}\" data-action=\"page-goto\" data-goto=\"${i - 1}\">${i}</a></li>`\n }\n },\n startDots () {\n template += `\n <li><a class=\"button pagination-link\" aria-label=\"Goto page 1\" data-action=\"page-goto\" data-goto=\"0\">1</a></li>\n <li data-action=\"page-ellipsis\"><span class=\"pagination-ellipsis\">…</span></li>\n `\n },\n endDots () {\n template += `\n <li data-action=\"page-ellipsis\"><span class=\"pagination-ellipsis\">…</span></li>\n <li><a class=\"button pagination-link\" aria-label=\"Goto page ${numPages}\" data-action=\"page-goto\" data-goto=\"${numPages - 1}\">${numPages}</a></li>\n `\n }\n }\n\n if (elementsToShow + 1 >= numPages) {\n add.pageNum(1, numPages)\n } else if (currentPage < elementsToShow) {\n add.pageNum(1, elementsToShow)\n add.endDots()\n } else if (currentPage > numPages - elementsToShow + 1) {\n add.startDots()\n add.pageNum(numPages - elementsToShow + 1, numPages)\n } else {\n add.startDots()\n add.pageNum(currentPage - step + 1, currentPage + step - 1)\n add.endDots()\n }\n\n return `\n <nav class=\"pagination is-centered is-small\">\n <a class=\"button pagination-previous\" data-action=\"page-prev\"${currentPage === 1 ? ' disabled' : ''}>Previous</a>\n <a class=\"button pagination-next\" data-action=\"page-next\"${currentPage >= numPages ? ' disabled' : ''}>Next page</a>\n <ul class=\"pagination-list\">${template}</ul>\n </nav>\n `\n}\n\npage.getStatistics = (params = {}) => {\n if (!page.permissions.admin) return swal('An error occurred!', 'You cannot do this!', 'error')\n\n if (page.isSomethingLoading) return page.warnSomethingLoading()\n\n page.updateTrigger(params.trigger, 'loading')\n\n const url = 'api/stats'\n axios.get(url).then(response => {\n if (response.data.success === false) {\n if (response.data.description === 'No token provided') {\n return page.verifyToken(page.token)\n } else {\n page.updateTrigger(params.trigger)\n return swal('An error occurred!', response.data.description, 'error')\n }\n }\n\n let content = ''\n const keys = Object.keys(response.data.stats)\n for (let i = 0; i < keys.length; i++) {\n let rows = ''\n if (!response.data.stats[keys[i]]) {\n rows += `\n <tr>\n <td>Generating, please try again later\\u2026</td>\n <td></td>\n </tr>\n `\n } else {\n try {\n const valKeys = Object.keys(response.data.stats[keys[i]])\n for (let j = 0; j < valKeys.length; j++) {\n const data = response.data.stats[keys[i]][valKeys[j]]\n const type = typeof data === 'object' ? data.type : 'auto'\n const value = typeof data === 'object' ? data.value : data\n\n let parsed\n switch (type) {\n case 'byte':\n parsed = page.getPrettyBytes(value)\n break\n case 'byteUsage': {\n // Reasoning: https://github.com/sebhildebrandt/systeminformation/issues/464#issuecomment-756406053\n const totalForPercentage = typeof value.available !== 'undefined'\n ? (value.used + value.available)\n : value.total\n parsed = `${page.getPrettyBytes(value.used)} / ${page.getPrettyBytes(value.total)} (${(value.used / totalForPercentage * 100).toFixed(2)}%)`\n break\n }\n case 'uptime':\n parsed = page.getPrettyUptime(value)\n break\n case 'auto':\n switch (typeof value) {\n case 'number':\n parsed = value.toLocaleString()\n break\n default:\n parsed = value\n }\n break\n default:\n parsed = value\n }\n\n rows += `\n <tr>\n <th>${valKeys[j]}</th>\n <td>${parsed}</td>\n </tr>\n `\n }\n } catch (error) {\n rows = `\n <tr>\n <td>Error parsing response. Try again?</td>\n <td></td>\n </tr>\n `\n page.onError(error)\n }\n }\n\n content += `\n <div class=\"table-container has-text-left\">\n <table id=\"statistics\" class=\"table is-narrow is-fullwidth is-hoverable\">\n <thead>\n <tr>\n <th class=\"capitalize\">${keys[i]}</th>\n <td></td>\n </tr>\n </thead>\n <tbody>\n ${rows}\n </tbody>\n </table>\n </div>\n `\n }\n\n if (Array.isArray(response.data.hrtime)) {\n content += `\n <article class=\"message is-size-7\">\n <div class=\"message-body has-text-left\">\n Time taken: ${response.data.hrtime[0]}s ${Math.ceil(response.data.hrtime[1] / 1000000)}ms.\n </div>\n </article>\n `\n }\n\n page.dom.innerHTML = content\n page.fadeInDom()\n page.scrollToDom()\n page.updateTrigger(params.trigger, 'active')\n }).catch(error => {\n page.updateTrigger(params.trigger)\n page.onAxiosError(error)\n })\n}\n\nwindow.addEventListener('DOMContentLoaded', () => {\n // Polyfill Object.assign()\n // eslint-disable-next-line compat/compat\n if (typeof Object.assign !== 'function') {\n // Must be writable: true, enumerable: false, configurable: true\n Object.defineProperty(Object, 'assign', {\n value: function assign (target, varArgs) { // .length of function is 2\n 'use strict'\n if (target === null || typeof target === 'undefined') {\n throw new TypeError('Cannot convert undefined or null to object')\n }\n const to = Object(target)\n for (let i = 1; i < arguments.length; i++) {\n const nextSource = arguments[i]\n if (nextSource !== null && typeof nextSource !== 'undefined') {\n for (const nextKey in nextSource) {\n // Avoid bugs when hasOwnProperty is shadowed\n if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {\n to[nextKey] = nextSource[nextKey]\n }\n }\n }\n }\n return to\n },\n writable: true,\n configurable: true\n })\n }\n\n // Add 'no-touch' class to non-touch devices\n if (!('ontouchstart' in document.documentElement)) {\n document.documentElement.classList.add('no-touch')\n }\n\n const selectedKeys = ['uploads', 'uploadsAll', 'albums', 'albumsAll', 'users']\n for (let i = 0; i < selectedKeys.length; i++) {\n const ls = localStorage[lsKeys.selected[selectedKeys[i]]]\n if (ls) page.selected[selectedKeys[i]] = JSON.parse(ls)\n }\n\n page.preparePage()\n\n page.clipboardJS = new ClipboardJS('.clipboard-js')\n\n page.clipboardJS.on('success', () => {\n return swal('', 'The link has been copied to clipboard.', 'success', {\n buttons: false,\n timer: 1500\n })\n })\n\n page.clipboardJS.on('error', page.onError)\n\n page.lazyLoad = new LazyLoad()\n\n page.albumsSidebarCollapse = document.querySelector('#albumsSidebarCollapse')\n\n /* eslint-disable-next-line new-cap */\n page.albumsSidebarCollapsible = new bulmaCollapsible(document.querySelector('#albumsSidebar'))\n page.albumsSidebarCollapsible.on('before:expand', event => {\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapse.dataset.textCollapse\n })\n page.albumsSidebarCollapsible.on('before:collapse', event => {\n page.albumsSidebarCollapse.innerText = page.albumsSidebarCollapse.dataset.textExpand\n })\n})\n"]} |