@getontime/cli
Version:
Time keeping for live events
3 lines (2 loc) • 10.5 kB
JavaScript
import{j as e,aY as ee,aZ as te,a_ as ae,f as se,a$ as ie,h as d,ad as re,ab as ne,ax as le}from"./vendor-q6fv0YT2.js";import{e as J,aj as oe,ag as j,at as g,b9 as z,ba as ce,as as de,O as x,ab as ue,ae as he,Z as V,af as S,ah as fe,Y as pe,a9 as me,B as ve,$ as be,ap as xe,bb as M,bc as Y,ai as je,an as ge,aw as _e,bd as we}from"./index-B81u4hxi.js";import{I as Ce}from"./useWindowTitle-Bpmo_HzW.js";import{S as Z}from"./Select-BGGVCKqU.js";import{S as _}from"./SwatchPicker-Cm5Eicvv.js";import{u as ke}from"./useCustomFields-k4piRt9n.js";import{u as ye}from"./useProjectData-DdgKoYzk.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new s.Error().stack;r&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[r]="a41ccdcd-b2fb-41f5-9d09-f738d8aa9665",s._sentryDebugIdIdentifier="sentry-dbid-a41ccdcd-b2fb-41f5-9d09-f738d8aa9665")}catch{}})();const it=/^\d+$/,rt=/^https?:\/\//,nt=/^[a-z0-9]+$/i,Se=/^[a-zA-Z0-9_-]*$/,Oe="_blink_1cc8f_1",Re="_fourtyfive_1cc8f_13",Ne="_radioGroup_1cc8f_17",$e="_item_1cc8f_23",Ie="_horizontal_1cc8f_28",De="_vertical_1cc8f_35",Ue="_radio_1cc8f_17",We="_indicator_1cc8f_73",$={blink:Oe,fourtyfive:Re,radioGroup:Ne,item:$e,horizontal:Ie,vertical:De,radio:Ue,indicator:We};function H({items:s,className:r,orientation:n="vertical",onValueChange:o,...h}){return e.jsx(ee,{onValueChange:l=>o==null?void 0:o(l),className:J([$.radioGroup,$[n],r]),...h,children:s.map(l=>e.jsxs("label",{className:$.item,children:[e.jsx(te,{value:l.value.toString(),className:$.radio,children:e.jsx(ae,{className:$.indicator})}),l.label]},l.value.toString()))})}const K={hideTableSeconds:!1,hideIndexColumn:!1,showDelayedTimes:!1,hideDelays:!1},lt=se()(ie(s=>({...K,setOption:(r,n)=>s(o=>({...o,[r]:n})),toggleOption:r=>s(n=>({...n,[r]:!n[r]})),resetOptions:()=>s(K)}),{name:"cuesheet-options"})),W=[{value:"flag",label:"Flag"},{value:"cue",label:"Cue"},{value:"title",label:"Title"},{value:"timeStart",label:"Time start"},{value:"timeEnd",label:"Time end"},{value:"duration",label:"Duration"},{value:"note",label:"Note"}];function Ee(s){return Object.entries(s).map(([r,n])=>({value:`custom-${r}`,label:n.label}))}const Fe="_twoCols_1wch9_17",Le="_grid_1wch9_23",G={twoCols:Fe,grid:Le};function Pe({readRef:s,writeRef:r}){const{data:n}=ke(),o=d.useMemo(()=>Ee(n),[n]),[h,l]=d.useState("full"),[u,I]=d.useState("full"),[w,C]=d.useState(()=>{const t={};return[...W,...o].forEach(i=>{t[i.value]=!0}),t}),[R,D]=d.useState(()=>{const t={};return[...W,...o].forEach(i=>{t[i.value]=!0}),t}),F=t=>{l(t),C(i=>{const f={...i};return Object.keys(f).forEach(p=>{f[p]=!0}),f})},L=t=>{t==="full"&&l("full"),I(t),C(i=>{const f={...i};return D(p=>{const k={...p};return[...W,...o].forEach(N=>{f[N.value]=!0,k[N.value]=!0}),k}),f})},c=(t,i,f)=>{i==="read"?C(p=>({...p,[t]:f})):D(p=>({...p,[t]:f}))},m=()=>h==="full"||u==="full"?"full":Object.entries(w).filter(([t,i])=>i).map(([t])=>t).join(","),P=()=>u==="full"?"full":Object.entries(R).filter(([t,i])=>i).map(([t])=>t).join(",");return e.jsxs(oe,{children:[e.jsx("input",{name:"read",hidden:!0,readOnly:!0,ref:s,value:m()||"-"}),e.jsx("input",{name:"write",hidden:!0,readOnly:!0,ref:r,value:P()||"-"}),e.jsxs("div",{children:[e.jsx(j,{title:"Access mode",description:"Which parts of the data will the link give access to"}),e.jsxs("div",{children:[e.jsx(H,{value:u,onValueChange:L,orientation:"horizontal",items:[{value:"full",label:"Full write (edit all existing and future columns)"},{value:"custom",label:"Custom write"}]}),e.jsx(H,{value:h,onValueChange:F,orientation:"horizontal",disabled:u==="full",items:[{value:"full",label:"Full read (view all existing and future columns)"},{value:"custom",label:"Custom read"}]})]})]}),e.jsxs("div",{className:G.twoCols,children:[e.jsxs("div",{className:G.grid,children:[e.jsx(g,{children:"Ontime columns"}),e.jsx(g,{children:"Read"}),e.jsx(g,{children:"Write"}),W.map(t=>e.jsxs(d.Fragment,{children:[e.jsx("div",{children:t.label}),e.jsx(_,{checked:!!w[t.value],onCheckedChange:i=>c(t.value,"read",i),disabled:h==="full"||u==="full","data-testid":`read-${t.value}`}),e.jsx(_,{checked:!!R[t.value],onCheckedChange:i=>c(t.value,"write",i),disabled:u==="full","data-testid":`write-${t.value}`})]},t.value))]}),o.length>0&&e.jsxs("div",{className:G.grid,children:[e.jsx(g,{children:"Custom fields"}),e.jsx(g,{children:"Read"}),e.jsx(g,{children:"Write"}),o.map(t=>e.jsxs(d.Fragment,{children:[t.label,e.jsx(_,{checked:!!w[t.value],onCheckedChange:i=>c(t.value,"read",i),disabled:h==="full"||u==="full","data-testid":`read-${t.value}`}),e.jsx(_,{checked:!!R[t.value],onCheckedChange:i=>c(t.value,"write",i),disabled:u==="full","data-testid":`write-${t.value}`})]},t.value))]})]})]})}const Te="_qrCode_1989f_17",ze="_column_1989f_23",Ge="_copiableLink_1989f_32",Be="_shareInline_1989f_39",Ae="_end_1989f_45",O={qrCode:Te,column:ze,copiableLink:Ge,shareInline:Be,end:Ae};function qe({hostOptions:s,pathOptions:r,presets:n,isLockedToView:o}){var B,A;const[h,l]=d.useState("pending"),[u,I]=d.useState(z),w=d.useRef(null),C=d.useRef(null),R=d.useRef(`cuesheet-${ce()}`),{addPreset:D}=de(),{handleSubmit:F,setError:L,watch:c,setValue:m,reset:P,register:t,formState:{errors:i,isDirty:f}}=re({mode:"onChange",defaultValues:{baseUrl:z,path:o?r[0].value:x.Timer,authenticate:!1,lockConfig:!1,lockNav:!1}}),p=async(a,y)=>{if(y.read==="-")throw new Error("Cannot create a share with no read permissions");return(await D({target:x.Cuesheet,enabled:!0,alias:a,search:"",options:{read:y.read,write:y.write}})).find(U=>U.alias===a)},k=async a=>{var y,T,U;try{if(l("loading"),a.path===x.Cuesheet){const v=await p(a.alias,{read:((y=w.current)==null?void 0:y.value)??"full",write:((T=C.current)==null?void 0:T.value)??"full"});if(!v)throw new Error("Failed to create URL preset for Cuesheet");const b=await M({baseUrl:a.baseUrl,path:a.path,authenticate:a.authenticate,lockConfig:a.lockConfig,lockNav:a.lockNav,preset:v.alias});await Y(b),I(b)}else{const v=a.path.startsWith("preset-")?a.path.replace("preset-",""):void 0,b=v?(U=n.find(X=>X.alias===v))==null?void 0:U.target:a.path;if(!b)throw new Error(`Could not resolve preset: ${b}`);const q=await M({baseUrl:a.baseUrl,path:b,authenticate:a.authenticate,lockConfig:a.lockConfig,lockNav:a.lockNav,preset:v});await Y(q),I(q)}P(a,{keepValues:!0,keepDirty:!1}),l("success")}catch(v){const b=je(v);L("root",{message:b}),l("error")}},N=f||h!=="success";return e.jsxs("form",{onSubmit:F(k),onKeyDown:a=>ue(a),children:[!o&&e.jsx(Ce,{children:"You can generate a link to share with your team or to use in automation (such as companion)."}),e.jsxs("div",{className:O.shareInline,children:[e.jsxs("div",{className:O.column,children:[e.jsxs(he,{children:[V?e.jsx("input",{hidden:!0,readOnly:!0,name:"baseUrl",value:z}):e.jsxs(S,{children:[e.jsx(j,{title:"Host IP",description:`Which IP address will be used${V?" (not applicable in Ontime Cloud)":""}`}),e.jsx(Z,{options:s,value:c("baseUrl"),onValueChange:a=>{a!==null&&m("baseUrl",a)}})]}),o?e.jsx("input",{type:"hidden",value:c("path")}):e.jsxs(S,{children:[e.jsx(j,{title:"Ontime view",description:"Which view or preset will the link point to"}),e.jsx(Z,{options:r,value:c("path"),onValueChange:a=>{a!==null&&m("path",a,{shouldDirty:!0})}})]}),c("path")===x.Cuesheet&&e.jsxs(e.Fragment,{children:[e.jsxs(S,{children:[e.jsx(j,{title:"Preset alias",description:"The name of the preset we will create to hold this options",error:(B=i.alias)==null?void 0:B.message}),e.jsx(fe,{defaultValue:R.current,...t("alias",{required:"Alias cannot be empty and must be unique",pattern:{value:Se,message:"Field can only contain URL safe characters (a-z, 0-9, _ and -)"}})})]}),e.jsx(Pe,{readRef:w,writeRef:C})]}),e.jsxs(S,{children:[e.jsx(j,{title:"Lock navigation",description:"Whether to hide the navigation menu"}),e.jsx(_,{size:"large",name:"lockNav","data-testid":"lockNav",checked:c("lockNav"),onCheckedChange:a=>m("lockNav",a,{shouldDirty:!0}),disabled:c("lockConfig")})]}),c("path")!==x.Cuesheet&&e.jsxs(S,{children:[e.jsx(j,{title:"Lock configuration",description:"Whether to hide the configuration panel (also hides navigation)"}),e.jsx(_,{size:"large",name:"lockConfig","data-testid":"lockConfig",checked:c("lockConfig"),onCheckedChange:a=>{a&&m("lockNav",a,{shouldDirty:!0}),m("lockConfig",a,{shouldDirty:!0})}})]}),e.jsxs(S,{children:[e.jsx(j,{title:"Authenticate",description:"Whether the URL should be pre-authenticated"}),e.jsx(_,{size:"large",name:"authenticate","data-testid":"authenticate",checked:c("authenticate"),onCheckedChange:a=>m("authenticate",a,{shouldDirty:!0})})]})]}),e.jsx(pe,{children:(A=i.root)==null?void 0:A.message}),e.jsx(me,{align:"end",className:O.end,children:e.jsx(ve,{type:"submit",variant:N?"primary":"subtle",loading:h==="loading",children:N?"Create share link":"Link copied to clipboard!"})})]}),e.jsxs(be,{className:O.column,children:[e.jsx(g,{children:"Share this link"}),e.jsx(ne,{size:172,value:u,className:O.qrCode}),e.jsx("div",{className:O.copiableLink,"data-testid":"copy-link",children:u}),e.jsx(xe,{copyValue:u,children:"Copy link"})]})]})]})}function ot({lockedPath:s}){const{data:r}=ge(),{data:n}=_e({skip:s===void 0}),o=d.useMemo(()=>r.networkInterfaces.map(l=>({value:`http://${l.address}:${r.serverPort}`,label:`${l.name} - ${l.address}`})),[r.networkInterfaces,r.serverPort]),h=d.useMemo(()=>s?[{value:s.value,label:s.label}]:[{value:x.Timer,label:"Timer"},{value:x.Cuesheet,label:"Cuesheet"},{value:x.Operator,label:"Operator"},{value:"<<companion>>",label:"Companion"},...n.map(l=>({value:`preset-${l.alias}`,label:`URL Preset: ${l.alias}`}))],[s,n]);return e.jsx(qe,{hostOptions:o,pathOptions:h,presets:n,isLockedToView:!!s})}const Ve="_title_1kaxc_17",Me="_description_1kaxc_27",Q={title:Ve,description:Me};function ct(){const{data:s}=ye();return!s.title&&!s.description?null:e.jsxs("div",{children:[e.jsx("div",{className:Q.title,children:s.title}),e.jsx("div",{className:Q.description,children:s.description})]})}const Ye="_overview_1p0vh_17",Ze="_isOffline_1p0vh_24",He="_info_1p0vh_24",Ke="_nav_1p0vh_39",E={overview:Ye,isOffline:Ze,info:He,nav:Ke};function dt({navElements:s,children:r}){const{isOnline:n}=we();return e.jsx("div",{className:J([E.overview,!n&&E.isOffline]),children:e.jsxs(le,{children:[e.jsx("div",{className:E.nav,children:s}),e.jsx("div",{className:E.info,children:r})]})})}export{ot as G,dt as O,H as R,ct as T,Se as a,nt as b,it as i,rt as s,lt as u};
//# sourceMappingURL=OverviewWrapper-BQb2xl_N.js.map