Files
owncast/static/web/_next/static/chunks/pages/admin/config-notify-2ecba72764f48675.js
2022-12-28 11:31:54 +00:00

1 line
11 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4440],{7148:function(e,n,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/config-notify",function(){return s(4737)}])},73706:function(e,n,s){"use strict";s.d(n,{Z:function(){return d}});var i=s(85893),a=s(67294),l=s(94594),t=s(41983),r=s(39664),o=s(90745),c=s(99519);let d=e=>{let{apiPath:n,checked:s,reversed:d=!1,configPath:u="",disabled:h=!1,fieldName:p,label:x,tip:m,useSubmit:f,onChange:g}=e,[b,j]=(0,a.useState)(null),v=null,y=(0,a.useContext)(c.aC),{setFieldInConfigState:k}=y||{},w=()=>{j(null),clearTimeout(v),v=null},C=async e=>{if(f){j((0,t.kg)(t.Jk));let s=d?!e:e;await (0,o.Si)({apiPath:n,data:{value:s},onSuccess:()=>{k({fieldName:p,value:s,path:u}),j((0,t.kg)(t.zv))},onError:e=>{j((0,t.kg)(t.Un,"There was an error: ".concat(e)))}}),v=setTimeout(w,o.sI)}g&&g(e)},N=null!==b&&b.type===t.Jk;return(0,i.jsxs)("div",{className:"formfield-container toggleswitch-container",children:[x&&(0,i.jsx)("div",{className:"label-side",children:(0,i.jsx)("span",{className:"formfield-label",children:x})}),(0,i.jsxs)("div",{className:"input-side",children:[(0,i.jsxs)("div",{className:"input-group",children:[(0,i.jsx)(l.Z,{className:"switch field-".concat(p),loading:N,onChange:C,defaultChecked:s,checked:s,checkedChildren:"ON",unCheckedChildren:"OFF",disabled:h}),(0,i.jsx)(r.E,{status:b})]}),(0,i.jsx)("p",{className:"field-tip",children:m})]})]})};d.defaultProps={apiPath:"",checked:!1,reversed:!1,configPath:"",disabled:!1,label:"",tip:"",useSubmit:!1,onChange:null}},4737:function(e,n,s){"use strict";s.r(n),s.d(n,{default:function(){return E}});var i=s(85893),a=s(84485),l=s(14670),t=s(71230),r=s(15746),o=s(71577),c=s(67294),d=s(41664),u=s.n(d),h=s(99519),p=s(40117),x=s(39664),m=s(90745),f=s(73706),g=s(41983);let{Title:b}=a.Z,j=()=>{let e=(0,c.useContext)(h.aC),{serverConfig:n,setFieldInConfigState:s}=e||{},{notifications:a}=n||{},{discord:l}=a||{},{enabled:t,webhook:r,goLiveMessage:d}=l||{},[u,j]=(0,c.useState)({}),[v,y]=(0,c.useState)(null),[k,w]=(0,c.useState)(!1);(0,c.useEffect)(()=>{j({enabled:t,webhook:r,goLiveMessage:d})},[a,l]);let C=()=>""!==r&&""!==d,N=e=>{let{fieldName:n,value:s}=e;j({...u,[n]:s}),w(C())},T=()=>{y(null),clearTimeout(null)},S=async()=>{await (0,m.Si)({apiPath:"/notifications/discord",data:{value:u},onSuccess:()=>{s({fieldName:"discord",value:u,path:"notifications"}),y((0,g.kg)(g.zv,"Updated.")),setTimeout(T,m.sI)},onError:e=>{y((0,g.kg)(g.Un,e)),setTimeout(T,m.sI)}})},Z=e=>{N({fieldName:"enabled",value:e})};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(b,{children:"Discord"}),(0,i.jsx)("p",{className:"description reduced-margins",children:"Let your Discord channel know each time you go live."}),(0,i.jsxs)("p",{className:"description reduced-margins",children:[(0,i.jsx)("a",{href:"https://support.discord.com/hc/en-us/articles/228383668",target:"_blank",rel:"noreferrer",children:"Create a webhook"})," ","under ",(0,i.jsx)("i",{children:"Edit Channel / Integrations"})," on your Discord channel and provide it below."]}),(0,i.jsx)(f.Z,{apiPath:"",fieldName:"discordEnabled",label:"Enable Discord",checked:u.enabled,onChange:Z}),(0,i.jsx)("div",{style:{display:u.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.oy.webhookUrl,required:!0,value:u.webhook,onChange:N})}),(0,i.jsx)("div",{style:{display:u.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.oy.goLiveMessage,required:!0,value:u.goLiveMessage,onChange:N})}),(0,i.jsx)(o.Z,{type:"primary",onClick:S,style:{display:k?"inline-block":"none",position:"relative",marginLeft:"auto",right:"0",marginTop:"20px"},children:"Save"}),(0,i.jsx)(x.E,{status:v})]})},{Title:v}=a.Z,y=()=>{let e=(0,c.useContext)(h.aC),{serverConfig:n,setFieldInConfigState:s}=e||{},{notifications:a}=n||{},{browser:l}=a||{},{enabled:t,goLiveMessage:r}=l||{},[d,u]=(0,c.useState)({}),[b,j]=(0,c.useState)(null),[y,k]=(0,c.useState)(!1);(0,c.useEffect)(()=>{u({enabled:t,goLiveMessage:r})},[a,l]);let w=()=>!0,C=e=>{let{fieldName:n,value:s}=e;console.log(n,s),u({...d,[n]:s}),k(w())},N=e=>{C({fieldName:"enabled",value:e})},T=()=>{j(null),clearTimeout(null)},S=async()=>{await (0,m.Si)({apiPath:"/notifications/browser",data:{value:d},onSuccess:()=>{s({fieldName:"browser",value:d,path:"notifications"}),j((0,g.kg)(g.zv,"Updated.")),setTimeout(T,m.sI)},onError:e=>{j((0,g.kg)(g.Un,e)),setTimeout(T,m.sI)}})};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(v,{children:"Browser Alerts"}),(0,i.jsx)("p",{className:"description reduced-margins",children:"Viewers can opt into being notified when you go live with their browser."}),(0,i.jsx)("p",{className:"description reduced-margins",children:"Not all browsers support this."}),(0,i.jsx)(f.Z,{apiPath:"",fieldName:"enabled",label:"Enable browser notifications",onChange:N,checked:d.enabled}),(0,i.jsx)("div",{style:{display:d.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.mv.goLiveMessage,required:!0,type:p.Sk,value:d.goLiveMessage,onChange:C})}),(0,i.jsx)(o.Z,{type:"primary",style:{display:y?"inline-block":"none",position:"relative",marginLeft:"auto",right:"0",marginTop:"20px"},onClick:S,children:"Save"}),(0,i.jsx)(x.E,{status:b})]})};var k=s(10135);let{Title:w}=a.Z,C=()=>{let e=(0,c.useContext)(h.aC),{serverConfig:n,setFieldInConfigState:s}=e||{},{notifications:a}=n||{},{twitter:l}=a||{},[t,r]=(0,c.useState)({}),[d,u]=(0,c.useState)(null),[b,j]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let{enabled:e,apiKey:n,apiSecret:s,accessToken:i,accessTokenSecret:a,bearerToken:t,goLiveMessage:o}=l||{};r({enabled:e,apiKey:n,apiSecret:s,accessToken:i,accessTokenSecret:a,bearerToken:t,goLiveMessage:o})},[l]);let v=()=>{let{enabled:e,apiKey:n,apiSecret:s,accessToken:i,accessTokenSecret:a,bearerToken:l,goLiveMessage:r}=t;return e&&!!n&&!!s&&!!i&&!!a&&!!l&&!!r},y=e=>{let{fieldName:n,value:s}=e;r({...t,[n]:s}),j(v())},C=e=>{let n=t.enabled;return y({fieldName:"enabled",value:e}),e!==n},N=()=>{u(null),clearTimeout(null),j(!1)},T=async()=>{await (0,m.Si)({apiPath:"/notifications/twitter",data:{value:t},onSuccess:()=>{s({fieldName:"twitter",value:t,path:"notifications"}),u((0,g.kg)(g.zv,"Updated.")),setTimeout(N,m.sI)},onError:e=>{u((0,g.kg)(g.Un,e)),setTimeout(N,m.sI)}})};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(w,{children:"Twitter"}),(0,i.jsx)("p",{className:"description reduced-margins",children:"Let your Twitter followers know each time you go live."}),(0,i.jsxs)("div",{style:{display:t.enabled?"block":"none"},children:[(0,i.jsxs)("p",{className:"description reduced-margins",children:[(0,i.jsx)("a",{href:"https://owncast.online/docs/notifications",target:"_blank",rel:"noreferrer",children:"Read how to configure your Twitter account"})," ","to support posting from Owncast."]}),(0,i.jsxs)("p",{className:"description reduced-margins",children:[(0,i.jsx)("a",{href:"https://developer.twitter.com/en/portal/dashboard",target:"_blank",rel:"noreferrer",children:"And then get your Twitter developer credentials"})," ","to fill in below."]})]}),(0,i.jsx)(f.Z,{apiPath:"",fieldName:"enabled",label:"Enable Twitter",onChange:C,checked:t.enabled}),(0,i.jsx)("div",{style:{display:t.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.$Z.apiKey,required:!0,value:t.apiKey,onChange:y})}),(0,i.jsx)("div",{style:{display:t.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.$Z.apiSecret,type:p.A8,required:!0,value:t.apiSecret,onChange:y})}),(0,i.jsx)("div",{style:{display:t.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.$Z.accessToken,required:!0,value:t.accessToken,onChange:y})}),(0,i.jsx)("div",{style:{display:t.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.$Z.accessTokenSecret,type:p.A8,required:!0,value:t.accessTokenSecret,onChange:y})}),(0,i.jsx)("div",{style:{display:t.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.$Z.bearerToken,required:!0,value:t.bearerToken,onChange:y})}),(0,i.jsx)("div",{style:{display:t.enabled?"block":"none"},children:(0,i.jsx)(p.nv,{...m.$Z.goLiveMessage,type:k.Kx,required:!0,value:t.goLiveMessage,onChange:y})}),(0,i.jsx)(o.Z,{type:"primary",onClick:T,style:{display:b?"inline-block":"none",position:"relative",marginLeft:"auto",right:"0",marginTop:"20px"},children:"Save"}),(0,i.jsx)(x.E,{status:d})]})},{Title:N}=a.Z,T=()=>{let e=(0,c.useContext)(h.aC),{serverConfig:n}=e||{},{federation:s}=n||{},{enabled:a}=s||{},[l,t]=(0,c.useState)({});return(0,c.useEffect)(()=>{t({enabled:a})},[a]),(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(N,{children:"Fediverse Social"}),(0,i.jsx)("p",{className:"description",children:"Enabling the Fediverse social features will not just alert people to when you go live, but also enable other functionality."}),(0,i.jsxs)("p",{children:["Fediverse social features:"," ",(0,i.jsx)("span",{style:{color:s.enabled?"green":"red"},children:l.enabled?"Enabled":"Disabled"})]}),(0,i.jsx)(u(),{passHref:!0,href:"/config-federation",children:(0,i.jsx)(o.Z,{type:"primary",style:{position:"relative",marginLeft:"auto",right:"0",marginTop:"20px"},children:"Configure"})})]})};var S=s(37174);let{Title:Z}=a.Z;function E(){let[e,n]=(0,c.useState)(null),s=(0,c.useContext)(h.aC),{serverConfig:a}=s||{},{yp:d}=a,{instanceUrl:p}=d,[x,f]=(0,c.useState)(!1);(0,c.useEffect)(()=>{n({instanceUrl:p})},[d]);let g=()=>{x&&n({...e,enabled:!1})},b=s=>{let{fieldName:i,value:a}=s;f((0,S.jv)(a)),n({...e,[i]:a})},v=""!==p,w=!v&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(l.Z,{message:"You must set your server URL before you can enable this feature.",type:"warning",showIcon:!0}),(0,i.jsx)("br",{}),(0,i.jsx)(k.$7,{fieldName:"instanceUrl",...m.yi,value:(null==e?void 0:e.instanceUrl)||"",initialValue:d.instanceUrl,type:k.xA,onChange:b,onSubmit:g,required:!0})]});return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Z,{children:"Notifications"}),(0,i.jsxs)("p",{className:"description",children:["Let your viewers know when you go live by supporting any of the below notification channels."," ",(0,i.jsx)("a",{href:"https://owncast.online/docs/notifications/?source=admin",target:"_blank",rel:"noopener noreferrer",children:"Learn more about live notifications."})]}),w,(0,i.jsxs)(t.Z,{children:[(0,i.jsx)(r.Z,{span:10,className:"form-module ".concat(v?"":"disabled"),style:{margin:"5px",display:"flex",flexDirection:"column"},children:(0,i.jsx)(y,{})}),(0,i.jsx)(r.Z,{span:10,className:"form-module ".concat(v?"":"disabled"),style:{margin:"5px",display:"flex",flexDirection:"column"},children:(0,i.jsx)(C,{})}),(0,i.jsx)(r.Z,{span:10,className:"form-module ".concat(v?"":"disabled"),style:{margin:"5px",display:"flex",flexDirection:"column"},children:(0,i.jsx)(j,{})}),(0,i.jsx)(r.Z,{span:10,className:"form-module ".concat(v?"":"disabled"),style:{margin:"5px",display:"flex",flexDirection:"column"},children:(0,i.jsx)(T,{})}),(0,i.jsxs)(r.Z,{span:10,className:"form-module ".concat(v?"":"disabled"),style:{margin:"5px",display:"flex",flexDirection:"column"},children:[(0,i.jsx)(Z,{children:"Custom"}),(0,i.jsx)("p",{className:"description",children:"Build your own notifications by using custom webhooks."}),(0,i.jsx)(u(),{passHref:!0,href:"/webhooks",children:(0,i.jsx)(o.Z,{type:"primary",style:{position:"relative",marginLeft:"auto",right:"0",marginTop:"20px"},children:"Create"})})]})]})]})}}},function(e){e.O(0,[4485,7187,9774,2888,179],function(){return e(e.s=7148)}),_N_E=e.O()}]);