From 3fb1b1a6d6a4f1051e89e92d99b580bff1a7fb26 Mon Sep 17 00:00:00 2001 From: ennucore Date: Wed, 8 Mar 2023 15:43:32 +0100 Subject: [PATCH] SiteSettings --- .idea/workspace.xml | 29 +++-- src/api.ts | 1 + src/components/SiteSettings.vue | 192 ++++++++++++++++++++++++++++++++ src/result.ts | 20 +++- src/views/Explore.vue | 155 +++++++++++++++++--------- 5 files changed, 330 insertions(+), 67 deletions(-) create mode 100644 src/components/SiteSettings.vue diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f3324e9..94c69cd 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,10 +1,11 @@ - - + + - + + @@ -274,6 +287,8 @@ - \ No newline at end of file diff --git a/src/api.ts b/src/api.ts index e997b80..1fa5f7e 100644 --- a/src/api.ts +++ b/src/api.ts @@ -8,6 +8,7 @@ declare var process : { export class Api { public readonly api_url: string; + public agorata_adnl: string = "3a3a4515e9092ef501d8d820a2964b42abfe541b7aff3d85f9fe5375bc62de9e"; constructor() { if (process.env.NODE_ENV === 'development') { diff --git a/src/components/SiteSettings.vue b/src/components/SiteSettings.vue new file mode 100644 index 0000000..c414e59 --- /dev/null +++ b/src/components/SiteSettings.vue @@ -0,0 +1,192 @@ + + + + + \ No newline at end of file diff --git a/src/result.ts b/src/result.ts index a3c55d1..3e63519 100644 --- a/src/result.ts +++ b/src/result.ts @@ -1,11 +1,10 @@ // import {call_api} from "@/api"; import {Zone} from "@/zone"; -import {Collection} from "@/collection"; import type {Message} from "@/utils"; import {call_api} from "@/api"; -let ex_collection = () => new Collection("example.ton", "Example collection"); +// let ex_collection = () => new Collection("example.ton", "Example collection"); export class Result { domain: string; @@ -65,9 +64,9 @@ export class Result { } } -const sleep = (milliseconds: number) => { - return new Promise(resolve => setTimeout(resolve, milliseconds)) -} +// const sleep = (milliseconds: number) => { +// return new Promise(resolve => setTimeout(resolve, milliseconds)) +// } export async function get_search_results(query: string) { return Result.fromBackend(await call_api('find/' + query)); @@ -80,7 +79,7 @@ export async function get_search_results(query: string) { ];*/ } -export async function get_domain_result(domain: string, address?: string) { +export async function get_domain_result(domain: string, _address?: string) { return Result.fromBackend(await call_api('get/' + domain)); /*await sleep(100); if (domain === 'test.ton') { @@ -143,3 +142,12 @@ export class TonLink { export function get_ton_link(res: Result) { return new TonLink(res.zone(), 'b/' + res.domain, res.buy_price!); } + +export class SiteConstructorParams { + domain: string; + title: string; + constructor(domain: string, title: string = '') { + this.domain = domain; + this.title = title; + } +} diff --git a/src/views/Explore.vue b/src/views/Explore.vue index d7b9ad2..b3933ce 100644 --- a/src/views/Explore.vue +++ b/src/views/Explore.vue @@ -8,52 +8,52 @@ - -
- -
-
-
-

{{ domain }}

-
is owned by -
{{ ownerAddr }}
-
- View nft +
+ +
+
-
-

{{ domain }}

-
is owned by -
you
-
- View nft -
-
-
-

Wallet:

- -
- Save -
+
+
+

{{ domain }}

+
is owned by +
{{ ownerAddr }}
+ View nft
-
-
-

Site:

- -
Save +
+

{{ domain }}

+
is owned by +
you
+
+ View nft +
+
+
+

Wallet:

+ +
+ + +
+ +
+
+ This domain is not owned. + + +
-
-
- This domain is not owned. - - -
@@ -63,38 +63,45 @@ import DarkLayout from "../components/DarkLayout.vue"; import DomainBar from "../components/DomainBar.vue"; import RotateSquare2 from "../components/RotateSquare2.vue"; -import {get_domain_result, get_records} from "../result"; +import {get_domain_result, get_records, SiteConstructorParams} from "../result"; import {convertAddress} from "../utils"; import contenteditable from 'vue-contenteditable'; import {call_api} from "../api"; +import Socket from "../components/Socket.vue"; +import SiteSettings from "../components/SiteSettings.vue"; export default { name: "Explore", - components: {DomainBar, DarkLayout, RotateSquare2, contenteditable}, + components: {SiteSettings, Socket, DomainBar, DarkLayout, RotateSquare2, contenteditable}, props: { domain: { type: String, } }, data() { + let saved_constructor_params = new SiteConstructorParams(this.domain, this.domain); return { result: null, - records: null, + records: {wallet: null, storage: null, uri: null, next_resolver: null, site: null}, wallet_rec: null, site_rec: null, signingSite: false, - signingWallet: false + signingWallet: false, + constructor_params: saved_constructor_params, + saved_constructor_params, + timer: '' } }, mounted() { - get_domain_result(this.domain, this.$store.getters.address).then(r => { - this.result = r; + setInterval(() => get_domain_result(this.domain, this.$store.getters.address).then(r => { + this.result = Object.assign({}, r); if (this.isMine) { get_records(r.nft_info.address).then(r => { this.records = r; + // this.timer = setTimeout(this.updRecords, 10000); }) } - }) + }), 7000); }, computed: { core_domain() { @@ -122,6 +129,9 @@ export default { }, siteChanged() { return this.records && this.site_rec !== this.records.site; + }, + settingsCompLoaded() { + return this.$refs.site_settings !== undefined; } }, methods: { @@ -148,12 +158,10 @@ export default { console.log("Sending transaction", transaction); const result = await this.$store.state.connector.sendTransaction(transaction); this.signingWallet = false; - if(!result.boc) { + if (!result.boc) { // todo } - get_records(this.result.nft_info.address).then(r => { - this.records = r; - }) + this.records.wallet = this.wallet_rec; }, async saveSite() { if (!this.siteChanged) { @@ -177,13 +185,22 @@ export default { this.signingSite = true; const result = await this.$store.state.connector.sendTransaction(transaction); this.signingSite = false; - if(!result.boc) { + if (!result.boc) { // todo } + this.records.site = this.site_rec; + }, + updRecords() { get_records(this.result.nft_info.address).then(r => { - this.records = r; + if (this.records.wallet !== r.wallet || this.records.site !== r.site) { + this.records = r; + } }) }, + updSettingsComponent() { + this.$refs.site_settings.set_site_rec(this.site_rec); + this.$refs.site_settings.saved_constructor_params = this.saved_constructor_params; + } }, watch: { records: function (val) { @@ -191,6 +208,17 @@ export default { this.wallet_rec = val.wallet; this.site_rec = val.site; } + }, + site_rec () { + this.$refs.site_settings.set_site_rec(this.site_rec); + }, + saved_constructor_params () { + this.$refs.site_settings.saved_constructor_params = this.saved_constructor_params; + }, + settingsCompLoaded () { + if (!this.loading && this.settingsCompLoaded) { + this.updSettingsComponent(); + } } } } @@ -231,11 +259,30 @@ export default { border-radius: 0.3rem; background-color: #4e5a88; color: white; - min-width: 50%; + min-width: 50vw; width: 100%; } .rec-field:not(:last-child) { margin-bottom: 1rem; } + +.get_b.inactive { + opacity: 0.5; + cursor: default; +} + +.get_b.signing { + /* Center elements inside horizontally, allow rows */ + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + background-color: white; + font-size: 1.4rem; +} + +.wallet-record-field { + font-family: 'Inconsolata', monospace; +} \ No newline at end of file