PageSourceSearch

https://www.tsada.edu.rs/assets/SendNotification-BtOOGYMY.js

js tsada.edu.rs collected 2026-10-05 23:39:08 UTC 12,328 bytes, 1 lines download raw bytes

1import{d as j,r as _,c as $,o as q,q as r,y as d,C as t,E as s,a8 as D,J as c,a9 as m,ao as B,ap as H,I as v,F as I,N,u as U}from"./vendor-vue-y_2z1IZ8.js";import{u as F}from"./vendor-i18n-BUEuSNw2.js";import{E as M}from"./vendor-ui-extras-BWBFfKt4.js";import{Q as g,D as T}from"./vendor-appwrite-BOs4F4m5.js";import{c as n,b as E,_ as A}from"./index-0cjCJZsv.js";import{v as f}from"./vendor-misc-CHtuvIjj.js";import"./vendor-dexie-REAOjB_1.js";import"./vendor-vuetify-BDn3RT1a.js";import"./vendor-axios-oM-kPufh.js";import"./vendor-video-Cit8kvcb.js";import"./vendor-swiper-Dv14htd7.js";import"./vendor-primevue-CCnmf-yE.js";/* empty css                   */const O={class:"send-notification-page page-shell py-8 px-4"},L={class:"page-panel container max-w-4xl admin-dark-form"},Q={class:"page-header"},J={class:"section-title"},R={class:"page-subtitle"},G={class:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-8"},K={class:"stat-card glass-card p-6 rounded-2xl"},P={class:"flex items-center gap-4"},W={class:"text-gray-500 dark:text-gray-400 text-sm"},X={class:"text-gray-900 dark:text-white text-2xl font-bold"},Y={class:"stat-card glass-card p-6 rounded-2xl"},Z={class:"flex items-center gap-4"},tt={class:"text-gray-500 dark:text-gray-400 text-sm"},et={class:"text-gray-900 dark:text-white text-2xl font-bold"},st={class:"stat-card glass-card p-6 rounded-2xl"},ot={class:"flex items-center gap-4"},at={class:"text-gray-500 dark:text-gray-400 text-sm"},it={class:"text-gray-900 dark:text-white text-2xl font-bold"},nt={class:"glass rounded-2xl p-8 mb-8"},lt={class:"mb-6"},rt={class:"block text-gray-900 dark:text-white font-semibold mb-2"},dt=["placeholder"],ct={class:"text-sm text-gray-500 mt-1"},ut={class:"mb-6"},pt={class:"block text-gray-900 dark:text-white font-semibold mb-2"},_t=["placeholder"],mt={class:"text-sm text-gray-400 mt-1"},vt={class:"mb-6"},ht={class:"block text-gray-900 dark:text-white font-semibold mb-2"},gt={class:"mb-6"},ft={class:"block text-gray-900 dark:text-white font-semibold mb-2"},bt={class:"mb-6"},xt={class:"block text-gray-900 dark:text-white font-semibold mb-2"},yt={value:""},wt={value:"announcement"},kt={value:"event"},$t={value:"urgent"},Mt={value:"news"},St={value:"reminder"},Ct={class:"mb-6"},Vt={class:"flex items-center gap-3 cursor-pointer"},zt={class:"text-gray-900 dark:text-white"},jt={class:"mb-8"},qt={class:"text-gray-900 dark:text-white font-semibold mb-4 flex items-center gap-2"},Dt={class:"notification-preview glass-card rounded-xl p-4 max-w-md"},Bt={class:"flex gap-3"},Ht=["src"],It={class:"flex-1 min-w-0"},Nt={class:"font-bold text-gray-900 dark:text-white truncate"},Ut={class:"text-sm text-gray-600 dark:text-gray-300 line-clamp-2"},Ft={class:"text-xs text-gray-400 mt-1"},Tt={class:"flex gap-4"},Et=["disabled"],At={key:0,class:"flex items-center justify-center gap-2"},Ot={key:1,class:"flex items-center justify-center gap-2"},Lt={class:"glass-card p-8 rounded-3xl"},Qt={class:"text-2xl font-bold text-gray-900 dark:text-white mb-6"},Jt={key:0,class:"text-center py-12"},Rt={class:"text-gray-500 dark:text-gray-400"},Gt={key:1,class:"space-y-4"},Kt={class:"flex items-start justify-between"},Pt={class:"flex-1"},Wt={class:"font-semibold text-gray-900 dark:text-white mb-1"},Xt={class:"text-sm text-gray-600 dark:text-gray-300 mb-2"},Yt={class:"flex items-center gap-4 text-xs text-gray-500 dark:text-gray-400"},Zt={class:"flex items-center gap-1"},te={key:0,class:"glass-badge px-3 py-1 rounded-full text-xs font-medium"},ee=j({__name:"SendNotification",setup(se){const u=new T(E),{t:b}=F(),a=_({title:"",body:"",icon:"",actionUrl:"",tag:"",requireInteraction:!1}),l=_({totalSubscribers:0,sentToday:0,totalSent:0}),h=_([]),p=_(!1),S=$(()=>f().format("HH:mm")),x=$(()=>a.value.title.trim().length>0&&a.value.body.trim().length>0);q(async()=>{await y(),await w()});async function y(){try{const e=await u.listDocuments(n.website_db,n.push_subscriptions||"push_subscriptions");l.value.totalSubscribers=e.total;const o=await u.listDocuments(n.website_db,n.push_notifications_log||"push_notifications_log");l.value.totalSent=o.total;const i=f().startOf("day").toISOString(),z=await u.listDocuments(n.website_db,n.push_notifications_log||"push_notifications_log",[g.greaterThanEqual("sent_at",i)]);l.value.sentToday=z.total}catch(e){console.error("Failed to load stats:",e)}}async function w(){try{const e=await u.listDocuments(n.website_db,n.push_notifications_log||"push_notifications_log",[g.orderDesc("sent_at"),g.limit(10)]);h.value=e.documents}catch(e){console.error("Failed to load recent notifications:",e)}}async function C(){if(x.value){p.value=!0;try{await u.createDocument(n.website_db,n.push_notifications_log||"push_notifications_log","unique()",{title:a.value.title,body:a.value.body,icon:a.value.icon||"/favicon.png",action_url:a.value.actionUrl,tag:a.value.tag,require_interaction:a.value.requireInteraction,recipients_count:l.value.totalSubscribers,sent_at:new Date().toISOString()}),M({type:"success",text:b("notification_sent_success")}),k(),await y(),await w()}catch(e){console.error("Failed to send notification:",e),M({type:"error",text:b("notification_sent_error")})}finally{p.value=!1}}}function k(){a.value={title:"",body:"",icon:"",actionUrl:"",tag:"",requireInteraction:!1}}function V(e){return f(e).fromNow()}return(e,o)=>(r(),d("div",O,[t("div",L,[t("div",Q,[t("h1",J,s(e.$t("send_push_notification")),1),o[7]||(o[7]=t("div",{class:"section-accent"},null,-1)),t("p",R,s(e.$t("send_push_description")),1)]),t("div",G,[t("div",K,[t("div",P,[o[8]||(o[8]=t("div",{class:"icon-wrapper bg-sky-500/15 p-3 rounded-xl"},[t("svg",{class:"w-8 h-8 text-sky-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 
10 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"})])],-1)),t("div",null,[t("p",W,s(e.$t("subscribers")),1),t("p",X,s(l.value.totalSubscribers),1)])])]),t("div",Y,[t("div",Z,[o[9]||(o[9]=t("div",{class:"icon-wrapper bg-sky-500/15 p-3 rounded-xl"},[t("svg",{class:"w-8 h-8 text-sky-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"})])],-1)),t("div",null,[t("p",tt,s(e.$t("sent_today")),1),t("p",et,s(l.value.sentToday),1)])])]),t("div",st,[t("div",ot,[o[10]||(o[10]=t("div",{class:"icon-wrapper bg-emerald-500/15 p-3 rounded-xl"},[t("svg",{class:"w-8 h-8 text-emerald-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1)),t("div",null,[t("p",at,s(e.$t("total_sent")),1),t("p",it,s(l.value.totalSent),1)])])])]),t("div",nt,[t("form",{onSubmit:D(C,["prevent"])},[t("div",lt,[t("label",rt,s(e.$t("notification_title"))+" *",1),c(t("input",{"onUpdate:modelValue":o[0]||(o[0]=i=>a.value.title=i),type:"text",required:"",maxlength:"50",class:"page-input w-full",placeholder:e.$t("notification_title_placeholder")},null,8,dt),[[m,a.value.title]]),t("p",ct,s(a.value.title.length)+"/50",1)]),t("div",ut,[t("label",pt,s(e.$t("notification_body"))+" *",1),c(t("textarea",{"onUpdate:modelValue":o[1]||(o[1]=i=>a.value.body=i),required:"",maxlength:"200",rows:"4",class:"page-input w-full resize-none",placeholder:e.$t("notification_body_placeholder")},null,8,_t),[[m,a.value.body]]),t("p",mt,s(a.value.body.length)+"/200",1)]),t("div",vt,[t("label",ht,s(e.$t("icon_url_optional")),1),c(t("input",{"onUpdate:modelValue":o[2]||(o[2]=i=>a.value.icon=i),type:"url",class:"page-input w-full",placeholder:"https://example.com/icon.png"},null,512),[[m,a.value.icon]])]),t("div",gt,[t("label",ft,s(e.$t("action_url")),1),c(t("input",{"onUpdate:modelValue":o[3]||(o[3]=i=>a.value.actionUrl=i),type:"url",class:"page-input w-full",placeholder:"https://tsada.edu.rs/news"},null,512),[[m,a.value.actionUrl]])]),t("div",bt,[t("label",xt,s(e.$t("notification_category")),1),c(t("select",{"onUpdate:modelValue":o[4]||(o[4]=i=>a.value.tag=i),class:"page-input w-full"},[t("option",yt,s(e.$t("no_category")),1),t("option",wt,s(e.$t("announcement")),1),t("option",kt,s(e.$t("event")),1),t("option",$t,s(e.$t("urgent")),1),t("option",Mt,s(e.$t("news")),1),t("option",St,s(e.$t("reminder")),1)],512),[[B,a.value.tag]])]),t("div",Ct,[t("label",Vt,[c(t("input",{"onUpdate:modelValue":o[5]||(o[5]=i=>a.value.requireInteraction=i),type:"checkbox",class:"w-5 h-5 text-sky-600 rounded focus:ring-sky-500"},null,512),[[H,a.value.requireInteraction]]),t("span",zt,s(e.$t("require_interaction")),1)])]),t("div",jt,[t("h3",qt,[o[11]||(o[11]=t("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})],-1)),v(" "+s(e.$t("preview")),1)]),t("div",Dt,[t("div",Bt,[t("img",{src:a.value.icon||"/favicon.png",alt:"Icon",class:"w-12 h-12 rounded-lg",onError:o[6]||(o[6]=i=>i.target.src="/favicon.png")},null,40,Ht),t("div",It,[t("h4",Nt,s(a.value.title||e.$t("notification_title")),1),t("p",Ut,s(a.value.body||e.$t("notification_body")+"..."),1),t("p",Ft,s(S.value),1)])])])]),t("div",Tt,[t("button",{type:"submit",disabled:p.value||!x.value,class:"flex-1 glass-btn px-6 py-4 text-white font-bold rounded-xl disabled:opacity-50 disabled:cursor-not-allowed"},[p.value?(r(),d("span",Ot,[o[13]||(o[13]=t("svg",{class:"animate-spin h-5 w-5",fill:"none",viewBox:"0 0 24 24"},[t("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),t("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})],-1)),v(" "+s(e.$t("sending")),1)])):(r(),d("span",At,[o[12]||(o[12]=t("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})],-1)),v(" "+s(e.$t("send_notification"))+" ("+s(l.value.totalSubscribers)+") ",1)]))],8,Et),t("button",{type:"button",onClick:k,class:"px-6 py-4 btn-ghost-glass rounded-xl font-semibold"},s(e.$t("delete")),1)])],32)]),t("div",Lt,[t("h2",Qt,s(e.$t("recent_notifications")),1),h.value.length===0?(r(),d("div",Jt,[o[14]||(o[14]=t("svg",{class:"w-16 h-16 text-gray-400 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"})],-1)),t("p",Rt,s(e.$t("no_notifications_sent")),1)])):(r(),d("div",Gt,[(r(!0),d(I,null,N(h.value,i=>(r(),d("div",{key:i.$id,class:"notification-item glass rounded-xl p-4 hover:border-sky-300 transition-all"},[t("div",Kt,[t("div",Pt,[t("h4",Wt,s(i.title),1),t("p",Xt,s(i.body),1),t("div",Yt,[t("span",null,s(V(i.sent_at)),1
1),t("span",Zt,[o[15]||(o[15]=t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"})],-1)),v(" "+s(i.recipients_count)+" "+s(e.$t("persons")),1)])])]),i.tag?(r(),d("span",te,s(i.tag),1)):U("",!0)])]))),128))]))])])]))}}),he=A(ee,[["__scopeId","data-v-2fa885b3"]]);export{he 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.