Files
pgsql-jellyfin/Jellyfin.Server/wwwroot/user-userprofile.f15366fd87ea3a594c64.chunk.js
2026-07-08 13:13:46 -04:00

1 line
17 KiB
JavaScript

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[16325],{648:function(e,r,t){t.d(r,{J:function(){return s},t:function(){return i}});var n=t(18879),o=t(80401),a=t(69410),i="User",s=function(e){var r=(0,a.gf)().api;return(0,o.I)({queryKey:[i,null==e?void 0:e.userId],queryFn:function(t){var o=t.signal;return function(e,r,t){return o=void 0,a=void 0,s=function(){return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=r.call(e,a)}catch(e){s=[6,e],n=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,(function(o){switch(o.label){case 0:return[4,(0,n.q)(e).getUserById(r,t)];case 1:return[2,o.sent().data]}}))},new((i=void 0)||(i=Promise))((function(e,r){function t(e){try{l(s.next(e))}catch(e){r(e)}}function n(e){try{l(s.throw(e))}catch(e){r(e)}}function l(r){var o;r.done?e(r.value):(o=r.value,o instanceof i?o:new i((function(e){e(o)}))).then(t,n)}l((s=s.apply(o,a||[])).next())}));var o,a,i,s}(r,e,{signal:o})},enabled:!!r&&!!e})}},25235:function(e,r,t){var n=t(62540),o=t(63696),a=t(89100),i=t(5898),s=t(47602),l=t(8566),c=t(71866),u=t(50723),d=t(42301),f=function(e,r,t,n){return new(t||(t=Promise))((function(o,a){function i(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var r;e.done?o(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(i,s)}l((n=n.apply(e,r||[])).next())}))},y=function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=r.call(e,a)}catch(e){s=[6,e],n=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};r.A=function(e){var r=e.user,p=(0,o.useRef)(null),m=(0,o.useMemo)((function(){return f(void 0,void 0,void 0,(function(){return y(this,(function(e){switch(e.label){case 0:return[4,Promise.all([t.e(45642),t.e(45568),t.e(73233),t.e(68603)]).then(t.bind(t,73233))];case 1:return[2,e.sent().default]}}))}))}),[]),h=(0,o.useCallback)((function(){return f(void 0,void 0,void 0,(function(){var e,n,o,i,s;return y(this,(function(l){switch(l.label){case 0:return(e=p.current)?[4,a.default.getCurrentUser()]:(console.error("[UserPasswordForm] Unexpected null page reference"),[2]);case 1:if(n=l.sent(),!r.Policy||!r.Configuration)throw new Error("Unexpected null user policy or configuration");return[4,m];case 2:return l.sent().setTitle(r.Name),r.HasConfiguredPassword?((null===(i=r.Policy)||void 0===i?void 0:i.IsAdministrator)||e.querySelector("#btnResetPassword").classList.remove("hide"),e.querySelector("#fldCurrentPassword").classList.remove("hide")):(e.querySelector("#btnResetPassword").classList.add("hide"),e.querySelector("#fldCurrentPassword").classList.add("hide")),o=(null===(s=null==n?void 0:n.Policy)||void 0===s?void 0:s.IsAdministrator)||r.Policy.EnableUserPreferenceAccess,e.querySelector(".passwordSection").classList.toggle("hide",!o),Promise.resolve().then(t.bind(t,84069)).then((function(r){r.default.autoFocus(e)})).catch((function(e){console.error("[UserPasswordForm] failed to load autofocuser",e)})),e.querySelector("#txtCurrentPassword").value="",e.querySelector("#txtNewPassword").value="",e.querySelector("#txtNewPasswordConfirm").value="",[2]}}))}))}),[r,m]);return(0,o.useEffect)((function(){var e=p.current;if(e){h().catch((function(e){console.error("[UserPasswordForm] failed to load user",e)}));var t=function(t){var o;return e.querySelector("#txtNewPassword").value!=e.querySelector("#txtNewPasswordConfirm").value?(0,c.A)(i.Ay.translate("PasswordMatchError")):""==e.querySelector("#txtNewPassword").value&&(null===(o=null==r?void 0:r.Policy)||void 0===o?void 0:o.IsAdministrator)?(0,c.A)(i.Ay.translate("PasswordMissingSaveError")):(l.Ay.show(),n()),t.preventDefault(),!1},n=function(){if(r.Id){var t=e.querySelector("#txtCurrentPassword").value,n=e.querySelector("#txtNewPassword").value;e.querySelector("#fldCurrentPassword").classList.contains("hide")&&(t=""),window.ApiClient.updateUserPassword(r.Id,t,n).then((function(){l.Ay.hide(),(0,c.A)(i.Ay.translate("PasswordSaved")),h().catch((function(e){console.error("[UserPasswordForm] failed to load user",e)}))}),(function(){l.Ay.hide(),a.default.alert({title:i.Ay.translate("HeaderLoginFailure"),message:i.Ay.translate("MessageInvalidUser")})}))}else console.error("[UserPasswordForm.savePassword] missing user id")},o=function(){var e=i.Ay.translate("PasswordResetConfirmation");(0,s.A)(e,i.Ay.translate("ResetPassword")).then((function(){l.Ay.show(),r.Id&&window.ApiClient.resetUserPassword(r.Id).then((function(){l.Ay.hide(),a.default.alert({message:i.Ay.translate("PasswordResetComplete"),title:i.Ay.translate("ResetPassword")}),h().catch((function(e){console.error("[UserPasswordForm] failed to load user",e)}))})).catch((function(e){console.error("[UserPasswordForm] failed to reset user password",e)}))})).catch((function(){}))};return e.querySelector(".updatePasswordForm").addEventListener("submit",t),e.querySelector("#btnResetPassword").addEventListener("click",o),function(){e.querySelector(".updatePasswordForm").removeEventListener("submit",t),e.querySelector("#btnResetPassword").removeEventListener("click",o)}}console.error("[UserPasswordForm] Unexpected null page reference")}),[h,r]),(0,n.jsx)("div",{ref:p,children:(0,n.jsx)("form",{className:"updatePasswordForm passwordSection hide",style:{margin:"0 auto 2em"},children:(0,n.jsxs)("div",{className:"detailSection",children:[(0,n.jsx)("div",{id:"fldCurrentPassword",className:"inputContainer hide",children:(0,n.jsx)(d.A,{type:"password",id:"txtCurrentPassword",label:i.Ay.translate("LabelCurrentPassword"),autoComplete:"off"})}),(0,n.jsx)("div",{className:"inputContainer",children:(0,n.jsx)(d.A,{type:"password",id:"txtNewPassword",label:i.Ay.translate("LabelNewPassword"),autoComplete:"off"})}),(0,n.jsx)("div",{className:"inputContainer",children:(0,n.jsx)(d.A,{type:"password",id:"txtNewPasswordConfirm",label:i.Ay.translate("LabelNewPasswordConfirm"),autoComplete:"off"})}),(0,n.jsx)("br",{}),(0,n.jsxs)("div",{children:[(0,n.jsx)(u.A,{type:"submit",className:"raised button-submit block",title:i.Ay.translate("SavePassword")}),(0,n.jsx)(u.A,{type:"button",id:"btnResetPassword",className:"raised button-cancel block hide",title:i.Ay.translate("ResetPassword")})]})]})})})}},42301:function(e,r,t){var n=t(62540),o=t(4452),a=t.n(o),i=t(63696),s=function(){return s=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},s.apply(this,arguments)},l=(0,i.forwardRef)((function(e,r){var t=e.id,o=e.label,l=e.className,c=e.onBlur,u=e.onFocus,d=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(e,["id","label","className","onBlur","onFocus"]),f=function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,a=t.call(e),i=[];try{for(;(void 0===r||r-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i}((0,i.useState)(!1),2),y=f[0],p=f[1],m=(0,i.useCallback)((function(e){p(!1),null==c||c(e)}),[c]),h=(0,i.useCallback)((function(e){p(!0),null==u||u(e)}),[u]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("label",{htmlFor:t,className:a()("inputLabel",{inputLabelUnfocused:!y,inputLabelFocused:y}),children:o}),(0,n.jsx)("input",s({ref:r,id:t,className:a()("emby-input",l),onBlur:m,onFocus:h},d))]})}));l.displayName="Input",r.A=l},50723:function(e,r,t){var n,o=t(62540),a=(t(63696),t(4452)),i=t.n(a),s=t(46782),l=function(){return l=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e},l.apply(this,arguments)};!function(e){e.RIGHT="RIGHT",e.LEFT="LEFT"}(n||(n={})),r.A=function(e){var r=e.className,t=e.title,a=e.icon,c=e.iconClassName,u=e.iconPos,d=e.onClick,f=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)r.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(t[n[o]]=e[n[o]])}return t}(e,["className","title","icon","iconClassName","iconPos","onClick"]),y=i()("emby-button",r,{"show-focus":s.A.tv}),p=i()("material-icons",c,a);return(0,o.jsxs)("button",l({className:y,onClick:d},f,{children:[a&&u===n.LEFT&&(0,o.jsx)("span",{className:p,"aria-hidden":"true"}),(0,o.jsx)("span",{children:t}),a&&u===n.RIGHT&&(0,o.jsx)("span",{className:p,"aria-hidden":"true"})]}))}},66718:function(e,r,t){t.r(r);var n=t(62540),o=t(64680),a=t(63696),i=t(9055),s=t(89100),l=t(5898),c=t(22622),u=t(47602),d=t(71866),f=t(648),y=t(8566),p=t(31297),m=t(25235),h=t(65242),v=t(84849),b=t(50723);r.default=function(){var e=function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,a=t.call(e),i=[];try{for(;(void 0===r||r-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i}((0,i.ok)(),1)[0].get("userId"),r=(0,f.J)(e?{userId:e}:void 0),w=r.data,g=r.isPending,P=(0,a.useMemo)((function(){return e=void 0,r=void 0,o=function(){return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=r.call(e,a)}catch(e){s=[6,e],n=0}finally{t=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,(function(e){switch(e.label){case 0:return[4,Promise.all([t.e(45642),t.e(45568),t.e(73233),t.e(68603)]).then(t.bind(t,73233))];case 1:return[2,e.sent().default]}}))},new((n=void 0)||(n=Promise))((function(t,a){function i(e){try{l(o.next(e))}catch(e){a(e)}}function s(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(i,s)}l((o=o.apply(e,r||[])).next())}));var e,r,n,o}),[]),x=(0,a.useRef)(null),A=(0,a.useCallback)((function(){var e=x.current;if(e){if(!(null==w?void 0:w.Name)||!(null==w?void 0:w.Id))throw new Error("Unexpected null user name or id");P.then((function(e){return e.setTitle(w.Name)}));var r="assets/img/avatar.png";w.PrimaryImageTag&&(r=window.ApiClient.getUserImageUrl(w.Id,{tag:w.PrimaryImageTag,type:"Primary"})),e.querySelector("#image").style.backgroundImage="url("+r+")",s.default.getCurrentUser().then((function(r){var t;if(!w.Policy)throw new Error("Unexpected null user.Policy");w.PrimaryImageTag?(e.querySelector("#btnAddImage").classList.add("hide"),e.querySelector("#btnDeleteImage").classList.remove("hide")):c.g.supports("fileinput")&&((null===(t=null==r?void 0:r.Policy)||void 0===t?void 0:t.IsAdministrator)||w.Policy.EnableUserPreferenceAccess)&&(e.querySelector("#btnDeleteImage").classList.add("hide"),e.querySelector("#btnAddImage").classList.remove("hide"))})).catch((function(e){console.error("[userprofile] failed to get current user",e)}))}else console.error("[userprofile] Unexpected null page reference")}),[w,P]);return(0,a.useEffect)((function(){var r=x.current;if(r){A();var t=function(e){var r,t;switch(y.Ay.hide(),null===(t=null===(r=e.target)||void 0===r?void 0:r.error)||void 0===t?void 0:t.code){case DOMException.NOT_FOUND_ERR:(0,d.A)(l.Ay.translate("FileNotFound"));break;case DOMException.ABORT_ERR:n();break;default:(0,d.A)(l.Ay.translate("FileReadError"))}},n=function(){y.Ay.hide(),(0,d.A)(l.Ay.translate("FileReadCancelled"))},a=function(){e?(0,u.A)(l.Ay.translate("DeleteImageConfirmation"),l.Ay.translate("DeleteImage")).then((function(){y.Ay.show(),window.ApiClient.deleteUserImage(e,o.y.Primary).then((function(){y.Ay.hide(),p.q.invalidateQueries({queryKey:["User"]})})).catch((function(e){console.error("[userprofile] failed to delete image",e)}))})).catch((function(){})):console.error("[userprofile] missing user id")},i=function(){var e=r.querySelector("#uploadImage");e.value="",e.click()},s=function(a){!function(a){var i=r.querySelector("#image"),s=a.target.files[0];if(!s||!/image.*/.exec(s.type))return!1;var l=new FileReader;l.onerror=t,l.onabort=n,l.onload=function(){e?(i.style.backgroundImage="url("+l.result+")",window.ApiClient.uploadUserImage(e,o.y.Primary,s).then((function(){y.Ay.hide(),p.q.invalidateQueries({queryKey:["User"]})})).catch((function(e){console.error("[userprofile] failed to upload image",e)}))):console.error("[userprofile] missing user id")},l.readAsDataURL(s)}(a)};return r.querySelector("#btnDeleteImage").addEventListener("click",a),r.querySelector("#btnAddImage").addEventListener("click",i),r.querySelector("#uploadImage").addEventListener("change",s),function(){r.querySelector("#btnDeleteImage").removeEventListener("click",a),r.querySelector("#btnAddImage").removeEventListener("click",i),r.querySelector("#uploadImage").removeEventListener("change",s)}}console.error("[userprofile] Unexpected null page reference")}),[A,w,e]),g||!w?(0,n.jsx)(v.A,{}):(0,n.jsx)(h.A,{id:"userProfilePage",title:l.Ay.translate("Profile"),className:"mainAnimatedPage libraryPage userPreferencesPage userPasswordPage noSecondaryNavPage",children:(0,n.jsxs)("div",{ref:x,className:"padded-left padded-right padded-bottom-page",children:[(0,n.jsxs)("div",{className:"readOnlyContent",style:{margin:"0 auto",marginBottom:"1.8em",padding:"0 1em",display:"flex",flexDirection:"row",alignItems:"center"},children:[(0,n.jsxs)("div",{className:"imagePlaceHolder",style:{position:"relative",display:"inline-block",maxWidth:200},children:[(0,n.jsx)("input",{id:"uploadImage",type:"file",accept:"image/*",style:{position:"absolute",right:0,width:"100%",height:"100%",opacity:0,cursor:"pointer"}}),(0,n.jsx)("div",{id:"image",style:{width:200,height:200,backgroundRepeat:"no-repeat",backgroundPosition:"center",borderRadius:"100%",backgroundSize:"cover"}})]}),(0,n.jsxs)("div",{style:{verticalAlign:"top",margin:"1em 2em",display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,n.jsx)("h2",{className:"username",style:{margin:0,fontSize:"xx-large"},children:null==w?void 0:w.Name}),(0,n.jsx)("br",{}),(0,n.jsx)(b.A,{type:"button",id:"btnAddImage",className:"raised button-submit hide",title:l.Ay.translate("ButtonAddImage")}),(0,n.jsx)(b.A,{type:"button",id:"btnDeleteImage",className:"raised hide",title:l.Ay.translate("DeleteImage")})]})]}),(0,n.jsx)(m.A,{user:w})]})})}}}]);