PageSourceSearch

https://school-pilot.net/assets/EmailMonitoringSetup-DmnMuCM6.js

js school-pilot.net collected 2026-10-02 02:02:26 UTC 11,404 bytes, 1 lines download raw bytes

1import{b as W,d as j,j as e}from"./vendor-query-De67fZpb.js";import{c as q,p as _,y as K,e as Q,B as i,a as m,q as S}from"./index-BVa9LpK6.js";import{r as g}from"./vendor-react-DmHq5u7o.js";import{C as x,a as h,b as u,c,d as f}from"./card-cQS3_R5c.js";import{I as E}from"./input-CN76rOJZ.js";import{L as M}from"./label-Y6iYmX2a.js";import{B as H}from"./badge-BCiz6oPt.js";import{M as U}from"./mail-DohG3vEm.js";import{A as b}from"./arrow-left-BIPGBPce.js";import{T as A}from"./triangle-alert-DHZjnt5o.js";import{C as Y}from"./circle-check-CNz43yCu.js";import{R as J}from"./refresh-cw-CysRRe52.js";import{A as O}from"./arrow-right-kGHh1R8_.js";import{C as R}from"./copy-CNEl5Vxb.js";import{E as X}from"./external-link-s9F_gxNZ.js";import{S as Z}from"./shield-check-Unetnfmi.js";import"./vendor-radix-BC8qFHVc.js";import"./vendor-charts-BgnIT9fy.js";const I={name:"power-off",size:24,node:[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]};I.node;const ee=q(I);const B={name:"power",size:24,node:[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]};B.node;const se=q(B);function ye(){const d=_(),{navigate:o}=K(),{toast:t}=Q(),[l,a]=g.useState(1),[v,$]=g.useState(""),[n,P]=g.useState(null),{data:r,isLoading:V,error:y,refetch:D}=W({queryKey:["/api/mailpilot/setup/info"],queryFn:()=>m("GET","/mailpilot/setup/info")});g.useEffect(()=>{y?.response?.status===403&&o("/classpilot/admin",{replace:!0})},[y,o]);const N=j({mutationFn:s=>m("POST","/mailpilot/setup/verify",{testEmail:s}),onSuccess:s=>{P({ok:!0,data:s}),t({title:"Verification succeeded",description:`Service account can read ${s.email}'s mailbox.`})},onError:s=>{const p=s?.response?.data||{};P({ok:!1,error:p.error||s?.message,detail:p.detail})}}),w=j({mutationFn:()=>m("POST","/mailpilot/setup/enable",{}),onSuccess:s=>{S.invalidateQueries({queryKey:["/api/mailpilot/setup/info"]}),t({title:"Email monitoring enabled",description:`Started watches on ${s.watchesStarted} mailbox${s.watchesStarted===1?"":"es"}${s.failed?` • ${s.failed} failed`:""}`}),D()},onError:s=>{t({variant:"destructive",title:"Enable failed",description:s?.message||""})}}),T=j({mutationFn:()=>m("POST","/mailpilot/setup/disable",{}),onSuccess:()=>{S.invalidateQueries({queryKey:["/api/mailpilot/setup/info"]}),t({title:"Monitoring disabled"}),D()},onError:s=>{t({variant:"destructive",title:"Disable failed",description:s?.message||""})}}),z=j({mutationFn:()=>m("POST","/mailpilot/setup/resync",{}),onSuccess:s=>{S.invalidateQueries({queryKey:["/api/mailpilot/setup/info"]}),t({title:"Resync complete",description:`Added ${s.added}, removed ${s.removed}`})},onError:s=>{t({variant:"destructive",title:"Resync failed",description:s?.message||""})}});if(V||y?.response?.status===403)return e.jsx("div",{className:"p-8 text-muted-foreground",children:"Loading…"});const k=r?.serviceAccountClientId,C=r?.scope,F=r?.configured===!0,L=r?.enabled===!0,G=(s,p)=>{navigator.clipboard.writeText(s).then(()=>{t({title:"Copied",description:p})})};return e.jsxs("div",{className:"container mx-auto p-6 max-w-3xl space-y-6",children:[!d&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-lg bg-primary flex items-center justify-center",children:e.jsx(U,{className:"h-6 w-6 text-primary-foreground"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold",children:"Email Monitoring Setup"}),e.jsx("p",{className:"text-muted-foreground",children:"One-time Google Workspace authorization"})]})]}),e.jsxs(i,{variant:"outline",onClick:()=>o("/classpilot/admin/email-monitoring"),children:[e.jsx(b,{className:"h-4 w-4 mr-2"})," Back"]})]}),d&&e.jsxs(i,{variant:"outline",onClick:()=>o("/classpilot/admin/email-monitoring"),children:[e.jsx(b,{className:"mr-2 size-4"}),"Back to Email monitoring"]}),!F&&e.jsxs(x,{className:"border-amber-300 bg-amber-50 dark:bg-amber-950/20",children:[e.jsx(h,{children:e.jsxs(u,{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5 text-amber-600"}),"Service not configured"]})}),e.jsx(c,{children:"The SchoolPilot server is missing MailPilot service-account credentials. Contact support before proceeding."})]}),L?e.jsxs(x,{children:[e.jsxs(h,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-5 w-5 text-green-600"}),e.jsx(u,{children:"Monitoring is active"})]}),e.jsxs(f,{children:[r.mailboxesMonitored," active mailbox",r.mailboxesMonitored===1?"":"es",r.mailboxesWithErrors?` • ${r.mailboxesWithErrors} with errors`:""]})]}),e.jsxs(c,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(i,{onClick:()=>z.mutate(),disabled:z.isPending,children:[e.jsx(J,{className:"h-4 w-4 mr-2"}),"Resync with roster"]}),e.jsxs(i,{variant:"destructive",onClick:()=>T.mutate(),disabled:T.isPending,children:[e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Disable monitoring"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Resync adds watches for newly-added students and stops watches for removed students. Disable halts all monitoring and stops every active Gmail watch — you can re-enable later."})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ie,{step:l}),l===1&&e.jsxs(x,{children:[e.jsxs(h,{children:[e.jsx(u,{children:"Before you begin"}),e.jsx(f,{children:"Understand what will be scanned and who gets alerted."})]}),e.jsxs(c,{className:"space-y-3 text-sm",children:[e.jsx("p",{children:"Email monitoring scans every student's inbound and outbound Gmail for AI-detected safety concerns:"}),e.jsxs("ul",{className:"list-disc pl-6 space-y-1",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Self-harm"})," — suicidal ideation, self-injury, hopelessness"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Violence"})," — threats of violence, weapons, graphic content"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Sexual content"})," — explicit material, grooming, sexting"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Drugs"})," — drug use, acquisition, distribution"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Bullying / harassment"})," — targeted insults, exclusion campaigns"]})]}),e.jsx("p",{children:"Alerts are sent by email to all active admins and school admins at your school, and appear in the Email Monitoring dashboard for review."}),e.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 dark:bg-amber-950/20 p-3",children:[e.jsx(A,{className:"inline-block h-4 w-4 mr-1 text-amber-700"}),e.jsx("strong",{children:"Not scanned:"})," staff accounts, Gmail drafts, Google Docs/Drive, attachments. Most states require disclosing student monitoring to parents — review your policy before enabling."]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:["You must be a ",e.jsx("strong",{children:"Google Worksp
1ace super administrator"})," for your organization to complete the next step."]})]}),e.jsx(c,{children:e.jsxs(i,{onClick:()=>a(2),children:["Continue ",e.jsx(O,{className:"h-4 w-4 ml-2"})]})})]}),l===2&&e.jsxs(x,{children:[e.jsxs(h,{children:[e.jsx(u,{children:"Authorize MailPilot in Google Workspace"}),e.jsx(f,{children:"Paste these two values into Google Admin Console."})]}),e.jsxs(c,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(M,{children:"Service account Client ID"}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(E,{readOnly:!0,value:k||"",className:"font-mono text-sm"}),e.jsx(i,{variant:"outline",size:"icon",onClick:()=>k&&G(k,"Client ID copied"),children:e.jsx(R,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx(M,{children:"OAuth scope"}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(E,{readOnly:!0,value:C||"",className:"font-mono text-sm"}),e.jsx(i,{variant:"outline",size:"icon",onClick:()=>C&&G(C,"Scope copied"),children:e.jsx(R,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 space-y-2 text-sm",children:[e.jsx("p",{className:"font-medium",children:"Steps in Google Admin Console:"}),e.jsxs("ol",{className:"list-decimal pl-5 space-y-1",children:[e.jsxs("li",{children:["Open ",e.jsxs("a",{className:"underline",href:"https://admin.google.com",target:"_blank",rel:"noreferrer",children:["admin.google.com ",e.jsx(X,{className:"inline h-3 w-3"})]})]}),e.jsxs("li",{children:["Go to ",e.jsx("strong",{children:"Security → Access and data control → API controls"})]}),e.jsxs("li",{children:["Click ",e.jsx("strong",{children:"Manage Domain Wide Delegation"})]}),e.jsxs("li",{children:["Click ",e.jsx("strong",{children:"Add new"})]}),e.jsx("li",{children:"Paste the Client ID and OAuth scope above"}),e.jsxs("li",{children:["Click ",e.jsx("strong",{children:"Authorize"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(i,{variant:"outline",onClick:()=>a(1),children:[e.jsx(b,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs(i,{onClick:()=>a(3),children:["I've authorized — continue ",e.jsx(O,{className:"h-4 w-4 ml-2"})]})]})]})]}),l===3&&e.jsxs(x,{children:[e.jsxs(h,{children:[e.jsx(u,{children:"Verify and enable"}),e.jsx(f,{children:"Test your authorization, then enable monitoring for all students."})]}),e.jsxs(c,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(M,{htmlFor:"testEmail",children:"Test with a student email address"}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsx(E,{id:"testEmail",type:"email",placeholder:"[email protected]",value:v,onChange:s=>$(s.target.value)}),e.jsx(i,{onClick:()=>N.mutate(v),disabled:!v||N.isPending,children:N.isPending?"Verifying…":"Verify"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Uses the authorized service account to read one student's Gmail profile. No data is stored."})]}),n?.ok&&e.jsxs("div",{className:"rounded-md border border-green-300 bg-green-50 dark:bg-green-950/20 p-3 text-sm",children:[e.jsx(Z,{className:"inline h-4 w-4 mr-1 text-green-700"}),"Verified: service account can access ",e.jsx("strong",{children:n.data.email}),"."]}),n?.ok===!1&&e.jsxs("div",{className:"rounded-md border border-red-300 bg-red-50 dark:bg-red-950/20 p-3 text-sm",children:[e.jsx(A,{className:"inline h-4 w-4 mr-1 text-red-700"}),n.error,n.detail&&e.jsx("pre",{className:"mt-2 text-xs whitespace-pre-wrap",children:n.detail})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(i,{variant:"outline",onClick:()=>a(2),children:[e.jsx(b,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs(i,{onClick:()=>w.mutate(),disabled:!n?.ok||w.isPending,children:[e.jsx(se,{className:"h-4 w-4 mr-2"}),w.isPending?"Starting watches…":"Enable monitoring"]})]}),!n?.ok&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Run a successful verification first."})]})]})]})]})}function ie({step:d}){const o=["Overview","Authorize","Verify & Enable"];return e.jsx("div",{className:"flex items-center gap-2",children:o.map((t,l)=>{const a=l+1;return e.jsxs("div",{className:"flex items-center",children:[e.jsxs(H,{variant:a===d?"default":a<d?"secondary":"outline",children:[a,". ",t]}),a<o.length&&e.jsx("div",{className:"w-4 h-px bg-border mx-1"})]},t)})})}export{ye as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.