Files
dockerStuff/config/tandoor/staticfiles/vue3/assets/ApiSettings-Ne4Z0qVl.9ef3c0eeb0f3.js
2025-11-16 21:46:46 +00:00

2 lines
3.4 KiB
JavaScript

import{d as v,r as y,o as D,A as E,Q as I,R as B,h as p,w as o,ac as L,i as n,g as t,t as r,B as $,l as i,a7 as g,k as f,V as w,aa as A,j as l,_ as b,z as T,b as C,p as S,F as N,x as P,f as u,y as x,C as R,E as F,D as m,e as j,ai as z,G as M}from"./main-BhFWIRV_.js";import{_ as V}from"./DatabaseLinkCol.vue_vue_type_script_setup_true_lang-Bnq1B2KL.js";const U={class:"text-h6"},K=v({__name:"ApiSettings",setup(O){const k=y([]);D(()=>{d()});function d(){new E().apiAccessTokenList().then(e=>{k.value=e}).catch(e=>{I().addError(B.FETCH_ERROR,e)})}return(a,e)=>(u(),p(L,null,{default:o(()=>[n("p",U,r(a.$t("API")),1),t($,{class:"mb-3"}),t(f,null,{default:o(()=>[t(V,{"prepend-icon":"fa-solid fa-terminal",href:i(g)().getDjangoUrl("api"),lg:6,title:a.$t("API_Browser")},null,8,["href","title"]),t(V,{"prepend-icon":"fa-solid fa-laptop-code",href:i(g)().getDjangoUrl("/docs/api/"),lg:6,title:a.$t("API_Documentation")},null,8,["href","title"])]),_:1}),t(f,null,{default:o(()=>[t(w,null,{default:o(()=>[t(A,{color:"error",variant:"tonal"},{default:o(()=>e[2]||(e[2]=[l(" The API is made for developers to interact with the application. It is possible to break things using the API so be careful and create a backup first. The API definition can and will change in the future, make sure to read the changelog to spot changes early on. ")])),_:1,__:[2]})]),_:1})]),_:1}),t(f,null,{default:o(()=>[t(w,null,{default:o(()=>[e[4]||(e[4]=l(" Authentication works by proving the word ")),e[5]||(e[5]=n("code",null,"Bearer",-1)),e[6]||(e[6]=l(" followed by an API Token as a request Authorization header as shown below. ")),e[7]||(e[7]=n("br",null,null,-1)),e[8]||(e[8]=n("code",null,"Authorization: Bearer TOKEN",-1)),e[9]||(e[9]=l(" -or-")),e[10]||(e[10]=n("br",null,null,-1)),e[11]||(e[11]=n("code",null,"curl -X GET http://your.domain.com/api/recipe/ -H 'Authorization: Bearer TOKEN'",-1)),e[12]||(e[12]=n("br",null,null,-1)),e[13]||(e[13]=n("br",null,null,-1)),e[14]||(e[14]=l(" You can have multiple tokens and each token can have its own scope. Currently there is ")),e[15]||(e[15]=n("code",null,"read",-1)),e[16]||(e[16]=l(", ")),e[17]||(e[17]=n("code",null,"write",-1)),e[18]||(e[18]=l(" and ")),e[19]||(e[19]=n("code",null,"bookmarklet",-1)),e[20]||(e[20]=l(". Read and write do what the name says, the bookmarklet scope is only used for the bookmarklet to limit access to it. ")),t(A,{color:"warning",variant:"tonal"},{default:o(()=>e[3]||(e[3]=[l("Make sure to save your token after creation as they cannot be viewed afterwards.")])),_:1,__:[3]})]),_:1,__:[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]})]),_:1}),t(T,{"prepend-icon":"$create",color:"create",class:"mt-2"},{default:o(()=>[l(r(a.$t("New"))+" ",1),t(b,{model:"AccessToken",onCreate:e[0]||(e[0]=s=>d()),"close-after-create":!1})]),_:1}),t(P,{class:"mt-2",border:""},{default:o(()=>[(u(!0),C(N,null,S(k.value,s=>(u(),p(x,null,{append:o(()=>[s.expires<i(m).now().toJSDate()?(u(),p(z,{key:0,color:"error",class:"me-2"},{default:o(()=>e[21]||(e[21]=[l("Expired")])),_:1,__:[21]})):j("",!0),t(T,{color:"edit"},{default:o(()=>[t(M,{icon:"$edit"}),t(b,{model:"AccessToken",item:s,class:"mt-2",onDelete:e[1]||(e[1]=G=>d())},null,8,["item"])]),_:2},1024)]),default:o(()=>[t(R,null,{default:o(()=>[l(r(s.token),1)]),_:2},1024),t(F,null,{default:o(()=>[l("Scope "+r(s.scope)+" Expires "+r(i(m).fromJSDate(s.expires).toLocaleString(i(m).DATE_FULL)),1)]),_:2},1024)]),_:2},1024))),256))]),_:1})]),_:1}))}});export{K as default};