Your IP : 216.73.216.43


Current Path : /proc/thread-self/root/snap/lxd/38768/share/lxd-ui/assets/
Upload File :
Current File : //proc/thread-self/root/snap/lxd/38768/share/lxd-ui/assets/WarningList-zvRUNuX9.js

import{d7 as P,R as b,O as C,d as l,v as D,r as g,y as W,j as t,T as N,x as _,bu as w,J as R,aC as x,p as F}from"./index-BsQN_SZU.js";import{H as K}from"./HelpLink-BJF9zWZL.js";import{S as A}from"./SelectableMainTable-DBx4rRiq.js";import{P as p}from"./PageHeader-BkhUaI4-.js";import{s as q,p as k}from"./searchAndFilter-DtC_P-vv.js";const H=async()=>fetch(`${b}/1.0/warnings?recursion=1`).then(C).then(s=>s.metadata),M=async s=>fetch(`${b}/1.0/warnings/${encodeURIComponent(s)}`,{method:"DELETE"}).then(C),B=async s=>Promise.allSettled(s.map(async a=>M(a))).then(P),Q=({warningIds:s,onStart:a,onFinish:i})=>{const c=l.useToastNotification(),n=D(),[r,d]=g.useState(!1),{canEditServerConfiguration:f}=W(),m=f(),y=()=>{d(!0),a?.(),B(s).then(()=>{n.invalidateQueries({queryKey:[_.warnings]}),c.success(t.jsxs(t.Fragment,{children:[N("Warning",s.length)," deleted."]}))}).catch(u=>{c.failure("Warning deletion failed",u)}).finally(()=>{d(!1),i?.()})},o=()=>m?"Delete Warning":"You do not have permission to delete warnings";return t.jsxs(l.ConfirmationButton,{onHoverText:o(),appearance:"default",className:"u-no-margin--bottom has-icon",loading:r,confirmationModalProps:{title:"Confirm delete",children:t.jsxs("p",{children:["This will permanently delete"," ",t.jsxs("strong",{children:[s.length," ",N("warning",s.length)]}),t.jsx("br",{}),"This action cannot be undone, and can result in data loss."]}),onConfirm:y,confirmButtonLabel:"Delete"},disabled:!m||r,shiftClickEnabled:!0,showShiftClickHint:!0,"aria-label":"delete",children:[t.jsx(l.Icon,{name:"delete"}),t.jsxs("span",{children:["Delete ",N("warning",s.length)]})]})},$=["new","acknowledged","resolved"],U=["low","moderate","high"],Y="query",L="status",T="severity",j=[Y,L,T],O=()=>{const[s,a]=w(),i=[{id:1,heading:"Status",chips:$.map(n=>({lead:L,value:n}))},{id:2,heading:"Severity",chips:U.map(n=>({lead:T,value:n}))}],c=n=>{const r=k(n,s,j);r.toString()!==s.toString()&&a(r)};return t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:"u-off-screen",children:"Search and filter"}),t.jsx(l.SearchAndFilter,{existingSearchData:q(s,j),filterPanelData:i,returnSearchData:c,onExpandChange:()=>{window.dispatchEvent(new CustomEvent("resize",{detail:"search-and-filter"}))},onPanelToggle:()=>{window.dispatchEvent(new CustomEvent("sfp-toggle"))}})]})},z=g.memo(O),Z=()=>{const s=l.useNotify(),[a,i]=g.useState([]),[c,n]=g.useState([]),[r]=w(),{data:d=[],error:f,isLoading:m}=R({queryKey:[_.warnings],queryFn:async()=>H(),retry:!1});f&&s.failure("Loading warnings failed",f);const y=m||d.length>0,o={queries:r.getAll("query").map(e=>e.toLowerCase()),statuses:r.getAll("status"),severities:r.getAll("severity")},u=d.filter(e=>!(!o.queries.every(h=>e.type.toLowerCase().includes(h)||e.last_message.toLowerCase().includes(h))||o.statuses.length>0&&!o.statuses.includes(e.status)||o.severities.length>0&&!o.severities.includes(e.severity)));g.useEffect(()=>{const e=new Set(u?.map(S=>S.uuid)),h=a.filter(S=>e.has(S));h.length!==a.length&&i(h)},[u]);const E=[{content:"Type",sortKey:"type",className:"type"},{content:"Last message",sortKey:"lastMessage",className:"last_message"},{content:"Status",sortKey:"status",className:"status"},{content:"Severity",sortKey:"severity",className:"severity"},{content:"Count",sortKey:"count",className:"count u-align--right"},{content:"Project",sortKey:"project",className:"project"},{content:"First seen",sortKey:"firstSeen",className:"first_seen_at"},{content:"Last seen",sortKey:"lastSeen",className:"last_seen_at"}],v=u.map(e=>({key:e.uuid,name:e.uuid,columns:[{content:e.type,role:"rowheader","aria-label":"Type",className:"type"},{content:e.last_message,role:"cell","aria-label":"Last message",className:"last_message"},{content:e.status,role:"cell","aria-label":"Status",className:"status"},{content:e.severity,role:"cell","aria-label":"Severity",className:"severity"},{content:e.count,role:"cell",className:"count u-align--right","aria-label":"Count"},{content:e.project,role:"cell",className:"project u-align--center","aria-label":"Project"},{content:x(e.first_seen_at),role:"cell","aria-label":"First seen",className:"first_seen_at"},{content:x(e.last_seen_at),role:"cell","aria-label":"Last seen",className:"last_seen_at"}],sortData:{type:e.type,lastMessage:e.last_message.toLowerCase(),status:e.status,severity:e.severity,count:e.count,project:e.project.toLowerCase(),firstSeen:e.first_seen_at,lastSeen:e.last_seen_at}}));return t.jsxs(l.CustomLayout,{mainClassName:"images-list",contentClassName:"u-no-padding--bottom",header:t.jsx(p,{children:t.jsxs(p.Left,{children:[t.jsx(p.Title,{children:t.jsx(K,{docPath:"/howto/troubleshoot/",title:"Learn more about troubleshooting",children:"Warnings"})}),y&&a.length===0&&t.jsx(p.Search,{children:t.jsx(z,{},`warning-${r.get("search")}`)}),a.length>0&&t.jsx(Q,{warningIds:a,onStart:()=>{n(a)},onFinish:()=>{n([])}})]})}),children:[t.jsx(F,{}),t.jsx(l.Row,{children:t.jsx(l.ScrollableTable,{dependencies:[u],tableId:"warning-table",belowIds:["status-bar"],children:t.jsx(A,{id:"warning-table",headers:E,rows:v,paginate:30,sortable:!0,className:"warnings-table",emptyStateMsg:m?t.jsx(l.Spinner,{className:"u-loader",text:"Loading warnings..."}):"No data to display",itemName:"warning",parentName:"server",selectedNames:a,setSelectedNames:i,filteredNames:v.map(e=>e.name),disabledNames:c})})})]})};export{Z as default};