diff --git a/README.md b/README.md index a141d82343d595629dbc3cb60757e20da9468d7b..b79f88024990a28ac675ddb073219331d83c99c7 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ pnpm dev After exporting the data to json files with the Rust script from `v2s-datapod`. ```sh +# takes about 200 seconds (4 minutes) time npx tsx src/scripts/cesium-plus-import.ts ``` @@ -19,4 +20,6 @@ You can then manually pin the cid according to the command output. ```sh ipfs pin add -r bafyreie74jtf23zzz2tdgsz7axfrm4pidje43ypqn25v4gkdtfjbcj62km -``` \ No newline at end of file +``` + +This will make easier to insert this data in any AMT or other data structure. \ No newline at end of file diff --git a/src/cesium-plus.ts b/src/cesium-plus.ts index 09eb75b0586c19392553baa98076f50daae79a1d..5ca1a1cd9b48509b3a1fb603a44e460897aa9b38 100644 --- a/src/cesium-plus.ts +++ b/src/cesium-plus.ts @@ -4,7 +4,7 @@ import { Buffer } from 'buffer' // for reference see // https://doc.e-is.pro/cesium-plus-pod/REST_API.html -interface CplusProfile { +export interface CplusProfile { version: number title: string description: string diff --git a/src/views/CplusView.vue b/src/views/CplusView.vue index 7568f7d86cac14a6a4ae44d48dc5c740761891e8..e4cd5ba7060e2a0bf9aaefe2a3a31d022ea1a462 100644 --- a/src/views/CplusView.vue +++ b/src/views/CplusView.vue @@ -1,26 +1,28 @@ <script setup lang="ts"> -import { ref, type Ref } from 'vue' -import { processCesiumPlusImport } from '../cesium-plus' -import type { CID } from 'kubo-rpc-client' +import { ref, type Ref, computed } from 'vue' +import { processCesiumPlusProfile, type CplusProfile } from '../cesium-plus' const file: Ref<File | null> = ref(null) const sample = ref('') -const importResult: Ref<CID | null> = ref(null) +const cidlist = ref('') +const MAX = 20 -async function setfile(input: any) { +function setfile(input: any) { file.value = input.target.files[0] } -async function importCplus() { +function importCplus() { + cidlist.value = '' if (file.value) { console.log(file.value) - const reader = new FileReader() reader.onload = function (event) { const obj = JSON.parse(event.target!.result as string) console.log(obj) sample.value = JSON.stringify(obj[0], undefined, 4) - processCesiumPlusImport(obj.slice(0, 10)).then((cid) => (importResult.value = cid)) + obj + .slice(0, MAX) + .map((e: CplusProfile) => processCesiumPlusProfile(e).then((c) => (cidlist.value += c.toString() + '\n'))) } reader.readAsText(file.value) } @@ -28,19 +30,23 @@ async function importCplus() { </script> <template> - <main> - <h1>Cesium Plus</h1> - <h2>Import</h2> - <p>Import data from Cesium+</p> - <p> - json input file: - <input type="file" @change="setfile" /> - <button v-on:click="importCplus">Import</button> - </p> - <p>sample:</p> + <h1>Cesium Plus</h1> + <h2>Import from file</h2> + <p>Import data from Cesium+</p> + <p> + json input file: + <input type="file" @change="setfile" /> + <button v-on:click="importCplus">Import</button> (max {{ MAX }}) + </p> + <details> + <summary>sample:</summary> <pre>{{ sample }}</pre> - <p>root node for import: {{ importResult }}</p> - </main> + </details> + <p>list of imported cids:</p> + <pre>{{ cidlist }}</pre> + + <h2>Import from root cid</h2> + <p>Choose a root CID from Cesium import and the root CID of the target AMT</p> </template> <style scoped></style>