You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
11 KiB
2 lines
11 KiB
2 weeks ago
|
var G=Object.defineProperty;var L=(e,t,s)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var c=(e,t,s)=>L(e,typeof t!="symbol"?t+"":t,s);import{V as T,f as M,e as F,C as H,_ as B,g as y,h as l,i as d,j as n,q as _,l as g,p as P,w as I,F as C,x as r,k as m,z as N,t as p}from"./index-BLqts8WY.js";import{E as R}from"./EntityIcon-CF1RwQI5.js";import{I as U}from"./InfiniteScroll-B5tl9k_n.js";import{Q as A}from"./QuickNav-DgCyvgDx.js";import{O as V}from"./OnboardingDialog-CiAZLb6o.js";import{P as E}from"./ProjectIcon-BlrP4rvy.js";import{T as z}from"./TopMessage-BE0GBIgW.js";import{U as Y}from"./UserNameDialog-B8a82q1n.js";import{l as Q,h as q,e as J,ao as K,g as O,ap as W}from"./index-MyY_xqVN.js";import"./index-CsfPLOYu.js";var X=Object.defineProperty,Z=Object.getOwnPropertyDescriptor,ee=(e,t,s,a)=>{for(var i=a>1?void 0:a?Z(t,s):t,u=e.length-1,f;u>=0;u--)(f=e[u])&&(i=(a?f(t,s,i):f(i))||i);return a&&i&&X(t,s,i),i};let D=class extends T{constructor(){super(...arguments);c(this,"$notify");c(this,"activeDid","");c(this,"allContacts",[]);c(this,"allMyDids",[]);c(this,"apiServer","");c(this,"givenName","");c(this,"isLoading",!1);c(this,"isRegistered",!1);c(this,"offers",[]);c(this,"projectNameFromHandleId",{});c(this,"projects",[]);c(this,"showOffers",!1);c(this,"showProjects",!0);c(this,"libsUtil",Q);c(this,"didInfo",q)}errNote(s){this.$notify({group:"alert",type:"danger",title:"Error",text:s},5e3)}async mounted(){try{const s=await M();this.activeDid=s.activeDid||"",this.apiServer=s.apiServer||"",this.isRegistered=!!s.isRegistered,this.givenName=s.firstName||"",this.allContacts=await F.contacts.toArray(),this.allMyDids=await J(),s.finishedOnboarding||this.$refs.onboardingDialog.open(K.Create),this.allMyDids.length===0?(console.error("No accounts found."),this.errNote("You need an identifier to load your projects.")):await this.loadProjects()}catch(s){console.error("Error initializing:",s),this.errNote("Something went wrong loading your projects.")}}async projectDataLoader(s){try{const a=await O(this.activeDid,this.$notify);this.isLoading=!0;const i=await this.axios.get(s,{headers:a});if(i.status===200&&i.data.data){const u=i.data.data;for(const f of u){const{name:b,description:v,handleId:h,image:j,issuerDid:w,rowid:k}=f;this.projects.push({name:b,description:v,image:j,handleId:h,issuerDid:w,rowid:k})}}else console.error("Bad server response & data for plans:",i.status,i.data),this.errNote("Failed to get projects from the server.")}catch(a){console.error("Got error loading plans:",a.message||a),this.errNote("Got an error loading projects.")}finally{this.isLoading=!1}}async loadMoreProjectData(s){if(this.projects.length>0&&s){const a=this.projects[this.projects.length-1];await this.loadProjects(`beforeId=${a.rowid}`)}}async loadProjects(s=""){const a=`${this.apiServer}/api/v2/report/plansByIssuer?${s}`;await this.projectDataLoader(a)}onClickLoadProject(s){const a={path:"/project/"+encodeURIComponent(s)};this.$router.push(a)}onClickNewProject(){const s={name:"new-edit-project"};this.$router.push(s)}onClickLoadClaim(s){const a={path:"/claim/"+encodeURIComponent(s)};this.$router.push(a)}async offerDataLoader(s){const a=await O(this.activeDid);try{this.isLoading=!0;const i=await this.axios.get(s,{headers:a});if(i.status===200&&i.data.data)for(const u of i.data.data){if(u.fulfillsPlanHandleId){const f=await W(u.fulfillsPlanHandleId,this.axios,this.apiServer,this.activeDid),b=f==null?void 0:f.name;this.projectNameFromHandleId[u.fulfillsPlanHandleId]=b}this.offers=this.offers.concat([u])}else console.error("Bad server response & data for offers:",i.status,i.data),this.$notify({group:"alert",type:"danger",title:"Error",text:"Failed to get offers from the server. Try again later."},-1)}catch(i){console.error("Got error loading offers:",i.message||i),this.$notify({group:"alert",type:"danger",title:"Error",text:"Got an error loading offers."},-1)}finally{this.isLoading=!1}}async loadMoreOfferData(s){if(this.offers.length>0&&s){const a=this.offers[this.offers.length-1];await this.loadOffers(`&beforeId=${a.jwtId}`)}}a
|