1 line
6.9 KiB
JavaScript
Vendored
1 line
6.9 KiB
JavaScript
Vendored
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5685],{97183:function(e,t,n){"use strict";var r=n(2897),l=n(7293),o=r.ZP;o.Header=r.h4,o.Footer=r.$_,o.Content=r.VY,o.Sider=l.Z,t.Z=o},93645:function(e,t,n){"use strict";n.d(t,{u:function(){return l}});var r={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(e){return e<0?Math.ceil(e):Math.floor(e)}};function l(e){return e?r[e]:r.trunc}},59910:function(e,t,n){"use strict";n.d(t,{Z:function(){return o}});var r=n(19013),l=n(13882);function o(e,t){return(0,l.Z)(2,arguments),(0,r.Z)(e).getTime()-(0,r.Z)(t).getTime()}},11699:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var r=n(59910),l=n(13882),o=n(93645);function a(e,t,n){(0,l.Z)(2,arguments);var a=(0,r.Z)(e,t)/1e3;return(0,o.u)(null==n?void 0:n.roundingMethod)(a)}},54005:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/actions",function(){return n(93870)}])},93870:function(e,t,n){"use strict";n.r(t);var r=n(85893),l=n(85818),o=n(85402),a=n(79292),i=n(34041),c=n(79531),u=n(32808),s=n(26713),d=n(71577),h=n(54398),p=n(68344),x=n(58909),m=n(13804),f=n(5152),j=n.n(f),v=n(67294),y=n(57520),g=n(24044),Z=n(91332),k=n(38631),b=n(53899),w=n(34261);let{Title:C,Paragraph:I}=l.Z,S=j()(()=>Promise.all([n.e(2074),n.e(7949)]).then(n.t.bind(n,77949,23)),{loadableGenerated:{webpack:()=>[77949]},ssr:!1}),E=j()(()=>Promise.all([n.e(2074),n.e(775)]).then(n.t.bind(n,10775,23)),{loadableGenerated:{webpack:()=>[10775]},ssr:!1}),T=e=>{let{onOk:t,onCancel:n,open:l,action:s}=e,[d,h]=(0,v.useState)("url"),[f,j]=(0,v.useState)(""),[y,g]=(0,v.useState)(""),[Z,k]=(0,v.useState)(""),[w,C]=(0,v.useState)(""),[I,S]=(0,v.useState)(""),[E,T]=(0,v.useState)(""),[_,O]=(0,v.useState)(!1);(0,v.useEffect)(()=>{var e;h(((null==s?void 0:null===(e=s.html)||void 0===e?void 0:e.length)||0)>0?"html":"url"),j((null==s?void 0:s.url)||""),g((null==s?void 0:s.html)||""),k((null==s?void 0:s.title)||""),C((null==s?void 0:s.description)||""),S((null==s?void 0:s.icon)||""),T((null==s?void 0:s.color)||""),O((null==s?void 0:s.openExternally)||!1)},[s]);let L={disabled:!("html"===d?""!==y&&""!==Z:(0,b.jv)(f,["https:"])&&""!==Z)},M=e=>{O(e.target.checked)},N=e=>{g(e)};return(0,r.jsx)(o.Z,{destroyOnClose:!0,title:null==s?"Create New Action":"Edit Action",open:l,onOk:function(){t(s,e.index,"html"===d?"":f,"html"===d?y:"",Z,w,I,E,_),j(""),g(""),k(""),C(""),S(""),T(""),O(!1)},onCancel:n,okButtonProps:L,children:(0,r.jsxs)(a.Z,{initialValues:s,children:["Add the URL for the external action you want to present."," ",(0,r.jsx)("strong",{children:"Only HTTPS URLs and embeds are supported."}),(0,r.jsx)("p",{children:(0,r.jsx)("a",{href:"https://owncast.online/thirdparty/actions/",target:"_blank",rel:"noopener noreferrer",children:"Read more about external actions."})}),(0,r.jsx)(a.Z.Item,{children:(0,r.jsx)(i.Z,{value:d,onChange:h,placeholder:"Select an action type",options:[{label:"Link or embed an URL",value:"url"},{label:"Custom HTML",value:"html"}]})}),"html"===d?(0,r.jsx)(a.Z.Item,{name:"html",children:(0,r.jsx)(p.ZP,{value:y,placeholder:"HTML embed code (required)",theme:x.FZ,height:"200px",extensions:[(0,m.html)()],onChange:N})}):(0,r.jsx)(a.Z.Item,{name:"url",children:(0,r.jsx)(c.Z,{required:!0,placeholder:"https://myserver.com/action (required)",onChange:e=>j(e.currentTarget.value.trim()),type:"url",pattern:b.ax})}),(0,r.jsx)(a.Z.Item,{name:"title",children:(0,r.jsx)(c.Z,{value:Z,required:!0,placeholder:"Your action title (required)",onChange:e=>k(e.currentTarget.value)})}),(0,r.jsx)(a.Z.Item,{name:"description",children:(0,r.jsx)(c.Z,{value:w,placeholder:"Optional description",onChange:e=>C(e.currentTarget.value)})}),(0,r.jsx)(a.Z.Item,{name:"icon",children:(0,r.jsx)(c.Z,{value:I,placeholder:"https://myserver.com/action/icon.png (optional)",onChange:e=>S(e.currentTarget.value)})}),(0,r.jsxs)("div",{children:[(0,r.jsx)(a.Z.Item,{name:"color",style:{marginBottom:"0px"},children:(0,r.jsx)(c.Z,{type:"color",value:E,onChange:e=>T(e.currentTarget.value)})}),"Optional background color of the action button."]}),"html"===d?null:(0,r.jsx)(a.Z.Item,{name:"openExternally",children:(0,r.jsx)(u.Z,{checked:_,defaultChecked:_,onChange:M,children:"Open in a new tab instead of within your page."})})]})})},_=()=>{let e=(0,v.useContext)(k.a),{serverConfig:t,setFieldInConfigState:n}=e||{},{externalActions:l}=t,[o,a]=(0,v.useState)(null),[i,c]=(0,v.useState)(!1),[u,p]=(0,v.useState)(null),[x,m]=(0,v.useState)(null),[f,j]=(0,v.useState)(-1),b=()=>{p(null),clearTimeout(null)};async function w(e){await (0,g.Si)({apiPath:g.os,data:{value:e},onSuccess:()=>{n({fieldName:"externalActions",value:e,path:""}),p((0,Z.kg)(Z.zv,"Updated.")),setTimeout(b,g.sI)},onError:e=>{console.log(e),p((0,Z.kg)(Z.Un,e)),setTimeout(b,g.sI)}})}async function _(e){let t=[...o];t.splice(e,1);try{a(t),w(t)}catch(e){console.error(e)}}async function O(e,t,n,r,l,i,c,u,s){try{let e=[...o],d={url:n,html:r,title:l,description:i,icon:c,color:u,openExternally:s};t>=0?e[t]=d:e.push(d),a(e),await w(e)}catch(e){console.error(e)}}async function L(e,t){j(t),m(e),c(!0)}(0,v.useEffect)(()=>{a(l||[])},[l]);let M=()=>{m(null),j(-1),c(!0)},N=(e,t,n,r,l,o,a,i,u)=>{c(!1),O(e,t,n,r,l,o,a,i,u),m(null),j(-1)},P=()=>{c(!1)};return(0,r.jsxs)("div",{children:[(0,r.jsx)(C,{children:"External Actions"}),(0,r.jsx)(I,{children:"External action URLs are 3rd party UI you can display, embedded, into your Owncast page when a user clicks on a button to launch your action."}),(0,r.jsxs)(I,{children:["Read more about how to use actions, with examples, at"," ",(0,r.jsx)("a",{href:"https://owncast.online/thirdparty/?source=admin",target:"_blank",rel:"noopener noreferrer",children:"our documentation"}),"."]}),(0,r.jsx)(h.Z,{rowKey:e=>"".concat(e.title,"-").concat(e.url),columns:[{title:"",key:"delete-edit",render:(e,t,n)=>(0,r.jsxs)(s.Z,{size:"middle",children:[(0,r.jsx)(d.Z,{onClick:()=>_(n),icon:(0,r.jsx)(S,{})}),(0,r.jsx)(d.Z,{onClick:()=>L(t,n),icon:(0,r.jsx)(E,{})})]})},{title:"Name",dataIndex:"title",key:"title"},{title:"Description",dataIndex:"description",key:"description"},{title:"URL / Embed",key:"url",dataIndex:"url",render:(e,t)=>t.html?"HTML embed":t.url},{title:"Icon",dataIndex:"icon",key:"icon",render:e=>e?(0,r.jsx)("img",{style:{width:"2vw"},src:e,alt:""}):null},{title:"Color",dataIndex:"color",key:"color",render:e=>e?(0,r.jsx)("div",{style:{backgroundColor:e,height:"30px"},children:e}):null},{title:"Opens",key:"openExternally",dataIndex:"openExternally",render:(e,t)=>!e||t.html?"In the same tab":"In a new tab"}],dataSource:o,pagination:!1}),(0,r.jsx)("br",{}),(0,r.jsx)(d.Z,{type:"primary",onClick:M,children:"Create New Action"}),(0,r.jsx)(y.E,{status:u}),(0,r.jsx)(T,{action:x,index:f,open:i,onOk:N,onCancel:P})]})};_.getLayout=function(e){return(0,r.jsx)(w.l,{page:e})},t.default=_},11163:function(e,t,n){e.exports=n(96885)}},function(e){e.O(0,[5762,173,5874,9151,2414,4931,5402,5257,1664,8014,5818,9915,4041,3698,3013,4398,7543,4261,9774,2888,179],function(){return e(e.s=54005)}),_N_E=e.O()}]); |