oxen-electron-gui-wallet/src/components/ons/ons_input.vue

208 lines
5.5 KiB
Vue
Raw Normal View History

<template>
2021-04-06 05:23:47 +02:00
<div class="ons-input">
<ONSInputForm
ref="form"
:submit-label="submit_label"
:disable-name="updating || renewing"
:updating="updating"
:renewing="renewing"
:show-clear-button="updating || renewing"
:disable-submit-button="disable_submit_button"
@onSubmit="onSubmit"
@onClear="onClear"
/>
2021-04-06 05:23:47 +02:00
<q-inner-loading :showing="ons_status.sending" :dark="theme == 'dark'">
<q-spinner color="primary" size="30" />
</q-inner-loading>
</div>
</template>
<script>
import { mapState } from "vuex";
2021-04-06 05:23:47 +02:00
import ONSInputForm from "./ons_input_form";
import WalletPassword from "src/mixins/wallet_password";
const objectAssignDeep = require("object-assign-deep");
export default {
2021-04-06 05:23:47 +02:00
name: "ONSInput",
components: {
2021-04-06 05:23:47 +02:00
ONSInputForm
},
mixins: [WalletPassword],
data() {
return {
updating: false,
renewing: false
};
},
computed: mapState({
theme: state => state.gateway.app.config.appearance.theme,
2021-04-06 05:23:47 +02:00
ons_status: state => state.gateway.ons_status,
unlocked_balance: state => state.gateway.wallet.info.unlocked_balance,
disable_submit_button() {
const minBalance = this.updating ? 0.05 : 7.1;
return this.unlocked_balance < minBalance * 1e9;
},
submit_label() {
let label = "buttons.purchase";
if (this.updating) {
label = "buttons.update";
} else if (this.renewing) {
label = "buttons.renew";
}
return this.$t(label);
}
}),
watch: {
2021-04-06 05:23:47 +02:00
ons_status: {
handler(val, old) {
if (val.code == old.code) return;
const { code, message } = val;
switch (code) {
case 0:
this.$q.notify({
type: "positive",
timeout: 1000,
message
});
this.$refs.form.reset();
2020-10-09 02:18:39 +02:00
this.renewing = false;
this.updating = false;
break;
case -1:
this.$q.notify({
type: "negative",
timeout: 3000,
message
});
break;
}
},
deep: true
}
},
methods: {
startUpdating(record) {
this.$refs.form.setRecord(record);
this.updating = true;
},
startRenewing(record) {
this.renewing = true;
// set the type such that we default to one year
let renewRecord = {
...record,
type: "lokinet_1y"
};
this.$refs.form.setRecord(renewRecord);
},
onSubmit(record) {
if (this.updating) {
this.update(record);
2020-10-08 10:59:30 +02:00
} else if (this.renewing) {
this.renew(record);
} else {
this.purchase(record);
}
},
onClear() {
this.$refs.form.reset();
this.updating = false;
this.renewing = false;
},
async update(record) {
const updatedRecord = {
...record,
value: record.value,
owner: record.owner,
backup_owner: record.backup_owner
};
UI upgrade (#155) * followed upgrade instructions on quasar site * followed upgrade instructions on quasar site * debug messages now show * Fix template error mode undefined * building and working, UI broken, need to move to new quasar components * move collapsible to expansion-item * moving over components to quasar v1+ * items to labels * items and item side to quasar v1 * fix label typo * item main to item label * q-section to q-item-section * popover to menu * modals to v1 quasar * Remove debug lines, use new dialog methods * move static folder up a dir and rename to public. Change paths accordingly * Exit modal fixed with v1 quasar * UI fixes for v1 quasar * remove link styles * some field updates * Fix more fields and modals for v1 * more fields updated * more fields changed over * wallet settings modals * Fix password confirm dialog issue w/ refactor * begin generalising a copy component * Receive item looking better * Index view vixed for v1 quasar * fix export/import keys modal * tx styles and some others * bunch of small style changes * Fix date display on restore page * completed upgrade to v1 quasar (I think) * lns list fixed, stake buttons fixed * fix favourite checkbox with v1 quasar * Address book fixes * Fix the context menus * clean up * remove mixin from copyicon * Fix webpack * fix QR code view on address detail page * Fix welcome stepper and default to blink * Fix some style issues * radio buttons w/ white circles * clean up * sn style fixes, and other fixes * style fixes and unlock bug fixed * fix daemon typo * Fix some style things * fix button colour Co-authored-by: Kyle Zsembery <zsembery.kyle@gmail.com>
2020-08-31 07:26:06 +02:00
let passwordDialog = await this.showPasswordConfirmation({
2021-04-06 05:23:47 +02:00
title: this.$t("dialog.onsUpdate.title"),
noPasswordMessage: this.$t("dialog.onsUpdate.message"),
ok: {
2021-04-06 05:23:47 +02:00
label: this.$t("dialog.onsUpdate.ok"),
UI upgrade (#155) * followed upgrade instructions on quasar site * followed upgrade instructions on quasar site * debug messages now show * Fix template error mode undefined * building and working, UI broken, need to move to new quasar components * move collapsible to expansion-item * moving over components to quasar v1+ * items to labels * items and item side to quasar v1 * fix label typo * item main to item label * q-section to q-item-section * popover to menu * modals to v1 quasar * Remove debug lines, use new dialog methods * move static folder up a dir and rename to public. Change paths accordingly * Exit modal fixed with v1 quasar * UI fixes for v1 quasar * remove link styles * some field updates * Fix more fields and modals for v1 * more fields updated * more fields changed over * wallet settings modals * Fix password confirm dialog issue w/ refactor * begin generalising a copy component * Receive item looking better * Index view vixed for v1 quasar * fix export/import keys modal * tx styles and some others * bunch of small style changes * Fix date display on restore page * completed upgrade to v1 quasar (I think) * lns list fixed, stake buttons fixed * fix favourite checkbox with v1 quasar * Address book fixes * Fix the context menus * clean up * remove mixin from copyicon * Fix webpack * fix QR code view on address detail page * Fix welcome stepper and default to blink * Fix some style issues * radio buttons w/ white circles * clean up * sn style fixes, and other fixes * style fixes and unlock bug fixed * fix daemon typo * Fix some style things * fix button colour Co-authored-by: Kyle Zsembery <zsembery.kyle@gmail.com>
2020-08-31 07:26:06 +02:00
color: "primary"
},
2021-01-06 06:26:42 +01:00
color: "#1F1C47"
UI upgrade (#155) * followed upgrade instructions on quasar site * followed upgrade instructions on quasar site * debug messages now show * Fix template error mode undefined * building and working, UI broken, need to move to new quasar components * move collapsible to expansion-item * moving over components to quasar v1+ * items to labels * items and item side to quasar v1 * fix label typo * item main to item label * q-section to q-item-section * popover to menu * modals to v1 quasar * Remove debug lines, use new dialog methods * move static folder up a dir and rename to public. Change paths accordingly * Exit modal fixed with v1 quasar * UI fixes for v1 quasar * remove link styles * some field updates * Fix more fields and modals for v1 * more fields updated * more fields changed over * wallet settings modals * Fix password confirm dialog issue w/ refactor * begin generalising a copy component * Receive item looking better * Index view vixed for v1 quasar * fix export/import keys modal * tx styles and some others * bunch of small style changes * Fix date display on restore page * completed upgrade to v1 quasar (I think) * lns list fixed, stake buttons fixed * fix favourite checkbox with v1 quasar * Address book fixes * Fix the context menus * clean up * remove mixin from copyicon * Fix webpack * fix QR code view on address detail page * Fix welcome stepper and default to blink * Fix some style issues * radio buttons w/ white circles * clean up * sn style fixes, and other fixes * style fixes and unlock bug fixed * fix daemon typo * Fix some style things * fix button colour Co-authored-by: Kyle Zsembery <zsembery.kyle@gmail.com>
2020-08-31 07:26:06 +02:00
});
passwordDialog
.onOk(password => {
// if no password set
password = password || "";
2021-04-06 05:23:47 +02:00
this.$store.commit("gateway/set_ons_status", {
code: 1,
message: "Sending transaction",
sending: true
});
2021-04-06 05:23:47 +02:00
const ons = objectAssignDeep.noMutate(updatedRecord, {
password
});
2021-04-06 05:23:47 +02:00
this.$gateway.send("wallet", "update_ons_mapping", ons);
})
UI upgrade (#155) * followed upgrade instructions on quasar site * followed upgrade instructions on quasar site * debug messages now show * Fix template error mode undefined * building and working, UI broken, need to move to new quasar components * move collapsible to expansion-item * moving over components to quasar v1+ * items to labels * items and item side to quasar v1 * fix label typo * item main to item label * q-section to q-item-section * popover to menu * modals to v1 quasar * Remove debug lines, use new dialog methods * move static folder up a dir and rename to public. Change paths accordingly * Exit modal fixed with v1 quasar * UI fixes for v1 quasar * remove link styles * some field updates * Fix more fields and modals for v1 * more fields updated * more fields changed over * wallet settings modals * Fix password confirm dialog issue w/ refactor * begin generalising a copy component * Receive item looking better * Index view vixed for v1 quasar * fix export/import keys modal * tx styles and some others * bunch of small style changes * Fix date display on restore page * completed upgrade to v1 quasar (I think) * lns list fixed, stake buttons fixed * fix favourite checkbox with v1 quasar * Address book fixes * Fix the context menus * clean up * remove mixin from copyicon * Fix webpack * fix QR code view on address detail page * Fix welcome stepper and default to blink * Fix some style issues * radio buttons w/ white circles * clean up * sn style fixes, and other fixes * style fixes and unlock bug fixed * fix daemon typo * Fix some style things * fix button colour Co-authored-by: Kyle Zsembery <zsembery.kyle@gmail.com>
2020-08-31 07:26:06 +02:00
.onDismiss(() => {})
.onCancel(() => {});
},
UI upgrade (#155) * followed upgrade instructions on quasar site * followed upgrade instructions on quasar site * debug messages now show * Fix template error mode undefined * building and working, UI broken, need to move to new quasar components * move collapsible to expansion-item * moving over components to quasar v1+ * items to labels * items and item side to quasar v1 * fix label typo * item main to item label * q-section to q-item-section * popover to menu * modals to v1 quasar * Remove debug lines, use new dialog methods * move static folder up a dir and rename to public. Change paths accordingly * Exit modal fixed with v1 quasar * UI fixes for v1 quasar * remove link styles * some field updates * Fix more fields and modals for v1 * more fields updated * more fields changed over * wallet settings modals * Fix password confirm dialog issue w/ refactor * begin generalising a copy component * Receive item looking better * Index view vixed for v1 quasar * fix export/import keys modal * tx styles and some others * bunch of small style changes * Fix date display on restore page * completed upgrade to v1 quasar (I think) * lns list fixed, stake buttons fixed * fix favourite checkbox with v1 quasar * Address book fixes * Fix the context menus * clean up * remove mixin from copyicon * Fix webpack * fix QR code view on address detail page * Fix welcome stepper and default to blink * Fix some style issues * radio buttons w/ white circles * clean up * sn style fixes, and other fixes * style fixes and unlock bug fixed * fix daemon typo * Fix some style things * fix button colour Co-authored-by: Kyle Zsembery <zsembery.kyle@gmail.com>
2020-08-31 07:26:06 +02:00
async purchase(record) {
let passwordDialog = await this.showPasswordConfirmation({
title: this.$t("dialog.purchase.title"),
noPasswordMessage: this.$t("dialog.purchase.message"),
ok: {
UI upgrade (#155) * followed upgrade instructions on quasar site * followed upgrade instructions on quasar site * debug messages now show * Fix template error mode undefined * building and working, UI broken, need to move to new quasar components * move collapsible to expansion-item * moving over components to quasar v1+ * items to labels * items and item side to quasar v1 * fix label typo * item main to item label * q-section to q-item-section * popover to menu * modals to v1 quasar * Remove debug lines, use new dialog methods * move static folder up a dir and rename to public. Change paths accordingly * Exit modal fixed with v1 quasar * UI fixes for v1 quasar * remove link styles * some field updates * Fix more fields and modals for v1 * more fields updated * more fields changed over * wallet settings modals * Fix password confirm dialog issue w/ refactor * begin generalising a copy component * Receive item looking better * Index view vixed for v1 quasar * fix export/import keys modal * tx styles and some others * bunch of small style changes * Fix date display on restore page * completed upgrade to v1 quasar (I think) * lns list fixed, stake buttons fixed * fix favourite checkbox with v1 quasar * Address book fixes * Fix the context menus * clean up * remove mixin from copyicon * Fix webpack * fix QR code view on address detail page * Fix welcome stepper and default to blink * Fix some style issues * radio buttons w/ white circles * clean up * sn style fixes, and other fixes * style fixes and unlock bug fixed * fix daemon typo * Fix some style things * fix button colour Co-authored-by: Kyle Zsembery <zsembery.kyle@gmail.com>
2020-08-31 07:26:06 +02:00
label: this.$t("dialog.purchase.ok"),
color: "primary"
2021-01-06 06:26:42 +01:00
}
UI upgrade (#155) * followed upgrade instructions on quasar site * followed upgrade instructions on quasar site * debug messages now show * Fix template error mode undefined * building and working, UI broken, need to move to new quasar components * move collapsible to expansion-item * moving over components to quasar v1+ * items to labels * items and item side to quasar v1 * fix label typo * item main to item label * q-section to q-item-section * popover to menu * modals to v1 quasar * Remove debug lines, use new dialog methods * move static folder up a dir and rename to public. Change paths accordingly * Exit modal fixed with v1 quasar * UI fixes for v1 quasar * remove link styles * some field updates * Fix more fields and modals for v1 * more fields updated * more fields changed over * wallet settings modals * Fix password confirm dialog issue w/ refactor * begin generalising a copy component * Receive item looking better * Index view vixed for v1 quasar * fix export/import keys modal * tx styles and some others * bunch of small style changes * Fix date display on restore page * completed upgrade to v1 quasar (I think) * lns list fixed, stake buttons fixed * fix favourite checkbox with v1 quasar * Address book fixes * Fix the context menus * clean up * remove mixin from copyicon * Fix webpack * fix QR code view on address detail page * Fix welcome stepper and default to blink * Fix some style issues * radio buttons w/ white circles * clean up * sn style fixes, and other fixes * style fixes and unlock bug fixed * fix daemon typo * Fix some style things * fix button colour Co-authored-by: Kyle Zsembery <zsembery.kyle@gmail.com>
2020-08-31 07:26:06 +02:00
});
passwordDialog
.onOk(password => {
// if no password set
password = password || "";
2021-04-06 05:23:47 +02:00
this.$store.commit("gateway/set_ons_status", {
code: 1,
message: "Sending transaction",
sending: true
});
2021-04-06 05:23:47 +02:00
const ons = objectAssignDeep.noMutate(record, {
password
});
2021-04-06 05:23:47 +02:00
this.$gateway.send("wallet", "purchase_ons", ons);
})
UI upgrade (#155) * followed upgrade instructions on quasar site * followed upgrade instructions on quasar site * debug messages now show * Fix template error mode undefined * building and working, UI broken, need to move to new quasar components * move collapsible to expansion-item * moving over components to quasar v1+ * items to labels * items and item side to quasar v1 * fix label typo * item main to item label * q-section to q-item-section * popover to menu * modals to v1 quasar * Remove debug lines, use new dialog methods * move static folder up a dir and rename to public. Change paths accordingly * Exit modal fixed with v1 quasar * UI fixes for v1 quasar * remove link styles * some field updates * Fix more fields and modals for v1 * more fields updated * more fields changed over * wallet settings modals * Fix password confirm dialog issue w/ refactor * begin generalising a copy component * Receive item looking better * Index view vixed for v1 quasar * fix export/import keys modal * tx styles and some others * bunch of small style changes * Fix date display on restore page * completed upgrade to v1 quasar (I think) * lns list fixed, stake buttons fixed * fix favourite checkbox with v1 quasar * Address book fixes * Fix the context menus * clean up * remove mixin from copyicon * Fix webpack * fix QR code view on address detail page * Fix welcome stepper and default to blink * Fix some style issues * radio buttons w/ white circles * clean up * sn style fixes, and other fixes * style fixes and unlock bug fixed * fix daemon typo * Fix some style things * fix button colour Co-authored-by: Kyle Zsembery <zsembery.kyle@gmail.com>
2020-08-31 07:26:06 +02:00
.onDismiss(() => {})
.onCancel(() => {});
2020-10-08 10:59:30 +02:00
},
async renew(record) {
let passwordDialog = await this.showPasswordConfirmation({
title: this.$t("dialog.renew.title"),
noPasswordMessage: this.$t("dialog.renew.message"),
ok: {
label: this.$t("dialog.renew.ok"),
color: "primary"
},
dark: this.theme == "dark",
color: this.theme == "dark" ? "white" : "dark"
});
passwordDialog
.onOk(password => {
// if no password set
password = password || "";
2021-04-06 05:23:47 +02:00
this.$store.commit("gateway/set_ons_status", {
2020-10-08 10:59:30 +02:00
code: 1,
message: "Sending renew mapping transaction",
sending: true
});
const params = {
type: record.type,
name: record.name,
password
};
2021-04-06 05:23:47 +02:00
this.$gateway.send("wallet", "ons_renew_mapping", params);
2020-10-08 10:59:30 +02:00
})
.onDismiss(() => {})
.onCancel(() => {});
}
}
};
</script>
<style lang="scss"></style>