"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[9218],{"./public/app/core/components/PageActionBar/PageActionBar.tsx":(e,a,t)=>{t.d(a,{Z:()=>l});var s=t("./node_modules/react/index.js"),n=t("./packages/grafana-ui/src/index.ts"),i=t("./node_modules/react/jsx-runtime.js");class l extends s.PureComponent{render(){const{searchQuery:e,linkButton:a,setSearchQuery:t,target:s,placeholder:l="Search by name or type"}=this.props,r={href:null==a?void 0:a.href,disabled:null==a?void 0:a.disabled};return s&&(r.target=s),(0,i.jsxs)("div",{className:"page-action-bar",children:[(0,i.jsx)("div",{className:"gf-form gf-form--grow",children:(0,i.jsx)(n.FilterInput,{value:e,onChange:t,placeholder:l})}),a&&(0,i.jsx)(n.LinkButton,Object.assign({},r,{children:a.title}))]})}}},"./public/app/features/playlist/PlaylistPage.tsx":(e,a,t)=>{t.r(a),t.d(a,{PlaylistPage:()=>v,default:()=>f});var s=t("./node_modules/react/index.js"),n=t("./node_modules/react-redux/es/index.js"),i=t("./public/app/core/components/Page/Page.tsx"),l=t("./public/app/core/selectors/navModel.ts"),r=t("./node_modules/react-use/esm/useAsync.js"),o=t("./packages/grafana-ui/src/index.ts"),c=t("./public/app/core/services/context_srv.ts"),p=t("./public/app/core/components/PageActionBar/PageActionBar.tsx"),d=t("./public/app/core/components/EmptyListCTA/EmptyListCTA.tsx"),u=t("./public/app/features/playlist/api.ts"),y=t("./packages/grafana-data/src/index.ts"),g=t("./packages/grafana-runtime/src/index.ts"),h=t("./node_modules/react/jsx-runtime.js");const x=({playlist:e,onDismiss:a})=>{const[t,n]=(0,s.useState)(!1),[i,l]=(0,s.useState)(!1);return(0,h.jsxs)(o.Modal,{isOpen:!0,icon:"play",title:"Start playlist",onDismiss:a,children:[(0,h.jsxs)(o.VerticalGroup,{children:[(0,h.jsx)(o.Field,{label:"Mode",children:(0,h.jsx)(o.RadioButtonGroup,{value:t,options:[{label:"Normal",value:!1},{label:"TV",value:"tv"},{label:"Kiosk",value:!0}],onChange:n})}),(0,h.jsx)(o.Checkbox,{label:"Autofit",description:"Panel heights will be adjusted to fit screen size",name:"autofix",value:i,onChange:e=>l(e.currentTarget.checked)})]}),(0,h.jsx)(o.Modal.ButtonRow,{children:(0,h.jsxs)(o.Button,{variant:"primary",onClick:()=>{const a={};t&&(a.kiosk=t),i&&(a.autofitpanels=!0),g.locationService.push(y.urlUtil.renderUrl(`/playlists/play/${e.id}`,a))},children:["Start ",e.name]})})]})};var m;const v=({navModel:e})=>{const[a,t]=(0,s.useState)(""),[n,l]=(0,s.useState)(),[y,g]=(0,s.useState)(),[v,f]=(0,s.useState)(0),{value:b,loading:j}=(0,r.Z)((async()=>(0,u.Dv)(a)),[v]),k=b&&b.length>0;let B=m||(m=(0,h.jsx)(d.Z,{title:"There are no playlists created yet",buttonIcon:"plus",buttonLink:"playlists/new",buttonTitle:"Create Playlist",proTip:"You can use playlists to cycle dashboards on TVs without user control",proTipLink:"http://docs.grafana.org/reference/playlist/",proTipLinkTitle:"Learn more",proTipTarget:"_blank"}));return k&&(B=(0,h.jsx)(h.Fragment,{children:b.map((e=>(0,h.jsx)(o.Card,{heading:e.name,children:(0,h.jsxs)(o.Card.Actions,{children:[(0,h.jsx)(o.Button,{variant:"secondary",icon:"play",onClick:()=>l(e),children:"Start playlist"}),c.Vt.isEditor&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.LinkButton,{variant:"secondary",href:`/playlists/edit/${e.id}`,icon:"cog",children:"Edit playlist"},"edit"),(0,h.jsx)(o.Button,{disabled:!1,onClick:()=>g({id:e.id,name:e.name}),icon:"trash-alt",variant:"destructive",children:"Delete playlist"})]})]})},e.id.toString())))})),(0,h.jsx)(i.Z,{navModel:e,children:(0,h.jsxs)(i.Z.Contents,{isLoading:j,children:[k&&(0,h.jsx)(p.Z,{searchQuery:a,linkButton:{title:"New playlist",href:"/playlists/new"},setSearchQuery:t}),B,y&&(0,h.jsx)(o.ConfirmModal,{title:y.name,confirmText:"Delete",body:`Are you sure you want to delete '${y.name}' playlist?`,onConfirm:()=>{y&&(0,u.l8)(y.id).finally((()=>{f(v+1),g(void 0)}))},isOpen:Boolean(y),onDismiss:()=>g(void 0)}),n&&(0,h.jsx)(x,{playlist:n,onDismiss:()=>l(void 0)})]})})},f=(0,n.connect)((e=>({navModel:(0,l.h)(e.navIndex,"playlists")})))(v)},"./public/app/features/playlist/api.ts":(e,a,t)=>{t.d(a,{cg:()=>r,CE:()=>o,l8:()=>c,A5:()=>p,Dv:()=>d});var s=t("./packages/grafana-runtime/src/index.ts"),n=t("./public/app/store/store.ts"),i=t("./public/app/core/actions/index.ts"),l=t("./public/app/core/copy/appNotification.ts");async function r(e){await u((()=>(0,s.getBackendSrv)().post("/api/playlists",e)))}async function o(e,a){await u((()=>(0,s.getBackendSrv)().put(`/api/playlists/${e}`,a)))}async function c(e){await u((()=>(0,s.getBackendSrv)().delete(`/api/playlists/${e}`)),"Playlist deleted")}async function p(e){return await(0,s.getBackendSrv)().get(`/api/playlists/${e}`)}async function d(e){return await(0,s.getBackendSrv)().get("/api/playlists/",{query:e})}async function u(e,a="Playlist saved"){try{await e(),(0,n.WI)((0,i.$l)((0,l.AT)(a)))}catch(e){(0,n.WI)((0,i.$l)((0,l.t_)("Unable to save playlist",e)))}}}}]);
//# sourceMappingURL=PlaylistPage.8128b05ac04b15cbf98d.js.map