Skip to content

Commit

Permalink
move modals to route folders, add loading screens to most pages, add …
Browse files Browse the repository at this point in the history
…plan forward algorithm
  • Loading branch information
LeosPrograms committed Dec 20, 2024
1 parent 8082e5a commit 95061cf
Show file tree
Hide file tree
Showing 40 changed files with 482 additions and 436 deletions.
70 changes: 70 additions & 0 deletions ui/src/crud/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,23 @@ mutation($plan: PlanCreateParams!){
}
`

const UPDATE_PLAN = gql`
${SIMPLIFIED_PLAN_RETURN_FIELDS},
mutation($plan: PlanUpdateParams!){
updatePlan(plan: $plan) {
plan {
...SimplifiedPlanReturnFields
}
}
}
`

const DELETE_PLAN = gql`
mutation($revisionId: ID!){
deletePlan(revisionId: $revisionId)
}
`

const CREATE_PROCESS = gql`
${PROCESS_RETURN_FIELDS},
mutation($process: ProcessCreateParams!){
Expand All @@ -273,6 +290,23 @@ mutation($process: ProcessCreateParams!){
}
`

const UPDATE_PROCESS = gql`
${PROCESS_RETURN_FIELDS},
mutation($process: ProcessUpdateParams!){
updateProcess(process: $process) {
process {
...ProcessReturnFields
}
}
}
`

const DELETE_PROCESS = gql`
mutation($revisionId: ID!){
deleteProcess(revisionId: $revisionId)
}
`

const CREATE_RECIPE_FLOW = gql`
${RECIPE_FLOW_CORE_FIELDS},
mutation($recipeFlow: RecipeFlowCreateParams!){
Expand Down Expand Up @@ -608,6 +642,24 @@ export const createPlan = async (plan: any) => {
})
}

export const updatePlan = async (plan: any) => {
return await client.mutate({
mutation: UPDATE_PLAN,
variables: {
plan
}
})
}

export const deletePlan = async (revisionId: string) => {
return await client.mutate({
mutation: DELETE_PLAN,
variables: {
revisionId
}
})
}

