Files
sm-bm-plugin/public/assets/ProfileView-CzLixZvc.js
Jakub Zych 85cae45cb9 build: frontend with Microsoft 365 sign-in
The student app's login page offers Microsoft 365 when the provider is
configured, /auth/oauth/callback redeems the one-time code, a consent
screen finishes a first sign-in, the profile attaches Microsoft through
a link ticket, and the service worker leaves /oauth alone. The build
also carries the summer presentation theme already committed in the
frontend sources.
2026-10-21 00:23:38 +02:00

2 lines
11 KiB
JavaScript

import{d as I,u as O,y as W,E as A,Q as J,q as R,o as q,a as U,K as N,c as l,i as H,b as o,h as Z,t as r,f as d,w as k,v as w,e as s,F as T,B as D,p as M,r as c,R as Q,n,S as X}from"./index-DmTksCHf.js";import{_ as Y}from"./PageHead.vue_vue_type_script_setup_true_lang-CDCZ4Rtf.js";import{f as V}from"./forms-X1As8WqF.js";import{o as ee}from"./oauth-zzthF4BZ.js";const oe={class:"card","aria-labelledby":"dane-h"},se={key:0,class:"notice error",role:"alert",style:{"margin-bottom":"12px"}},te={key:1,class:"notice",role:"status",style:{"margin-bottom":"12px"}},ae={class:"grid-2"},le={class:"field"},ne={key:0,class:"error-text"},ie={class:"field"},re={key:0,class:"error-text"},de={class:"field"},ue={key:0,class:"error-text"},pe=["disabled"],me={id:"wybor",class:"card section","aria-labelledby":"wybor-h"},ce={key:0,class:"skeleton"},ye={key:1,class:"muted"},be={class:"eyebrow",style:{padding:"0","margin-bottom":"6px"}},ke=["name","value","checked","onChange"],we={key:0,class:"muted small",style:{margin:"4px 0 0"}},fe=["onClick"],ze={id:"kalendarz",class:"card section","aria-labelledby":"kalendarz-h"},ve={key:0,class:"notice error",role:"alert",style:{margin:"12px 0"}},ge={key:1,class:"skeleton",style:{"margin-top":"12px"}},_e={key:2,style:{"margin-top":"12px"}},he=["disabled"],xe={class:"field",style:{"margin-top":"12px"}},je={style:{display:"flex",gap:"8px"}},Pe=["value"],Ce={key:0,class:"muted small",style:{margin:"0"}},Ue={class:"check"},Te=["checked","disabled"],Ve={class:"check"},Ke=["checked","disabled"],Ne={class:"btn-row",style:{"margin-top":"12px"}},Ze=["disabled"],De=["disabled"],Me={key:0,class:"card section","aria-labelledby":"microsoft-h"},Be=["disabled"],Fe={class:"card section","aria-labelledby":"haslo-h"},Se={key:0,class:"notice error",role:"alert",style:{"margin-bottom":"12px"}},Ge={key:1,class:"notice",role:"status",style:{"margin-bottom":"12px"}},Le={class:"field"},Ee={key:0,class:"error-text"},$e={class:"field"},Ie={key:0,class:"error-text"},Oe={class:"field"},We=["disabled"],Ae={class:"section"},Ye=I({__name:"ProfileView",setup(Je){const f=O(),z=W(),v=A(),a=J(),x=R(),j=c(!1),g=c(!1);q(()=>{z.loadCourses(),a.load(),U.oauthProviders().then(i=>j.value=i.providers.some(e=>e.name==="microsoft")).catch(()=>j.value=!1)});async function B(){g.value=!0;try{const{link_ticket:i}=await U.oauthLinkTicket();window.location.assign(ee("microsoft",{action:"link",linkTicket:i,returnTo:"/profil"}))}catch(i){x.show(V(i).message||"Nie udało się połączyć konta Microsoft."),g.value=!1}}const K=c(null);async function F(){const i=a.feed?.url;i&&(await Q(i)?x.show("Skopiowano link do schowka."):(K.value?.select(),x.show("Nie udało się skopiować. Link jest zaznaczony: skopiuj go ręcznie.")))}function S(){window.confirm("Wygenerować nowy link? Stary przestanie działać i kalendarze, które go subskrybują, trzeba będzie dodać od nowa.")&&a.rotate()}function G(){window.confirm("Usunąć link do kalendarza? Kalendarze, które go subskrybują, przestaną się aktualizować.")&&a.remove()}function L(i){return new Date(i).toLocaleString("pl-PL",{day:"numeric",month:"long",hour:"2-digit",minute:"2-digit"})}const m=N({name:f.user?.name??"",surname:f.user?.surname??"",email:f.user?.email??""}),_=c(!1),u=c(null),P=c(!1);async function E(){_.value=!0,u.value=null,P.value=!1;try{await f.updateProfile({name:m.name.trim(),surname:m.surname.trim(),email:m.email.trim()}),P.value=!0}catch(i){u.value=V(i)}finally{_.value=!1}}const p=N({current_password:"",password:"",password_confirmation:""}),h=c(!1),y=c(null),C=c(!1);async function $(){h.value=!0,y.value=null,C.value=!1;try{await U.changePassword({...p}),C.value=!0,Object.assign(p,{current_password:"",password:"",password_confirmation:""})}catch(i){y.value=V(i)}finally{h.value=!1}}return(i,e)=>(n(),l("div",null,[H(Y,{eyebrow:"Konto",title:"Profil"}),o("section",oe,[e[14]||(e[14]=o("h2",{id:"dane-h",style:{"margin-bottom":"12px"}},"Dane",-1)),o("form",{onSubmit:Z(E,["prevent"]),novalidate:""},[u.value?.message?(n(),l("p",se,r(u.value.message),1)):d("",!0),P.value?(n(),l("p",te,"Zapisano.")):d("",!0),o("div",ae,[o("div",le,[e[11]||(e[11]=o("label",{for:"p-name"},"Imię",-1)),k(o("input",{id:"p-name","onUpdate:modelValue":e[0]||(e[0]=t=>m.name=t),type:"text",autocomplete:"given-name"},null,512),[[w,m.name]]),u.value?.fields.name?(n(),l("p",ne,r(u.value.fields.name),1)):d("",!0)]),o("div",ie,[e[12]||(e[12]=o("label",{for:"p-surname"},"Nazwisko",-1)),k(o("input",{id:"p-surname","onUpdate:modelValue":e[1]||(e[1]=t=>m.surname=t),type:"text",autocomplete:"family-name"},null,512),[[w,m.surname]]),u.value?.fields.surname?(n(),l("p",re,r(u.value.fields.surname),1)):d("",!0)])]),o("div",de,[e[13]||(e[13]=o("label",{for:"p-email"},"Adres e-mail",-1)),k(o("input",{id:"p-email","onUpdate:modelValue":e[2]||(e[2]=t=>m.email=t),type:"email",autocomplete:"email",inputmode:"email"},null,512),[[w,m.email]]),u.value?.fields.email?(n(),l("p",ue,r(u.value.fields.email),1)):d("",!0)]),o("button",{class:"btn primary",type:"submit",disabled:_.value},r(_.value?"Zapisywanie…":"Zapisz dane"),9,pe)],32)]),o("section",me,[e[15]||(e[15]=o("h2",{id:"wybor-h",style:{"margin-bottom":"6px"}},"Przedmioty do wyboru",-1)),e[16]||(e[16]=o("p",{class:"muted small"},"Z każdej grupy wybierasz jeden przedmiot. Pozostałe znikną z planu, pulpitu i list (można je pokazać przełącznikiem „Pokaż wszystkie”). Wybór zapamiętuje to urządzenie.",-1)),s(z).loaded.courses?s(z).electiveGroups.length?d("",!0):(n(),l("p",ye,"Nie ma teraz przedmiotów do wyboru.")):(n(),l("div",ce)),(n(!0),l(T,null,D(s(z).electiveGroups,t=>(n(),l("fieldset",{key:t.code,style:{border:"0",padding:"0",margin:"14px 0 0"}},[o("legend",be,r(s(X)(t.code)),1),(n(!0),l(T,null,D(t.options,b=>(n(),l("label",{key:b,class:"check"},[o("input",{type:"radio",name:`g-${t.code}`,value:b,checked:s(v).choices[t.code]===b,onChange:Re=>s(v).choose(t.code,b)},null,40,ke),o("span",null,r(b),1)]))),128)),s(v).choices[t.code]?(n(),l("button",{key:1,class:"linkish small",type:"button",onClick:b=>s(v).choose(t.code,null)},"Wyczyść wybór",8,fe)):(n(),l("p",we,"Jeszcze nie wybrano. Do tego czasu widać wszystkie alternatywy."))]))),128))]),o("section",ze,[e[23]||(e[23]=o("h2",{id:"kalendarz-h",style:{"margin-bottom":"6px"}},"Kalendarz Google / telefon",-1)),e[24]||(e[24]=o("p",{class:"muted small"}," Prywatny link do planu zajęć w formacie iCalendar. Dodaj go w Kalendarzu Google albo w telefonie, a zajęcia pojawią się obok Twoich wydarzeń. Plan uwzględnia przedmioty do wyboru wybrane wyżej. ",-1)),s(a).error?(n(),l("p",ve,r(s(a).error),1)):d("",!0),s(a).feed===void 0&&(s(a).loading||!s(a).error)?(n(),l("div",ge)):s(a).feed?(n(),l(T,{key:3},[o("div",xe,[e[17]||(e[17]=o("label",{for:"cal-url"},"Twój link (nie udostępniaj go)",-1)),o("div",je,[o("input",{id:"cal-url",ref_key:"urlInput",ref:K,class:"mono",type:"text",readonly:"",value:s(a).feed.url,style:{"font-size":"14px","min-width":"0"},onFocus:e[4]||(e[4]=t=>t.target.select())},null,40,Pe),o("button",{class:"btn",type:"button",onClick:F},"Kopiuj")]),s(a).feed.last_fetched_at?(n(),l("p",Ce,"Ostatnio pobrany przez kalendarz: "+r(L(s(a).feed.last_fetched_at))+".",1)):d("",!0)]),o("label",Ue,[o("input",{type:"checkbox",checked:s(a).feed.include_meetings,disabled:s(a).busy,onChange:e[5]||(e[5]=t=>s(a).save({include_meetings:t.target.checked}))},null,40,Te),e[18]||(e[18]=o("span",null,"Zjazdy jako wydarzenia całodniowe",-1))]),o("label",Ve,[o("input",{type:"checkbox",checked:s(a).feed.include_deadlines,disabled:s(a).busy,onChange:e[6]||(e[6]=t=>s(a).save({include_deadlines:t.target.checked}))},null,40,Ke),e[19]||(e[19]=o("span",null,"Terminy z terminarza",-1))]),o("div",Ne,[o("button",{class:"btn small ghost",type:"button",disabled:s(a).busy,onClick:S},"Wygeneruj nowy link",8,Ze),o("button",{class:"btn small miss",type:"button",disabled:s(a).busy,onClick:G},"Usuń link",8,De)]),e[20]||(e[20]=o("h3",{class:"eyebrow",style:{margin:"18px 0 6px"}},"Jak dodać",-1)),e[21]||(e[21]=o("ol",{class:"small",style:{margin:"0","padding-left":"20px",display:"grid",gap:"6px"}},[o("li",null,[o("b",null,"Kalendarz Google"),M(" (na komputerze, calendar.google.com): po lewej przy „Inne kalendarze” kliknij „+”, wybierz „Z adresu URL”, wklej link i kliknij „Dodaj kalendarz”. Na telefonie z Androidem kalendarz pojawi się sam po synchronizacji konta Google. ")]),o("li",null,[o("b",null,"iPhone / iPad"),M(": Ustawienia → Kalendarz → Konta → Dodaj konto → Inne → Dodaj subskrybowany kalendarz, wklej link i zapisz. ")])],-1)),e[22]||(e[22]=o("p",{class:"muted small",style:{margin:"10px 0 0"}}," Google odświeża subskrybowane kalendarze co kilka godzin, nie od razu: zmiana planu albo wyboru przedmiotów pojawi się w kalendarzu z opóźnieniem. ",-1))],64)):(n(),l("div",_e,[o("button",{class:"btn primary",type:"button",disabled:s(a).busy,onClick:e[3]||(e[3]=t=>s(a).create())},r(s(a).busy?"Tworzenie…":"Utwórz link do kalendarza"),9,he)]))]),j.value?(n(),l("section",Me,[e[25]||(e[25]=o("h2",{id:"microsoft-h",style:{"margin-bottom":"6px"}},"Konto Microsoft 365",-1)),e[26]||(e[26]=o("p",{class:"muted small"}," Połącz konto uczelniane Microsoft 365, aby logować się przyciskiem „Zaloguj przez Microsoft 365”. ",-1)),o("button",{class:"btn",type:"button",style:{"margin-top":"12px"},disabled:g.value,onClick:B},r(g.value?"Przekierowanie…":"Połącz konto Microsoft"),9,Be)])):d("",!0),o("section",Fe,[e[30]||(e[30]=o("h2",{id:"haslo-h",style:{"margin-bottom":"12px"}},"Zmiana hasła",-1)),o("form",{onSubmit:Z($,["prevent"]),novalidate:""},[y.value?.message?(n(),l("p",Se,r(y.value.message),1)):d("",!0),C.value?(n(),l("p",Ge,"Hasło zostało zmienione.")):d("",!0),o("div",Le,[e[27]||(e[27]=o("label",{for:"pw-current"},"Obecne hasło",-1)),k(o("input",{id:"pw-current","onUpdate:modelValue":e[7]||(e[7]=t=>p.current_password=t),type:"password",autocomplete:"current-password"},null,512),[[w,p.current_password]]),y.value?.fields.current_password?(n(),l("p",Ee,r(y.value.fields.current_password),1)):d("",!0)]),o("div",$e,[e[28]||(e[28]=o("label",{for:"pw-new"},"Nowe hasło (min. 8 znaków)",-1)),k(o("input",{id:"pw-new","onUpdate:modelValue":e[8]||(e[8]=t=>p.password=t),type:"password",autocomplete:"new-password"},null,512),[[w,p.password]]),y.value?.fields.password?(n(),l("p",Ie,r(y.value.fields.password),1)):d("",!0)]),o("div",Oe,[e[29]||(e[29]=o("label",{for:"pw-confirm"},"Powtórz nowe hasło",-1)),k(o("input",{id:"pw-confirm","onUpdate:modelValue":e[9]||(e[9]=t=>p.password_confirmation=t),type:"password",autocomplete:"new-password"},null,512),[[w,p.password_confirmation]])]),o("button",{class:"btn primary",type:"submit",disabled:h.value||!p.current_password||!p.password},r(h.value?"Zapisywanie…":"Zmień hasło"),9,We)],32)]),o("section",Ae,[o("button",{class:"btn miss",type:"button",onClick:e[10]||(e[10]=t=>s(f).logout())},"Wyloguj się")])]))}});export{Ye as default};