From 3c490dbadbe6f66cc9a29bea50a136e98bbe50f8 Mon Sep 17 00:00:00 2001 From: Jordan Wright Date: Wed, 30 Sep 2020 22:00:15 -0500 Subject: [PATCH] Updated JS from #1976 --- static/js/dist/app/users.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/dist/app/users.min.js b/static/js/dist/app/users.min.js index 4e8fa061..40631033 100644 --- a/static/js/dist/app/users.min.js +++ b/static/js/dist/app/users.min.js @@ -1 +1 @@ -!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=8)}({8:function(e,t){var n=[],o=function(){$("#username").val(""),$("#password").val(""),$("#confirm_password").val(""),$("#role").val(""),$("#modal\\.flashes").empty()},r=function(e){$("#modalSubmit").unbind("click").click(function(){!function(e){if($("#password").val()===$("#confirm_password").val()){var t={username:$("#username").val(),password:$("#password").val(),role:$("#role").val(),password_change_required:$("#force_password_change_checkbox").prop("checked")};-1!=e?(t.id=e,api.userId.put(t).success(function(e){successFlash("User "+escapeHtml(t.username)+" updated successfully!"),s(),o(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})):api.users.post(t).success(function(e){successFlash("User "+escapeHtml(t.username)+" registered successfully!"),s(),o(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})}else modalError("Passwords must match.")}(e)}),$("#role").select2(),-1==e?($("#role").val("user"),$("#role").trigger("change")):api.userId.get(e).success(function(e){$("#username").val(e.username),$("#role").val(e.role.slug),$("#role").trigger("change"),$("#force_password_change_checkbox").prop("checked",!1)}).error(function(){errorFlash("Error fetching user")})},s=function(){$("#userTable").hide(),$("#loading").show(),api.users.get().success(function(e){n=e,$("#loading").hide(),$("#userTable").show();var t=$("#userTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]});t.clear(),userRows=[],$.each(n,function(e,t){userRows.push([escapeHtml(t.username),escapeHtml(t.role.name),"
"])}),t.rows.add(userRows).draw()}).error(function(){errorFlash("Error fetching users")})};$(document).ready(function(){s(),$("#modal").on("hide.bs.modal",function(){o()}),$.fn.select2.defaults.set("width","100%"),$.fn.select2.defaults.set("dropdownParent",$("#role-select")),$.fn.select2.defaults.set("theme","bootstrap"),$.fn.select2.defaults.set("sorter",function(e){return e.sort(function(e,t){return e.text.toLowerCase()>t.text.toLowerCase()?1:e.text.toLowerCase()"+escapeHtml(o.username)+"",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Swap User",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1}).then(function(e){e.value&&fetch("/impersonate",{method:"post",body:"username="+o.username+"&csrf_token="+encodeURIComponent(csrf_token),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(e){200==e.status?Swal.fire({title:"Success!",html:"Successfully changed to user "+escapeHtml(o.username)+".",type:"success",showCancelButton:!1,confirmButtonText:"Home",allowOutsideClick:!1}).then(function(e){e.value&&(window.location.href="/")}):Swal.fire({title:"Error!",type:"error",html:"Failed to change to user "+escapeHtml(o.username)+".",showCancelButton:!1})})})})})}}); \ No newline at end of file +!function(e){var t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=8)}({8:function(e,t){var o=[],n=function(){$("#username").val(""),$("#password").val(""),$("#confirm_password").val(""),$("#role").val(""),$("#modal\\.flashes").empty()},r=function(e){$("#modalSubmit").unbind("click").click(function(){!function(e){if($("#password").val()===$("#confirm_password").val()){var t={username:$("#username").val(),password:$("#password").val(),role:$("#role").val(),password_change_required:$("#force_password_change_checkbox").prop("checked")};-1!=e?(t.id=e,api.userId.put(t).success(function(e){successFlash("User "+escapeHtml(t.username)+" updated successfully!"),s(),n(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})):api.users.post(t).success(function(e){successFlash("User "+escapeHtml(t.username)+" registered successfully!"),s(),n(),$("#modal").modal("hide")}).error(function(e){modalError(e.responseJSON.message)})}else modalError("Passwords must match.")}(e)}),$("#role").select2(),-1==e?($("#role").val("user"),$("#role").trigger("change")):api.userId.get(e).success(function(e){$("#username").val(e.username),$("#role").val(e.role.slug),$("#role").trigger("change"),$("#force_password_change_checkbox").prop("checked",!1)}).error(function(){errorFlash("Error fetching user")})},s=function(){$("#userTable").hide(),$("#loading").show(),api.users.get().success(function(e){o=e,$("#loading").hide(),$("#userTable").show();var t=$("#userTable").DataTable({destroy:!0,columnDefs:[{orderable:!1,targets:"no-sort"}]});t.clear(),userRows=[],$.each(o,function(e,t){lastlogin="Never","0001-01-01T00:00:00Z"!=t.last_login&&(lastlogin=moment(t.last_login).format("MMMM Do YYYY, h:mm:ss a")),userRows.push([escapeHtml(t.username),escapeHtml(t.role.name),lastlogin,"
"])}),t.rows.add(userRows).draw()}).error(function(){errorFlash("Error fetching users")})};$(document).ready(function(){s(),$("#modal").on("hide.bs.modal",function(){n()}),$.fn.select2.defaults.set("width","100%"),$.fn.select2.defaults.set("dropdownParent",$("#role-select")),$.fn.select2.defaults.set("theme","bootstrap"),$.fn.select2.defaults.set("sorter",function(e){return e.sort(function(e,t){return e.text.toLowerCase()>t.text.toLowerCase()?1:e.text.toLowerCase()"+escapeHtml(n.username)+"",type:"warning",animation:!1,showCancelButton:!0,confirmButtonText:"Swap User",confirmButtonColor:"#428bca",reverseButtons:!0,allowOutsideClick:!1}).then(function(e){e.value&&fetch("/impersonate",{method:"post",body:"username="+n.username+"&csrf_token="+encodeURIComponent(csrf_token),headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(e){200==e.status?Swal.fire({title:"Success!",html:"Successfully changed to user "+escapeHtml(n.username)+".",type:"success",showCancelButton:!1,confirmButtonText:"Home",allowOutsideClick:!1}).then(function(e){e.value&&(window.location.href="/")}):Swal.fire({title:"Error!",type:"error",html:"Failed to change to user "+escapeHtml(n.username)+".",showCancelButton:!1})})})})})}}); \ No newline at end of file