Skip to content

Commit

Permalink
update to latest we pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed Mar 11, 2024
1 parent 5c8b0e6 commit 7ff3197
Show file tree
Hide file tree
Showing 12 changed files with 484 additions and 437 deletions.
558 changes: 293 additions & 265 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev": "VITE_ADMIN_PORT=$(port) VITE_APP_PORT=$(port) SIGNAL_PORT=$(port) BOOTSTRAP_PORT=$(port) UI_PORT=8888 npm run x",
"x": "hc s clean && npm run build:happ && UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run start:happ\" \"hc run-local-services -b $BOOTSTRAP_PORT -s $SIGNAL_PORT\"",
"applet-dev": " UI_PORT=8888 npm run applet-devy",
"applet-devy": "concurrently \"npm start -w ui\" \"we-dev-cli --agent-idx 1 --dev-config we_dev/config.ts\" \"we-dev-cli --agent-idx 2 --dev-config we_dev/config.ts\"",
"applet-devy": "concurrently \"npm start -w ui\" \"sleep 1 && we-dev-cli --agent-idx 1 --dev-config we_dev/config.ts\" \"sleep 10 && we-dev-cli --agent-idx 2 --dev-config we_dev/config.ts\"",
"applet-devx": "BPORT=46263 SPORT=46262; concurrently \"hc run-local-services -b $BPORT -s $SPORT\" \"npm start -w ui\" \"./we_dev/we.AppImage --dev-config we_dev/config.json --agent-num 1 -b http://127.0.0.1:$BPORT -s ws://127.0.0.1:$SPORT\" \"sleep 10 && ./we_dev/we.AppImage --dev-config we_dev/config.json --agent-num 2 -b http://127.0.0.1:$BPORT -s ws://127.0.0.1:$SPORT\"",
"network": "hc s clean && npm run build:happ && UI_PORT=8888 concurrently \"npm start -w ui\" \"npm run launch:happ\" \"holochain-playground\"",
"test": "npm run build:zomes && hc app pack workdir --recursive && npm t -w tests",
Expand Down
5 changes: 3 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"@holochain-open-dev/utils": "^0.16.4",
"@holochain-syn/core": "^0.12.1",
"@holochain/client": "^0.16.7",
"@lightningrodlabs/we-applet": "^0.15.0-alpha.1",
"@lightningrodlabs/we-applet": "^0.15.0",
"@lightningrodlabs/we-elements": "^0.4.5",
"@holochain/tryorama": "^0.11.0",
"@mdi/js": "^7.1.96",
"@ts-stack/markdown": "^1.5.0",
Expand Down Expand Up @@ -47,7 +48,7 @@
"@univerjs/facade": "^0.1.2"
},
"devDependencies": {
"@lightningrodlabs/we-dev-cli": "^0.10.5-alpha.3",
"@lightningrodlabs/we-dev-cli": "^0.10.5",
"@sveltejs/vite-plugin-svelte": "^2.0.2",
"@tsconfig/svelte": "^3.0.0",
"bestzip": "^2.2.0",
Expand Down
14 changes: 13 additions & 1 deletion ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import "@holochain-open-dev/profiles/dist/elements/create-profile.js";
import LogoIcon from "./icons/LogoIcon.svelte";
import { appletServices } from './we';
import ControllerCreate from './ControllerCreate.svelte'
const appId = import.meta.env.VITE_APP_ID ? import.meta.env.VITE_APP_ID : 'calcy'
const roleName = 'calcy'
Expand All @@ -22,12 +23,14 @@
let client: AppAgentWebsocket
let weClient: WeClient
let profilesStore : ProfilesStore|undefined = undefined
let createView
let connected = false
enum RenderType {
App,
Hrl,
CreateSpreadsheet,
BlockActiveBoards
}
Expand Down Expand Up @@ -77,6 +80,13 @@
throw new Error("Unknown applet-view block type:"+weClient.renderInfo.view.block);
}
break;
case "creatable":
switch (weClient.renderInfo.view.name) {
case "spreadsheet":
renderType = RenderType.CreateSpreadsheet
createView = weClient.renderInfo.view
}
break;
case "attachable":
switch (weClient.renderInfo.view.roleName) {
case "calcy":
Expand Down Expand Up @@ -149,7 +159,9 @@
{:else if $prof.status=="error"}
Error when loading profile: {$prof.error}
{:else}
{#if renderType== RenderType.App}
{#if renderType== RenderType.CreateSpreadsheet}
<ControllerCreate view={createView} client={client} weClient={weClient} profilesStore={profilesStore} roleName={roleName}></ControllerCreate>
{:else if renderType== RenderType.App}
<Controller client={client} weClient={weClient} profilesStore={profilesStore} roleName={roleName}></Controller>
{:else if renderType== RenderType.Hrl && !hrlWithContext.context}
<ControllerBoard board={hrlWithContext.hrl[1]} client={client} weClient={weClient} profilesStore={profilesStore} roleName={roleName}></ControllerBoard>
Expand Down
95 changes: 0 additions & 95 deletions ui/src/AttachmentsBind.svelte

This file was deleted.

11 changes: 1 addition & 10 deletions ui/src/AttachmentsDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import '@shoelace-style/shoelace/dist/components/button/button.js';
import '@shoelace-style/shoelace/dist/components/dialog/dialog.js';
import AttachmentsList from "./AttachmentsList.svelte";
import AttachmentsBind from "./AttachmentsBind.svelte";
import SvgIcon from "./SvgIcon.svelte";
const { getStore } :any = getContext("store");
Expand All @@ -27,12 +26,10 @@
// } else {
attachments = activeBoard.state().props.attachments
// }
await bind.refresh()
dialog.show()
}
let dialog
$: attachments
let bind
function removeAttachment(index: number) {
attachments.splice(index, 1);
Expand Down Expand Up @@ -79,15 +76,9 @@
<h3>Search Linkables:</h3>
</div>
<sl-button style="margin-top:5px;margin-right: 5px" circle on:click={()=>addAttachment()} >
<SvgIcon icon=link size=12 />
<SvgIcon icon=searchPlus size=12 />
</sl-button>

<AttachmentsBind
bind:this = {bind}
activeBoard={activeBoard}
on:add-binding={(e)=>_addAttachment(e.detail)}
/>

{/if}
</sl-dialog>

Expand Down
9 changes: 7 additions & 2 deletions ui/src/CalcyPane.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
import { exportBoard } from "./export";
import AttachmentsList from './AttachmentsList.svelte';
import AttachmentsDialog from "./AttachmentsDialog.svelte"
import {Workbook} from "@fortune-sheet/react";
import { weaveUrlFromWal, type HrlWithContext } from "@lightningrodlabs/we-applet";
import { hrlB64WithContextToRaw } from "./util";
import '@lightningrodlabs/we-elements/dist/elements/wal-embed.js';
// import {Workbook} from "@fortune-sheet/react";
// import ReactAdapter from "./ReactAdapter.svelte";
// import "@fortune-sheet/react/dist/index.css"
import type { IWorkbookData } from '@univerjs/core';
Expand Down Expand Up @@ -150,7 +155,7 @@
const newValue = spreadsheet[sheet].cellData[row][col]
// check if object values in previousValue differ from newValue
if (!isEqual(previousValue, newValue)) {
// let microRange = activeSheet.getRange(row, col, 3, 2);
// let microRange = activeSheet.getRange(row, col, 1, 1);
// microRange.setValue(newValue)
compromiseValue[row][col] = newValue
changed = true;
Expand Down
112 changes: 112 additions & 0 deletions ui/src/ControllerCreate.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<script lang="ts">
import { CalcyStore } from './store'
import { setContext } from 'svelte';
import type { AppAgentClient } from '@holochain/client';
import { SynStore } from '@holochain-syn/store';
import type { ProfilesStore } from "@holochain-open-dev/profiles";
import type { WeClient } from '@lightningrodlabs/we-applet';
import { SynClient } from '@holochain-syn/core';
import { getMyDna } from './util';
import { Board } from './board';
export let roleName = ""
export let client : AppAgentClient
export let weClient : WeClient
export let profilesStore : ProfilesStore
export let view
let store: CalcyStore = new CalcyStore (
weClient,
profilesStore,
client,
roleName,
);
let synStore: SynStore = store.synStore
setContext('synStore', {
getStore: () => synStore,
});
setContext('store', {
getStore: () => store,
});
let inputElement
let disabled = true
</script>
<div class="flex-scrollable-parent">
<div class="flex-scrollable-container">
<div class='app'>

<div class="wrapper">

<div class="workspace" style="display:flex; flex-direction:column;padding:20px;">
<sl-input bind:this={inputElement}
on:sl-input={(e)=>disabled = !e.target.value}
label="Spreadsheet Name"></sl-input>
<div style="margin-top:10px;display:flex;justify-content:flex-end">
<sl-button
style="margin-right:10px;"
disabled={disabled}
on:click={async ()=>{
try {
const synStore = new SynStore(new SynClient(client, roleName));
//const hrlB64 = hrlWithContextToB64(attachToHrlWithContext)
const board = await Board.Create(synStore, {/*boundTo:[hrlB64]*/name: inputElement.value})
const dnaHash = await getMyDna(roleName, client)
view.resolve({hrl:[dnaHash, board.hash]})
} catch(e) {
console.log("ERR",e)
view.reject(e)
}
}}>Create</sl-button>
<sl-button on:click={()=>{
view.cancel()
}}>Cancel</sl-button>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
.app {
margin: 0;
padding-bottom: 10px;
background-size: cover;
display: flex;
flex-direction: column;
min-height: 0;
background-color: #fff;
height: 100vh;
position: relative;
}
:global(:root) {
--resizeable-height: 200px;
--tab-width: 60px;
}
@media (min-width: 640px) {
.app {
max-width: none;
}
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.flex-scrollable-parent {
position: relative;
display: flex;
flex: 1;
}
.flex-scrollable-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.wrapper {
position: relative;
z-index: 10;
}
</style>
Loading

0 comments on commit 7ff3197

Please sign in to comment.