Skip to content

Commit

Permalink
address latest github issues
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed Feb 16, 2024
1 parent b13997c commit ec8c343
Show file tree
Hide file tree
Showing 13 changed files with 494 additions and 140 deletions.
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"leaflet": "^1.9.3",
"svelte-apollo": "^0.5.0",
"svelte-leafletjs": "^0.10.0",
"ws": "^8.13.0"
"ws": "^8.13.0",
"@svelte-put/dragscroll": "^3.0.0"
},
"devDependencies": {
"@rollup/plugin-replace": "^4.0.0",
Expand Down
42 changes: 36 additions & 6 deletions ui/src/lib/CommitmentModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
let agents: Agent[];
let resourceSpecifications: any[];
let units: any[];
let saveCost: boolean = false;
$: saveCost;
$: if (selectedCommitment) {
if (selectedCommitment.clauseOf && selectedCommitment.clauseOf.commitments.length > 0) {
saveCost = true
} else {
saveCost = false
}
}
// $: if (open) {
// newCommitment.id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
Expand Down Expand Up @@ -399,10 +410,12 @@ const GET_ALL_RESOURCE_SPECIFICATIONS = gql`
id="defaultUnitOfResource"
name="defaultUnitOfResource"
class="mt-2 block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-indigo-600 sm:text-sm sm:leading-6"
bind:value={newCommitment.resourceConformsTo.name}
value={newCommitment.resourceConformsTo.name}
on:change={(e) => {
newCommitment.resourceQuantity.hasUnit = resourceSpecifications.find((rs) => rs.name === e.target.value).defaultUnitOfResource
newCommitment.resourceConformsTo.defaultUnitOfResource = resourceSpecifications.find((rs) => rs.name === e.target.value).defaultUnitOfResource
// newCommitment.resourceConformsTo.defaultUnitOfResource = resourceSpecifications.find((rs) => rs.name === e.target.value).defaultUnitOfResource
let x = resourceSpecifications.find((rs) => rs.name === e.target.value)
newCommitment.resourceConformsTo = x
}}
>
{#each resourceSpecifications as rs}
Expand Down Expand Up @@ -491,7 +504,7 @@ const GET_ALL_RESOURCE_SPECIFICATIONS = gql`
>
{#if units}
{#each units as unit}
<option value={unit.label}>{unit.symbol}</option>
<option value={unit.label}>{unit.label}</option>
{/each}
{/if}
</select>
Expand Down Expand Up @@ -525,6 +538,22 @@ const GET_ALL_RESOURCE_SPECIFICATIONS = gql`
/>
{/if}
</div>

<!-- save cost? checkbox -->
<div class="mt-4 flex items-center">
<input
id="save_cost"
name="save_cost"
type="checkbox"
checked={saveCost}
on:change={(e) => {
saveCost = e.target.checked
}}
class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
/>
<label for="save_cost" class="ml-2 block text-sm text-gray-900">Save cost</label>
</div>

<!-- <p class="mt-3 text-sm leading-6 text-gray-600">
Description for the description field
</p> -->
Expand Down Expand Up @@ -577,13 +606,13 @@ const GET_ALL_RESOURCE_SPECIFICATIONS = gql`
// selectedCommitment = Object.assign({}, newCommitmentTemplate)

}
// console.log("hihi")
dispatch('submit', {
column: commitmentModalColumn,
process: commitmentModalProcess,
side: commitmentModalSide,
commitment: updatedCommitment,
useAs: 'update'
useAs: 'update',
saveCost: saveCost
});
open = false;
}}
Expand Down Expand Up @@ -614,7 +643,8 @@ const GET_ALL_RESOURCE_SPECIFICATIONS = gql`
...newCommitment,
id: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
},
useAs: 'new'
useAs: 'new',
saveCost: saveCost
});
// }

Expand Down
34 changes: 24 additions & 10 deletions ui/src/lib/EconomicEventModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ const GET_ALL_RESOURCE_SPECIFICATIONS = gql`
>
{#if units}
{#each units as unit}
<option value={unit.label}>{unit.symbol}</option>
<option value={unit.label}>{unit.labell}</option>
{/each}
{/if}
</select>
Expand Down Expand Up @@ -461,19 +461,33 @@ const GET_ALL_RESOURCE_SPECIFICATIONS = gql`
{/if}

<div class="mt-4 text-left">
<div>
<label
for="date"
class="block text-sm font-medium leading-6 text-gray-900"
>Commitment finished</label
>
<input type="checkbox" id="finished"
<!-- <div class="mt-4 flex items-center">
<input
id="save_cost"
name="save_cost"
type="checkbox"
checked={saveCost}
on:change={(e) => {
saveCost = e.target.checked
}}
class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
/>
<label for="save_cost" class="ml-2 block text-sm text-gray-900">Save cost</label>
</div> -->
<div class="mt-4 flex items-center">
<input type="checkbox" id="finished"
on:change={(e) => {
console.log("lkjjjjjjj", e)
selectedCommitment.finished = e.target.checked
console.log(selectedCommitment.finished)
}}
bind:checked={finished} class="mt-2">
bind:checked={finished}
class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
>

<label
for="date"
class="block text-sm font-medium leading-6 text-gray-900"
>&nbsp;Commitment finished</label>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/lib/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<style>
/* Custom CSS */
.custom-background {
background-image: url('/heading3.png');
background-image: url('/dsf.jpg');
background-size: cover;
background-position: center;
}
Expand Down
22 changes: 14 additions & 8 deletions ui/src/lib/PlanModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
node {
id
name
classifiedAs
}
}
}
Expand Down Expand Up @@ -315,7 +316,7 @@
},
}
const defaultAgent = agents.find((a) => a.node.name === "Carbon Farm Network").node
const defaultAgent = agents.find((a) => a.node.classifiedAs[2] === "Network").node
try {
o.provider = agents.find((a) => a.node.name === commitment.provider.name).node.id
Expand Down Expand Up @@ -400,7 +401,7 @@
let o = {
...c,
// provider is carbon farm network
provider: agents.find((a) => a.node.name === "Carbon Farm Network").node.id,
provider: agents.find((a) => a.node.classifiedAs[2] === "Network").node.id,
// reciever is agent for request
plannedWithin: p.data.res.plan.id,
// references plan with independentDemandOf
Expand Down Expand Up @@ -584,12 +585,16 @@
// delete commitments
console.log(commitmentsToDelete)
for (const c of commitmentsToDelete) {
console.log("deleting commitment", c)
await deleteCommitment({
variables: {
revisionId: c
}
})
try {
console.log("deleting commitment", c)
await deleteCommitment({
variables: {
revisionId: c
}
})
} catch (e) {
console.log("could not delete commitment", e)
}
}
savingPlan = false;
Expand Down Expand Up @@ -625,6 +630,7 @@
processSpecifications = z.data.processSpecifications.edges
console.log("loaded process specifications", processSpecifications)
const y = await agentsQuery.refetch()
console.log(y)
agents = y.data.agents.edges
console.log("loaded agents", agents)
window.addEventListener('keydown', checkKey)
Expand Down
2 changes: 2 additions & 0 deletions ui/src/lib/graphql/plan.fragments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ export const COMMITMENT_RETURN_FIELDS = gql`
finished
clauseOf {
id
revisionId
commitments {
id
revisionId
action {
id
label
Expand Down
12 changes: 6 additions & 6 deletions ui/src/lib/icons/EconomicEvent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
/>
</svg> -->

<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg">
<!-- Notebook cover -->
<!-- <svg width="20" height="20" xmlns="http://www.w3.org/2000/svg">
<rect x="10%" y="10%" width="80%" height="80%" fill="transparent" stroke="black" stroke-width="1"/>
<!-- Dollar sign -->
<text x="48%" y="58%" font-size="80%" fill="black">☰</text>
<text x="48%" y="88%" font-size="80%" fill="black">☰</text>
<!-- Notebook binding -->
<line x1="50%" y1="10%" x2="50%" y2="90%" stroke="black" stroke-width="2"/>
<!-- Dollar sign -->
<text x="15%" y="65%" font-size="80%" fill="black">$</text>
</svg>
</svg> -->

<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<path d="M152 24c0-13.3-10.7-24-24-24s-24 10.7-24 24V64H64C28.7 64 0 92.7 0 128v16 48V448c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V192 144 128c0-35.3-28.7-64-64-64H344V24c0-13.3-10.7-24-24-24s-24 10.7-24 24V64H152V24zM48 192H400V448c0 8.8-7.2 16-16 16H64c-8.8 0-16-7.2-16-16V192zm176 40c-13.3 0-24 10.7-24 24v48H152c-13.3 0-24 10.7-24 24s10.7 24 24 24h48v48c0 13.3 10.7 24 24 24s24-10.7 24-24V352h48c13.3 0 24-10.7 24-24s-10.7-24-24-24H248V256c0-13.3-10.7-24-24-24z"/>
</svg>
Loading

0 comments on commit ec8c343

Please sign in to comment.