export const createProcess = async (process: any) => {
return await client.mutate({
mutation: CREATE_PROCESS,
Expand All @@ -617,6 +669,24 @@ export const createProcess = async (process: any) => {
})
}

export const updateProcess = async (process: any) => {
return await client.mutate({
mutation: UPDATE_PROCESS,
variables: {
process
}
})
}

export const deleteProcess = async (revisionId: string) => {
return await client.mutate({
mutation: DELETE_PROCESS,
variables: {
revisionId
}
})
}

export const createRecipeFlow = async (recipeFlow: RecipeFlowCreateParams) => {
return await client.mutate({
mutation: CREATE_RECIPE_FLOW,
Expand Down
25 changes: 24 additions & 1 deletion ui/src/crud/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { RESOURCE_SPECIFICATION_CORE_FIELDS, UNIT_CORE_FIELDS } from '$lib/graph
import { PROCESS_SPECIFICATION_CORE_FIELDS } from '$lib/graphql/process_specification.fragments'
import { RECIPE_RETURN_FIELDS, RECIPE_EXCHANGE_RETURN_FIELDS } from '$lib/graphql/recipe.fragments'
import { addToFullPlans, setActions, clientStored, setAgents, updateAnAgent, setUnits, setResourceSpecifications, setProcessSpecifications, setProposals, setRecipes, setRecipeExchanges,
setHashChanges, setEconomicEvents, setEconomicResources, updateProcessInPlan, setFulfillments, setCommitments, setAgreements, addNonProcessCommitmentsToPlan } from './store'
setHashChanges, setEconomicEvents, setEconomicResources, updateProcessInPlan, setFulfillments, setCommitments, setAgreements, addNonProcessCommitmentsToPlan, setPlansList } from './store'
import { WeaveClient, isWeContext, initializeHotReload, type WAL} from '@lightningrodlabs/we-applet';
import { appletServices } from '../../we';
import { decode } from '@msgpack/msgpack';
Expand Down Expand Up @@ -203,6 +203,20 @@ query GetPlan($id: ID!) {
}
`

const GET_PLANS = gql`
${SIMPLIFIED_PLAN_RETURN_FIELDS}
query {
plans(last: 100000) {
edges {
cursor
node {
...SimplifiedPlanReturnFields
}
}
}
}
`

const GET_NON_PROCESS_COMMITMENTS = gql`
${NON_PROCESS_COMMITMENT_RETURN_FIELDS}
query GetPlan($id: ID!) {
Expand Down Expand Up @@ -494,6 +508,15 @@ export const getPlan = async (id: string) => {
return res.data.plan
}

export const getAllPlans = async () => {
const res = await client.query({
query: GET_PLANS,
fetchPolicy: 'no-cache'
})
setPlansList(res.data.plans.edges.map((edge: any) => edge.node))
return res
}

export const getNonProcessCommitments = async (id: string) => {
const res = await client.query({
query: GET_NON_PROCESS_COMMITMENTS,
Expand Down
5 changes: 5 additions & 0 deletions ui/src/crud/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const allEconomicEvents = writable([]);
export const allEconomicResources = writable([]);
export const allActions = writable([]);
export const fullPlans = writable({});
export const plansList = writable([]);
export const allFulfillments = writable([]);
export const allCommitments = writable([]);
export const allAgreements = writable([]);
Expand Down Expand Up @@ -98,6 +99,10 @@ export function addToFullPlans(newPlan: any) {
});
}

export function setPlansList(newPlans: any) {
plansList.update(v => newPlans);
}

export function addNonProcessCommitmentsToPlan(planId: string, commitments: any[]) {
fullPlans.update(v => {
let newPlan = v[planId]
Expand Down
2 changes: 2 additions & 0 deletions ui/src/lib/Initialize.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
action: actions.find(a => a.label === i.action.label.replaceAll("_", "-")).id,
providerRole: i.provider_role,
receiverRole: i.receiver_role,
instructions: i.instructions,
resourceQuantity: {
hasNumericalValue: Number(i.resourceQuantity.hasNumericalValue),
hasUnit: units.find(u => u.label === i.resourceQuantity.hasUnit.label)?.id,
Expand All @@ -229,6 +230,7 @@
action: actions.find(a => a.label === o.action.label.replaceAll("_", "-")).id,
providerRole: o.provider_role,
receiverRole: o.receiver_role,
instructions: o.instructions,
resourceQuantity: {
hasNumericalValue: Number(o.resourceQuantity.hasNumericalValue),
hasUnit: units.find(u => u.label === o.resourceQuantity.hasUnit.label)?.id,
Expand Down
39 changes: 0 additions & 39 deletions ui/src/lib/graphql/plan.fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,6 @@ export const SIMPLIFIED_PLAN_RETURN_FIELDS = gql`
revisionId
name
note
meta {
retrievedRevision {
id
time
}
}
independentDemands {
id
revisionId
action {
id
label
}
receiverId
resourceQuantity {
hasNumericalValue
hasUnitId
}
resourceConformsTo {
id
name
defaultUnitOfResourceId
}
}
processes {
id
revisionId
name
meta {
retrievedRevision {
id
time
}
}
basedOn {
id
name
}
}
}
`

Expand Down
2 changes: 2 additions & 0 deletions ui/src/lib/graphql/recipe.fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const RECIPE_RETURN_FIELDS = gql`
note
providerRole
receiverRole
insructions
stage {
id
name
Expand Down Expand Up @@ -72,6 +73,7 @@ export const RECIPE_RETURN_FIELDS = gql`
note
providerRole
receiverRole
instructions
stage {
id
name
Expand Down
Loading

0 comments on commit 95061cf

Please sign in to comment.