@getontime/cli
Version:
Time keeping for live events
3 lines (2 loc) • 10.4 kB
JavaScript
import{j as e,aX as ee,aY as te,aZ as ae,f as se,a_ as ie,r as d,ad as re,ab as ne,av as le}from"./vendor-DFNUfA2K.js";import{i as Q,ah as oe,ae as j,ar as g,b8 as T,b9 as ce,aq as de,O as x,a9 as ue,ac as he,Y as V,ad as S,af as fe,X as me,a7 as pe,B as ve,_ as be,an as xe,ba as M,bb as H,am as je,ag as ge,al as _e,au as we,bc as Ce}from"./index-BNit4nUw.js";import{I as ke}from"./useWindowTitle-Bgl000Se.js";import{S as Y}from"./Select-Bp_h4xvR.js";import{S as _,u as ye}from"./useProjectData-BfKJevmX.js";import{u as Se}from"./useCustomFields-C60U2vqf.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]="bfc2459c-8b95-489a-9e3c-24b40359a148",s._sentryDebugIdIdentifier="sentry-dbid-bfc2459c-8b95-489a-9e3c-24b40359a148")}catch{}})();const it=/^\d+$/,rt=/^https?:\/\//,nt=/^[a-z0-9]+$/i,Oe=/^[a-zA-Z0-9_-]*$/,Re="_blink_1cc8f_1",Ne="_fourtyfive_1cc8f_13",Ie="_radioGroup_1cc8f_17",$e="_item_1cc8f_23",De="_horizontal_1cc8f_28",Ue="_vertical_1cc8f_35",We="_radio_1cc8f_17",Ee="_indicator_1cc8f_73",I={blink:Re,fourtyfive:Ne,radioGroup:Ie,item:$e,horizontal:De,vertical:Ue,radio:We,indicator:Ee};function X({items:s,className:r,orientation:n="vertical",onValueChange:o,...h}){return e.jsx(ee,{onValueChange:l=>o==null?void 0:o(l),className:Q([I.radioGroup,I[n],r]),...h,children:s.map(l=>e.jsxs("label",{className:I.item,children:[e.jsx(te,{value:l.value.toString(),className:I.radio,children:e.jsx(ae,{className:I.indicator})}),l.label]},l.value.toString()))})}const Z={hideTableSeconds:!1,hidePast:!1,hideIndexColumn:!1,showDelayedTimes:!1,hideDelays:!1},lt=se()(ie(s=>({...Z,setOption:(r,n)=>s(o=>({...o,[r]:n})),toggleOption:r=>s(n=>({...n,[r]:!n[r]})),resetOptions:()=>s(Z)}),{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 ze(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}=Se(),o=d.useMemo(()=>ze(n),[n]),[h,l]=d.useState("full"),[u,$]=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}),z=t=>{l(t),C(i=>{const f={...i};return Object.keys(f).forEach(m=>{f[m]=!0}),f})},F=t=>{t==="full"&&l("full"),$(t),C(i=>{const f={...i};return D(m=>{const k={...m};return[...W,...o].forEach(N=>{f[N.value]=!0,k[N.value]=!0}),k}),f})},c=(t,i,f)=>{i==="read"?C(m=>({...m,[t]:f})):D(m=>({...m,[t]:f}))},p=()=>h==="full"||u==="full"?"full":Object.entries(w).filter(([t,i])=>i).map(([t])=>t).join(","),L=()=>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:p()||"-"}),e.jsx("input",{name:"write",hidden:!0,readOnly:!0,ref:r,value:L()||"-"}),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(X,{value:u,onValueChange:F,orientation:"horizontal",items:[{value:"full",label:"Full write (edit all existing and future columns)"},{value:"custom",label:"Custom write"}]}),e.jsx(X,{value:h,onValueChange:z,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_kmiy6_17",Ge="_column_kmiy6_23",Be="_copiableLink_kmiy6_32",qe="_shareInline_kmiy6_39",Ae="_end_kmiy6_45",O={qrCode:Te,column:Ge,copiableLink:Be,shareInline:qe,end:Ae};function Ve({hostOptions:s,pathOptions:r,presets:n,isLockedToView:o}){var B,q;const[h,l]=d.useState("pending"),[u,$]=d.useState(T),w=d.useRef(null),C=d.useRef(null),R=d.useRef(`cuesheet-${ce()}`),{addPreset:D}=de(),{handleSubmit:z,setError:F,watch:c,setValue:p,reset:L,register:t,formState:{errors:i,isDirty:f}}=re({mode:"onChange",defaultValues:{baseUrl:T,path:o?r[0].value:x.Timer,authenticate:!1,lockConfig:!1,lockNav:!1}}),m=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,P,U;try{if(l("loading"),a.path===x.Cuesheet){const v=await m(a.alias,{read:((y=w.current)==null?void 0:y.value)??"full",write:((P=C.current)==null?void 0:P.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 H(b),$(b)}else{const v=a.path.startsWith("preset-")?a.path.replace("preset-",""):void 0,b=v?(U=n.find(J=>J.alias===v))==null?void 0:U.target:a.path;if(!b)throw new Error(`Could not resolve preset: ${b}`);const A=await M({baseUrl:je(a.baseUrl),path:b,authenticate:a.authenticate,lockConfig:a.lockConfig,lockNav:a.lockNav,preset:v});await H(A),$(A)}L(a,{keepValues:!0,keepDirty:!1}),l("success")}catch(v){const b=ge(v);F("root",{message:b}),l("error")}},N=f||h!=="success";return e.jsxs("form",{onSubmit:z(k),onKeyDown:a=>ue(a),children:[!o&&e.jsx(ke,{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:T}):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(Y,{options:s,value:c("baseUrl"),onValueChange:a=>p("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(Y,{options:r,value:c("path"),onValueChange:a=>p("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:Oe,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",checked:c("lockNav"),onCheckedChange:a=>p("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",checked:c("lockConfig"),onCheckedChange:a=>{a&&p("lockNav",a,{shouldDirty:!0}),p("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",checked:c("authenticate"),onCheckedChange:a=>p("authenticate",a,{shouldDirty:!0})})]})]}),e.jsx(me,{children:(q=i.root)==null?void 0:q.message}),e.jsx(pe,{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}=_e(),{data:n}=we({skip:s===void 0}),o=d.useMemo(()=>r.networkInterfaces.map(l=>({value:l.address,label:`${l.name} - ${l.address}`})),[r.networkInterfaces]),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:"",label:"Companion"},...n.map(l=>({value:`preset-${l.alias}`,label:`URL Preset: ${l.alias}`}))],[s,n]);return e.jsx(Ve,{hostOptions:o,pathOptions:h,presets:n,isLockedToView:!!s})}const Me="_title_g70eo_17",He="_description_g70eo_24",K={title:Me,description:He};function ct(){const{data:s}=ye();return!s.title&&!s.description?null:e.jsxs("div",{children:[e.jsx("div",{className:K.title,children:s.title}),e.jsx("div",{className:K.description,children:s.description})]})}const Ye="_overview_zh5tn_17",Xe="_isOffline_zh5tn_24",Ze="_info_zh5tn_24",Ke="_nav_zh5tn_39",E={overview:Ye,isOffline:Xe,info:Ze,nav:Ke};function dt({navElements:s,children:r}){const{isOnline:n}=Ce();return e.jsx("div",{className:Q([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,X as R,ct as T,nt as a,it as i,rt as s,lt as u};
//# sourceMappingURL=OverviewWrapper-qXI8MQqb.js.map