"+e.toString()+"
",swal({title:"An error occurred!",icon:"error",content:a})},onAxiosError:function(e){console.error(e);var a={520:"Unknown Error",521:"Web Server Is Down",522:"Connection Timed Out",523:"Origin Is Unreachable",524:"A Timeout Occurred",525:"SSL Handshake Failed",526:"Invalid SSL Certificate",527:"Railgun Error",530:"Origin DNS Error"}[e.response.status]||e.response.statusText,n=e.response.data&&e.response.data.description?e.response.data.description:"There was an error with the request, please check the console for more information.";return swal(e.response.status+" "+a,n,"error")},preparePage:function(){page.token?page.verifyToken(page.token,!0):window.location="auth"},verifyToken:function(e,a){axios.post("api/tokens/verify",{token:e}).then((function(n){if(!1===n.data.success)return swal({title:"An error occurred!",text:n.data.description,icon:"error"}).then((function(){a&&(localStorage.removeItem(lsKeys.token),window.location="auth")}));axios.defaults.headers.common.token=e,localStorage[lsKeys.token]=e,page.token=e,page.username=n.data.username,page.permissions=n.data.permissions,page.prepareDashboard()})).catch(page.onAxiosError)},prepareDashboard:function(){page.dom=document.querySelector("#page"),page.dom.addEventListener("click",page.domClick,!0),page.dom.addEventListener("submit",(function(e){if(e.target&&e.target.classList.contains("prevent-default"))return e.preventDefault()}),!0),page.menusContainer=document.querySelector("#menu");for(var e=[{selector:"#itemUploads",onclick:page.getUploads},{selector:"#itemDeleteUploadsByNames",onclick:page.deleteUploadsByNames},{selector:"#itemManageAlbums",onclick:page.getAlbums},{selector:"#itemManageToken",onclick:page.changeToken},{selector:"#itemChangePassword",onclick:page.changePassword},{selector:"#itemLogout",onclick:page.logout},{selector:"#itemManageUploads",onclick:page.getUploads,params:{all:!0},group:"moderator"},{selector:"#itemStatistics",onclick:page.getStatistics,group:"admin"},{selector:"#itemManageUsers",onclick:page.getUsers,group:"admin"}],a=function(a){if(!e[a].group||page.permissions[e[a].group]){var n=document.querySelector(e[a].selector);n.addEventListener("click",(function(n){page.menusContainer.classList.contains("is-loading")||e[a].onclick.call(null,Object.assign({trigger:n.currentTarget},e[a].params||{}))})),n.classList.remove("is-hidden"),page.menus.push(n)}},n=0;n'+f.name+"
\n"+(f.appendix?""+f.appendix+" – ":"")+f.prettyBytes+"
\n "+(p&&f.prettyExpiryDate?'\nEXP: '+f.prettyExpiryDate+"
":"")+"\n\n | File name | \n '+(void 0===e.album?""+(e.all?"User":"Album")+" | ":"")+"\nSize | \n "+(e.all?"IP | ":"")+"\nDate | \n "+(p?"Expiry date | ":"")+'\n\n |
---|
user:demo
\n Uploads from users named "demo" AND/OR "John Doe" AND/OR non-registered users:\n user:demo user:"John Doe" user:-
\n ALL uploads, including from non-registered users, but NOT the ones from user named "demo":\n -user:demo user:-
\n Uploads from IP "127.0.0.1" AND which file names match "*.rar" OR "*.zip":\n ip:127.0.0.1 *.rar *.zip
\n Uploads uploaded since "1 June 2019 00:00:00":\n date:2019/06
\n Uploads uploaded between "7 April 2020 00:00:00" and "7 April 2020 23:59:59":\n date:2020/04/07-2020/04/07 23:59:59
\n Uploads which file names match "*.gz" but NOT "*.tar.gz":\n *.gz -*.tar.gz
\n Sort matches by "size" column in ascending and descending order respectively:\n user:"John Doe" orderby:size
\n *.mp4 user:- orderby:size:d
\n\n Friendly reminder: This window can be scrolled up!\n '.trim().replace(/^ {6}/gm,"").replace(/\n/g,"You won't be able to recover "+n.replace(/^(\d*)(.*)/,"$1$2")+"!
";e.all&&(t+="\nWarning: You may be nuking "+(1===a?"an upload":"some uploads")+" by "+(1===a?"another user":"other users")+"!
");var s=document.createElement("div");s.innerHTML=t,swal({title:"Are you sure?",content:s,icon:"warning",dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, nuke "+(1===e.values.length?"it":"them")+"!",closeModal:!1}}}).then((function(t){t&&axios.post("api/upload/bulkdelete",{field:e.fields,values:e.values}).then((function(t){if(t){if(!1===t.data.success)return"No token provided"===t.data.description?page.verifyToken(page.token):swal("An error occurred!",t.data.description,"error");var s=Array.isArray(t.data.failed)?t.data.failed:[];s.length===e.values.length?swal("An error occurred!","Unable to delete any of the "+n+".","error"):s.length&&s.lengthYou are about to add '+n+" upload"+(1===n?"":"s")+' to an album.
\nIf an upload is already in an album, it will be moved.
\n \nID | \nName | \nFiles | \nCreated at | \nPublic link | \n\n |
---|
Max length is '+page.albumTitleMaxLength+' characters.
\nMax length is '+page.albumDescMaxLength+' characters.
\n\n | Username | \nUploads | \nUsage | \nGroup | \n\n |
---|
Username: "+e.data.username+"
\nPassword: "+e.data.password+"
User group: "+e.data.group+"
\n ",swal({title:"Created a new user!",icon:"success",content:a}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))},editUser:function(e){var a=page.cache.users[e];if(a){var n=Object.keys(page.permissions).map((function(e,n,t){return'"})).join("\n"),t=document.createElement("div");t.innerHTML='\n"+a.username+" was renamed into: "+e.data.update.username+".
",n=!1,s=e.data.update.username),e.data.update.password&&(t.innerHTML+="\n"+s+"'s new password is:
\n"+e.data.update.password+"
"+s+" has been "+(e.data.update.enabled?"enabled":"disabled")+"!
"),t.innerHTML||(t.innerHTML=""+s+" was edited!
"),swal({title:"Success!",icon:"success",content:t,buttons:!n,timer:n?1500:null}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},disableUser:function(e){var a=page.cache.users[e];if(a&&a.enabled){var n=document.createElement("div");n.innerHTML="\nYou will be disabling a user named "+page.cache.users[e].username+".
\nTheir files will remain.
\n ",swal({title:"Are you sure?",icon:"warning",content:n,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, disable them!",closeModal:!1}}}).then((function(a){a&&axios.post("api/users/disable",{id:e}).then((function(a){if(a){if(!1===a.data.success)return"No token provided"===a.data.description?page.verifyToken(page.token):swal("An error occurred!",a.data.description,"error");swal("Success!",page.cache.users[e].username+" has been disabled.","success",{buttons:!1,timer:1500}),page.getUsers(page.views.users)}})).catch(page.onAxiosError)}))}},deleteUser:function(e){if(page.cache.users[e]){var a=document.createElement("div");a.innerHTML="\nYou will be deleting a user named "+page.cache.users[e].username+".
\n
Their files will remain, unless you choose otherwise.
\n ",swal({title:"Are you sure?",icon:"warning",content:a,dangerMode:!0,buttons:{cancel:!0,confirm:{text:"Yes, delete it!",closeModal:!1},purge:{text:"Yes, and the uploads too!",value:"purge",className:"swal-button--danger",closeModal:!1}}}).then((function(a){a&&axios.post("api/users/delete",{id:e,purge:"purge"===a}).then((function(a){if(a){if(!1===a.data.success){var n=Array.isArray(a.data.failed)?a.data.failed:[];return"No token provided"===a.data.description?page.verifyToken(page.token):n.length?swal("An error occurred!","Unable to delete "+n.length+" of the user's upload"+(1===n.length?"":"s")+".","error"):swal("An error occurred!",a.data.description,"error")}swal("Success!",page.cache.users[e].username+" has been deleted.","success",{buttons:!1,timer:1500}),page.getUsers(Object.assign({autoPage:!0},page.views.users))}})).catch(page.onAxiosError)}))}},paginate:function(e,a,n){n+=1;var t=Math.ceil(e/a),s="",i=function(e,a){for(var t=e;t<=a;++t)s+=''+t[s].toUpperCase()+" | \n\n |
---|