Browse Source

Site constructor

vue
Lev 2 years ago
parent
commit
d2dce44868
  1. 13
      .idea/workspace.xml
  2. 4
      src/api.ts
  3. 10
      src/components/SiteSettings.vue
  4. 10
      src/result.ts
  5. 32
      src/views/Explore.vue

13
.idea/workspace.xml

@ -2,9 +2,9 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="ddb8afd5-d3ba-47b1-b6d0-227403f1abf7" name="Changes" comment="SiteSettings">
<change afterPath="$PROJECT_DIR$/src/components/SiteSettings.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/api.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/api.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/SiteSettings.vue" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/SiteSettings.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/result.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/result.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/views/Explore.vue" beforeDir="false" afterPath="$PROJECT_DIR$/src/views/Explore.vue" afterDir="false" />
</list>
@ -100,7 +100,7 @@
<workItem from="1675542984242" duration="370000" />
<workItem from="1677945869469" duration="608000" />
<workItem from="1678007103478" duration="1012000" />
<workItem from="1678136230438" duration="19501000" />
<workItem from="1678136230438" duration="23126000" />
</task>
<task id="LOCAL-00001" summary="Wrote the landing">
<created>1670844191163</created>
@ -249,7 +249,14 @@
<option name="project" value="LOCAL" />
<updated>1674596285797</updated>
</task>
<option name="localTasksCounter" value="22" />
<task id="LOCAL-00022" summary="SiteSettings">
<created>1678286612958</created>
<option name="number" value="00022" />
<option name="presentableId" value="LOCAL-00022" />
<option name="project" value="LOCAL" />
<updated>1678286612958</updated>
</task>
<option name="localTasksCounter" value="23" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">

4
src/api.ts

@ -24,3 +24,7 @@ export const config = new Api();
export async function call_api(url: string) {
return (await axios.get(config.api_url + url)).data;
}
export async function call_api_post(url: string, data: any) {
return (await axios.post(config.api_url + url, data)).data;
}

10
src/components/SiteSettings.vue

@ -49,6 +49,7 @@
import Socket from "./Socket.vue";
import contenteditable from 'vue-contenteditable';
import {config} from "../api";
import {SiteConstructorParams} from "../result";
export default {
name: "SiteSettings",
@ -77,8 +78,8 @@ export default {
return {
site_rec,
constructor_site,
constructor_params: {title: ''},
saved_constructor_params: {title: ''},
constructor_params: new SiteConstructorParams(''),
saved_constructor_params: new SiteConstructorParams(''),
}
},
watch: {
@ -92,8 +93,9 @@ export default {
deep: true
},
saved_constructor_params: {
handler: function (newVal) {
this.$emit('change-constructor', newVal);
handler: function (newVal, oldVal) {
if (newVal === oldVal) return;
this.constructor_params = newVal.copy();
},
deep: true
},

10
src/result.ts

@ -2,6 +2,7 @@
import {Zone} from "@/zone";
import type {Message} from "@/utils";
import type {Collection} from "@/collection";
import {call_api} from "@/api";
// let ex_collection = () => new Collection("example.ton", "Example collection");
@ -150,4 +151,13 @@ export class SiteConstructorParams {
this.domain = domain;
this.title = title;
}
copy(): SiteConstructorParams {
return new SiteConstructorParams(this.domain, this.title);
}
}
export async function get_constr_params(domain: string) {
let res = await call_api('get-site-data/' + domain);
return new SiteConstructorParams(res.domain, res.title);
}

32
src/views/Explore.vue

@ -43,7 +43,8 @@
</div>
</div>
<SiteSettings ref="site_settings"
@save="saveSite()" @change="site_rec = $event" @change-constructor="constructor_params = $event"
@save="saveSite()" @save-constructor="saveSiteConstr()"
@change="site_rec = $event" @change-constructor="constructor_params = $event"
:site-changed="siteChanged" :signing-site="signingSite"/>
</div>
<div v-else>
@ -63,10 +64,10 @@
import DarkLayout from "../components/DarkLayout.vue";
import DomainBar from "../components/DomainBar.vue";
import RotateSquare2 from "../components/RotateSquare2.vue";
import {get_domain_result, get_records, SiteConstructorParams} from "../result";
import {get_constr_params, get_domain_result, get_records, SiteConstructorParams} from "../result";
import {convertAddress} from "../utils";
import contenteditable from 'vue-contenteditable';
import {call_api} from "../api";
import {call_api, call_api_post, config} from "../api";
import Socket from "../components/Socket.vue";
import SiteSettings from "../components/SiteSettings.vue";
@ -96,12 +97,18 @@ export default {
setInterval(() => get_domain_result(this.domain, this.$store.getters.address).then(r => {
this.result = Object.assign({}, r);
if (this.isMine) {
get_constr_params(this.domain).then(r => {
this.constructor_params = r;
this.saved_constructor_params = r;
this.updSettingsComponent();
});
get_records(r.nft_info.address).then(r => {
this.records = r;
// this.timer = setTimeout(this.updRecords, 10000);
this.updSettingsComponent()
})
}
}), 7000);
}), 10000);
},
computed: {
core_domain() {
@ -128,7 +135,11 @@ export default {
return this.records && this.wallet_rec !== this.records.wallet;
},
siteChanged() {
return this.records && this.site_rec !== this.records.site;
let constr_change = false;
if (this.site_rec === config.agorata_adnl) {
constr_change = this.constructor_params.title !== this.saved_constructor_params.title;
}
return this.records && (this.site_rec !== this.records.site || constr_change);
},
settingsCompLoaded() {
return this.$refs.site_settings !== undefined;
@ -190,6 +201,12 @@ export default {
}
this.records.site = this.site_rec;
},
async saveSiteConstr() {
await this.saveSite();
await call_api_post('set-site-data', this.constructor_params);
this.saved_constructor_params = this.constructor_params;
this.updSettingsComponent();
},
updRecords() {
get_records(this.result.nft_info.address).then(r => {
if (this.records.wallet !== r.wallet || this.records.site !== r.site) {
@ -219,6 +236,11 @@ export default {
if (!this.loading && this.settingsCompLoaded) {
this.updSettingsComponent();
}
},
loading () {
if (!this.loading && this.settingsCompLoaded) {
this.updSettingsComponent();
}
}
}
}

Loading…
Cancel
Save