diff --git a/qortal-ui-core/package.json b/qortal-ui-core/package.json index 5389c651..7cdec4ba 100644 --- a/qortal-ui-core/package.json +++ b/qortal-ui-core/package.json @@ -70,12 +70,11 @@ "file-saver": "2.0.5", "lit": "2.5.0", "lit-translate": "2.0.1", - "postcss": "8.4.20", "pwa-helpers": "0.9.1", "random-sentence-generator": "0.0.8", "redux": "4.2.0", "redux-thunk": "2.4.2", - "rollup": "3.8.1", + "rollup": "3.9.0", "rollup-plugin-node-globals": "1.4.0", "rollup-plugin-progress": "1.1.2", "rollup-plugin-scss": "3.0.0" diff --git a/qortal-ui-crypto/api/transactions/TransferPrivsTransaction.js b/qortal-ui-crypto/api/transactions/TransferPrivsTransaction.js new file mode 100644 index 00000000..f12d837f --- /dev/null +++ b/qortal-ui-crypto/api/transactions/TransferPrivsTransaction.js @@ -0,0 +1,42 @@ +'use strict'; +import TransactionBase from './TransactionBase.js' +import Base58 from '../deps/Base58.js' +import { store } from '../../api.js' +import { QORT_DECIMALS } from '../constants.js' + +export default class TransferPrivsTransaction extends TransactionBase { + constructor() { + super() + this.type = 40 + } + + render(html) { + const conf = store.getState().config + return html` + Are you sure to transfer privileges to this account ? +
+ ${this.theRecipient} +
+ On pressing confirm, the transfer privileges request will be sent! + ` + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + get params() { + const params = super.params + params.push( + this._recipient, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/groups/AddGroupAdminTransaction.js b/qortal-ui-crypto/api/transactions/groups/AddGroupAdminTransaction.js index e69de29b..b4d6c120 100644 --- a/qortal-ui-crypto/api/transactions/groups/AddGroupAdminTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/AddGroupAdminTransaction.js @@ -0,0 +1,53 @@ +'use strict'; +import TransactionBase from "../TransactionBase.js" +import { QORT_DECIMALS } from "../../constants.js" + +export default class AddGroupAdminTransaction extends TransactionBase { + constructor() { + super() + this.type = 24 + } + + render(html) { + return html` + ${this._addAdminDialog1} +
+ ${this.theRecipient} +
+ ${this._addAdminDialog2} + ` + } + + set addAdminDialog1(addAdminDialog1) { + this._addAdminDialog1 = addAdminDialog1 + } + + set addAdminDialog2(addAdminDialog2) { + this._addAdminDialog2 = addAdminDialog2 + } + + set rGroupId(rGroupId) { + this._rGroupId = rGroupId; + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/groups/CancelGroupBanTransaction.js b/qortal-ui-crypto/api/transactions/groups/CancelGroupBanTransaction.js index e69de29b..3e36be23 100644 --- a/qortal-ui-crypto/api/transactions/groups/CancelGroupBanTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/CancelGroupBanTransaction.js @@ -0,0 +1,53 @@ +'use strict'; +import TransactionBase from "../TransactionBase.js" +import { QORT_DECIMALS } from "../../constants.js" + +export default class CancelGroupBanTransaction extends TransactionBase { + constructor() { + super() + this.type = 27 + } + + render(html) { + return html` + ${this._cancelBanMemberDialog1} +
+ ${this.theRecipient} +
+ ${this._cancelBanMemberDialog2} + ` + } + + set cancelBanMemberDialog1(cancelBanMemberDialog1) { + this._cancelBanMemberDialog1= cancelBanMemberDialog1 + } + + set cancelBanMemberDialog2(cancelBanMemberDialog2) { + this._cancelBanMemberDialog2 = cancelBanMemberDialog2 + } + + set rGroupId(rGroupId) { + this._rGroupId = rGroupId + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/groups/CancelGroupInviteTransaction.js b/qortal-ui-crypto/api/transactions/groups/CancelGroupInviteTransaction.js index e69de29b..79d24656 100644 --- a/qortal-ui-crypto/api/transactions/groups/CancelGroupInviteTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/CancelGroupInviteTransaction.js @@ -0,0 +1,60 @@ +'use strict'; +import TransactionBase from "../TransactionBase.js" +import { QORT_DECIMALS } from "../../constants.js" + +export default class CancelGroupInviteTransaction extends TransactionBase { + constructor() { + super() + this.type = 30 + } + + render(html) { + return html` + ${this._cancelInviteDialog1} +
+ ${this._memberName} +
+
+ ${this.theRecipient} +
+ ${this._cancelInviteDialog2} + ` + } + + set memberName(memberName) { + this._memberName = memberName + } + + set cancelInviteDialog1(cancelInviteDialog1) { + this._cancelInviteDialog1 = cancelInviteDialog1 + } + + set cancelInviteDialog2(cancelInviteDialog2) { + this._cancelInviteDialog2 = cancelInviteDialog2 + } + + set rGroupId(rGroupId) { + this._rGroupId = rGroupId; + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/groups/GroupBanTransaction.js b/qortal-ui-crypto/api/transactions/groups/GroupBanTransaction.js index e69de29b..2d6e2d9c 100644 --- a/qortal-ui-crypto/api/transactions/groups/GroupBanTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/GroupBanTransaction.js @@ -0,0 +1,67 @@ +'use strict'; +import TransactionBase from "../TransactionBase.js" +import { QORT_DECIMALS } from "../../constants.js" + +export default class GroupBanTransaction extends TransactionBase { + constructor() { + super() + this.type = 26 + } + + render(html) { + return html` + ${this._banMemberDialog1} +
+ ${this.theRecipient} +
+ ${this._banMemberDialog2} + ` + } + + set banMemberDialog1(banMemberDialog1) { + this._banMemberDialog1= banMemberDialog1 + } + + set banMemberDialog2(banMemberDialog2) { + this._banMemberDialog2 = banMemberDialog2 + } + + set rGroupId(rGroupId) { + this._rGroupId = rGroupId; + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } + + set rBanReason(rBanReason) { + this._rBanReason = rBanReason + this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason.toLocaleLowerCase()) + this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length) + } + + set rBanTime(rBanTime) { + this._rBanTime = rBanTime + this._rBanTimeBytes = this.constructor.utils.int32ToBytes(this._rBanTime) + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._rBanReasonLength, + this._rBanReasonBytes, + this._rBanTimeBytes, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/groups/GroupInviteTransaction.js b/qortal-ui-crypto/api/transactions/groups/GroupInviteTransaction.js index e69de29b..123ab820 100644 --- a/qortal-ui-crypto/api/transactions/groups/GroupInviteTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/GroupInviteTransaction.js @@ -0,0 +1,59 @@ +'use strict'; +import TransactionBase from "../TransactionBase.js" +import { QORT_DECIMALS } from "../../constants.js" + +export default class GroupInviteTransaction extends TransactionBase { + constructor() { + super() + this.type = 29 + } + + render(html) { + return html` + ${this._inviteMemberDialog1} +
+ ${this.theRecipient} +
+ ${this._inviteMemberDialog2} + ` + } + + set inviteMemberDialog1(inviteMemberDialog1) { + this._inviteMemberDialog1= inviteMemberDialog1 + } + + set inviteMemberDialog2(inviteMemberDialog2) { + this._inviteMemberDialog2 = inviteMemberDialog2 + } + + set rGroupId(rGroupId) { + this._rGroupId = rGroupId; + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } + + set rInviteTime(rInviteTime) { + this._rInviteTime = rInviteTime + this._rInviteTimeBytes = this.constructor.utils.int32ToBytes(this._rInviteTime) + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._rInviteTimeBytes, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/groups/GroupKickTransaction.js b/qortal-ui-crypto/api/transactions/groups/GroupKickTransaction.js index e69de29b..12e6d276 100644 --- a/qortal-ui-crypto/api/transactions/groups/GroupKickTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/GroupKickTransaction.js @@ -0,0 +1,61 @@ +'use strict'; +import TransactionBase from "../TransactionBase.js" +import { QORT_DECIMALS } from "../../constants.js" + +export default class GroupKickTransaction extends TransactionBase { + constructor() { + super() + this.type = 28 + } + + render(html) { + return html` + ${this._kickMemberDialog1} +
+ ${this.theRecipient} +
+ ${this._kickMemberDialog2} + ` + } + + set kickMemberDialog1(kickMemberDialog1) { + this._kickMemberDialog1= kickMemberDialog1 + } + + set kickMemberDialog2(kickMemberDialog2) { + this._kickMemberDialog2 = kickMemberDialog2 + } + + set rGroupId(rGroupId) { + this._rGroupId = rGroupId; + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } + + set rBanReason(rBanReason) { + this._rBanReason = rBanReason + this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason.toLocaleLowerCase()) + this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length) + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._rBanReasonLength, + this._rBanReasonBytes, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/groups/RemoveGroupAdminTransaction.js b/qortal-ui-crypto/api/transactions/groups/RemoveGroupAdminTransaction.js index e69de29b..502c6166 100644 --- a/qortal-ui-crypto/api/transactions/groups/RemoveGroupAdminTransaction.js +++ b/qortal-ui-crypto/api/transactions/groups/RemoveGroupAdminTransaction.js @@ -0,0 +1,53 @@ +'use strict'; +import TransactionBase from "../TransactionBase.js" +import { QORT_DECIMALS } from "../../constants.js" + +export default class RemoveGroupAdminTransaction extends TransactionBase { + constructor() { + super() + this.type = 25 + } + + render(html) { + return html` + ${this._kickAdminDialog1} +
+ ${this.theRecipient} +
+ ${this._kickAdminDialog2} + ` + } + + set kickAdminDialog1(kickAdminDialog1) { + this._kickAdminDialog1 = kickAdminDialog1 + } + + set kickAdminDialog2(kickAdminDialog2) { + this._kickAdminDialog2 = kickAdminDialog2 + } + + set rGroupId(rGroupId) { + this._rGroupId = rGroupId; + this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId) + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + get params() { + const params = super.params + params.push( + this._rGroupIdBytes, + this._recipient, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/names/BuyNameTransacion.js b/qortal-ui-crypto/api/transactions/names/BuyNameTransacion.js new file mode 100644 index 00000000..36aa7d60 --- /dev/null +++ b/qortal-ui-crypto/api/transactions/names/BuyNameTransacion.js @@ -0,0 +1,70 @@ +'use strict'; +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' + +export default class BuyNameTransacion extends TransactionBase { + constructor() { + super() + this.type = 7 + } + + render(html) { + return html` + ${this._buyNameDialog1} +
+ ${this.nameText} +
+ ${this._buyNameDialog2} +
+ ${this.showSellPrice} +
+ ${this._buyNameDialog3} + ` + } + + set buyNameDialog1(buyNameDialog1) { + this._buyNameDialog1 = buyNameDialog1 + } + + set buyNameDialog2(buyNameDialog2) { + this._buyNameDialog2 = buyNameDialog2 + } + + set buyNameDialog3(buyNameDialog3) { + this._buyNameDialog3 = buyNameDialog3 + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + set name(name) { + this.nameText = name + this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) + this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) + } + + set sellPrice(sellPrice) { + this.showSellPrice = sellPrice + this._sellPrice = sellPrice * QORT_DECIMALS + this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice) + } + + set recipient(recipient) { + this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) + this.theRecipient = recipient + } + + get params() { + const params = super.params + params.push( + this._nameLength, + this._nameBytes, + this._sellPriceBytes, + this._recipient, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/names/CancelSellNameTransacion.js b/qortal-ui-crypto/api/transactions/names/CancelSellNameTransacion.js new file mode 100644 index 00000000..bc5a69b3 --- /dev/null +++ b/qortal-ui-crypto/api/transactions/names/CancelSellNameTransacion.js @@ -0,0 +1,49 @@ +'use strict'; +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' + +export default class CancelSellNameTransacion extends TransactionBase { + constructor() { + super() + this.type = 6 + } + + render(html) { + return html` + ${this._cancelSellNameDialog1} +
+ ${this.nameText} +
+ ${this._cancelSellNameDialog2} + ` + } + + set cancelSellNameDialog1(cancelSellNameDialog1) { + this._cancelSellNameDialog1 = cancelSellNameDialog1 + } + + set cancelSellNameDialog2(cancelSellNameDialog2) { + this._cancelSellNameDialog2 = cancelSellNameDialog2 + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + set name(name) { + this.nameText = name + this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) + this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) + } + + get params() { + const params = super.params + params.push( + this._nameLength, + this._nameBytes, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/names/SellNameTransacion.js b/qortal-ui-crypto/api/transactions/names/SellNameTransacion.js new file mode 100644 index 00000000..aeb8b72e --- /dev/null +++ b/qortal-ui-crypto/api/transactions/names/SellNameTransacion.js @@ -0,0 +1,64 @@ +'use strict'; +import TransactionBase from '../TransactionBase.js' +import { QORT_DECIMALS } from '../../constants.js' + +export default class SellNameTransacion extends TransactionBase { + constructor() { + super() + this.type = 5 + } + + render(html) { + return html` + ${this._sellNameDialog1} +
+ ${this.nameText} +
+ ${this._sellNameDialog2} +
+ ${this.showSellPrice} +
+ ${this._sellNameDialog3} + ` + } + + set sellNameDialog1(sellNameDialog1) { + this._sellNameDialog1 = sellNameDialog1 + } + + set sellNameDialog2(sellNameDialog2) { + this._sellNameDialog2 = sellNameDialog2 + } + + set sellNameDialog3(sellNameDialog3) { + this._sellNameDialog3 = sellNameDialog3 + } + + set fee(fee) { + this._fee = fee * QORT_DECIMALS + this._feeBytes = this.constructor.utils.int64ToBytes(this._fee) + } + + set name(name) { + this.nameText = name + this._nameBytes = this.constructor.utils.stringtoUTF8Array(name) + this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length) + } + + set sellPrice(sellPrice) { + this.showSellPrice = sellPrice + this._sellPrice = sellPrice * QORT_DECIMALS + this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice) + } + + get params() { + const params = super.params + params.push( + this._nameLength, + this._nameBytes, + this._sellPriceBytes, + this._feeBytes + ) + return params + } +} \ No newline at end of file diff --git a/qortal-ui-crypto/api/transactions/transactions.js b/qortal-ui-crypto/api/transactions/transactions.js index c15cbd25..84f2759b 100644 --- a/qortal-ui-crypto/api/transactions/transactions.js +++ b/qortal-ui-crypto/api/transactions/transactions.js @@ -1,25 +1,47 @@ import PaymentTransaction from './PaymentTransaction.js' -import MessageTransaction from './MessageTransaction.js' import RegisterNameTransaction from './names/RegisterNameTransaction.js' +import SellNameTransacion from './names/SellNameTransacion.js' +import CancelSellNameTransacion from './names/CancelSellNameTransacion.js' +import BuyNameTransacion from './names/BuyNameTransacion.js' +import MessageTransaction from './MessageTransaction.js' import ChatTransaction from './chat/ChatTransaction.js' -import GroupChatTransaction from './chat/GroupChatTransaction.js'; -import RewardShareTransaction from './reward-share/RewardShareTransaction.js' -import RemoveRewardShareTransaction from './reward-share/RemoveRewardShareTransaction.js' -import CreateGroupTransaction from './groups/CreateGroupTransaction.js'; +import GroupChatTransaction from './chat/GroupChatTransaction.js' +import PublicizeTransaction from './PublicizeTransaction.js' +import CreateGroupTransaction from './groups/CreateGroupTransaction.js' +import AddGroupAdminTransaction from './groups/AddGroupAdminTransaction.js' +import RemoveGroupAdminTransaction from './groups/RemoveGroupAdminTransaction.js' +import GroupBanTransaction from './groups/GroupBanTransaction.js' +import CancelGroupBanTransaction from './groups/CancelGroupBanTransaction.js' +import GroupKickTransaction from './groups/GroupKickTransaction.js' +import GroupInviteTransaction from './groups/GroupInviteTransaction.js' +import CancelGroupInviteTransaction from './groups/CancelGroupInviteTransaction.js' import JoinGroupTransaction from './groups/JoinGroupTransaction.js' import LeaveGroupTransaction from './groups/LeaveGroupTransaction.js' -import PublicizeTransaction from './PublicizeTransaction.js' +import RewardShareTransaction from './reward-share/RewardShareTransaction.js' +import RemoveRewardShareTransaction from './reward-share/RemoveRewardShareTransaction.js' +import TransferPrivsTransaction from './TransferPrivsTransaction.js' export const transactionTypes = { 2: PaymentTransaction, 3: RegisterNameTransaction, + 5: SellNameTransacion, + 6: CancelSellNameTransacion, + 7: BuyNameTransacion, 17: MessageTransaction, 18: ChatTransaction, 181: GroupChatTransaction, 19: PublicizeTransaction, 22: CreateGroupTransaction, + 24: AddGroupAdminTransaction, + 25: RemoveGroupAdminTransaction, + 26: GroupBanTransaction, + 27: CancelGroupBanTransaction, + 28: GroupKickTransaction, + 29: GroupInviteTransaction, + 30: CancelGroupInviteTransaction, 31: JoinGroupTransaction, 32: LeaveGroupTransaction, 38: RewardShareTransaction, - 381: RemoveRewardShareTransaction + 381: RemoveRewardShareTransaction, + 40: TransferPrivsTransaction } diff --git a/qortal-ui-plugins/package.json b/qortal-ui-plugins/package.json index 83377e0a..88dfd7af 100644 --- a/qortal-ui-plugins/package.json +++ b/qortal-ui-plugins/package.json @@ -59,7 +59,7 @@ "html-escaper": "3.0.3", "lit": "2.5.0", "lit-translate": "2.0.1", - "rollup": "3.8.1", + "rollup": "3.9.0", "rollup-plugin-node-globals": "1.4.0", "rollup-plugin-progress": "1.1.2" }, diff --git a/qortal-ui-plugins/plugins/core/group-management/group-management.src.js b/qortal-ui-plugins/plugins/core/group-management/group-management.src.js index ee4eedc3..ca28731c 100644 --- a/qortal-ui-plugins/plugins/core/group-management/group-management.src.js +++ b/qortal-ui-plugins/plugins/core/group-management/group-management.src.js @@ -7,11 +7,18 @@ registerTranslateConfig({ loader: lang => fetch(`/language/${lang}.json`).then(res => res.json()) }) -import '@material/mwc-icon' import '@material/mwc-button' -import '@material/mwc-textfield' import '@material/mwc-dialog' +import '@material/mwc-formfield' +import '@material/mwc-icon' +import '@material/mwc-icon-button' +import '@material/mwc-textfield' +import '@polymer/paper-dialog/paper-dialog.js' import '@polymer/paper-spinner/paper-spinner-lite.js' +import '@polymer/paper-progress/paper-progress.js' +import '@vaadin/button' +import '@vaadin/icon' +import '@vaadin/icons' import '@vaadin/grid' import '@vaadin/grid/vaadin-grid-filter-column.js' import '@github/time-elements' @@ -24,6 +31,11 @@ class GroupManagement extends LitElement { loading: { type: Boolean }, publicGroups: { type: Array }, joinedGroups: { type: Array }, + groupInvites: { type: Array }, + newMembersList: { type: Array }, + newAdminsList: { type: Array }, + newBannedList: { type: Array }, + newGroupInvitesList: { type: Array }, recipientPublicKey: { type: String }, selectedAddress: { type: Object }, manageGroupObj: { type: Object }, @@ -31,11 +43,42 @@ class GroupManagement extends LitElement { leaveGroupObj: { type: Object }, btnDisable: { type: Boolean }, isLoading: { type: Boolean }, + createFee: { type: Number }, + joinFee: { type: Number }, + leaveFee: { type: Number }, + addGroupAdminFee: { type: Number }, + kickGroupAdminFee: { type: Number }, + createBanFee: { type: Number }, + cancelBanFee: { type: Number }, + kickGroupMemberFee: { type: Number }, + inviteGroupMemberFee: { type: Number }, + cancelInviteGroupMemberFee: { type: Number }, error: { type: Boolean }, message: { type: String }, removeError: { type: Boolean }, removeMessage: { type: String }, - theme: { type: String, reflect: true } + theme: { type: String, reflect: true }, + selectedView: { type: Object }, + manageGroupId: { type: String }, + theGroupOwner: { type: String }, + manageGroupName: { type: String }, + manageGroupCount: { type: String }, + manageGroupType: { type: String }, + memberToAdmin: { type: String }, + kickGroupAdminAddress: { type: String }, + toBanName: { type: String }, + toBanAddress: { type: String }, + banReason: { type: String }, + toCancelBanName: { type: String }, + toCancelBanAddress: { type: String }, + toKickMemberName: { type: String }, + toKickMemberAddress: { type: String }, + kickMemberReason: { type: String }, + toInviteMemberToGroup: { type: String }, + toCancelInviteMemberName: { type: String }, + toCancelInviteMemberAddress: { type: String }, + errorMessage: { type: String }, + successMessage: { type: String } } } @@ -45,7 +88,13 @@ class GroupManagement extends LitElement { --mdc-theme-primary: rgb(3, 169, 244); --paper-input-container-focus-color: var(--mdc-theme-primary); --mdc-theme-surface: var(--white); + --mdc-text-field-outlined-idle-border-color: var(--txtfieldborder); + --mdc-text-field-outlined-hover-border-color: var(--txtfieldhoverborder); + --mdc-text-field-label-ink-color: var(--black); + --mdc-text-field-ink-color: var(--black); --mdc-dialog-content-ink-color: var(--black); + --mdc-dialog-min-width: 400px; + --mdc-dialog-max-width: 1024px; --lumo-primary-text-color: rgb(0, 167, 245); --lumo-primary-color-50pct: rgba(0, 167, 245, 0.5); --lumo-primary-color-10pct: rgba(0, 167, 245, 0.1); @@ -63,6 +112,180 @@ class GroupManagement extends LitElement { padding: 12px 24px; } + paper-progress { + --paper-progress-active-color: var(--mdc-theme-primary); + } + + paper-dialog.nanage-group { + width: 80%; + max-width: 80vw; + height: 80%; + max-height: 80vh; + background-color: var(--white); + color: var(--black); + border: 1px solid var(--black); + border-radius: 15px; + line-height: 1.6; + overflow-y: auto; + } + + .actions { + display:flex; + justify-content: space-between; + padding: 0 1em; + margin: 12px 0 -6px 0; + } + + .card-container { + background-color: var(--white); + border-radius: 5px; + color: var(--black); + padding-top: 30px; + position: relative; + width: 350px; + max-width: 100%; + text-align: center; + } + + .error-icon { + font-size: 48px; + color: red; + } + + .close-icon { + font-size: 36px; + } + + .close-icon:hover { + cursor: pointer; + opacity: .6; + } + + .buttons { + text-align: right; + } + + .container { + max-width: 90vw; + margin-left: auto; + margin-right: auto; + margin-top: 20px; + padding: .6em; + } + + ul { + list-style: none; + padding: 0; + margin-bottom: 0; + } + + .leftBar { + background-color: var(--white); + color: var(--black); + border: 1px solid var(--border); + padding: 20px 0 0 0; + border-radius: 10px; + } + + .leftBar img { + margin: 0 auto; + width: 75%; + height: 75%; + text-align: center; + } + + .leftBar .slug { + text-align: center; + margin-top: 20px; + color: var(--black); + font-size: 16px; + font-weight: 600; + margin-bottom: 7px; + } + + .leftBar ul li { + border-bottom: 1px solid var(--border); + } + + .leftBar ul li:last-child { + border-bottom: none; + } + + .leftBar ul li a { + color: var(--black); + font-size: 16px; + font-weight: 400; + text-decoration: none; + padding: .9em; + display: block; + } + + .leftBar ul li a i { + margin-right: 8px; + font-size: 16px; + } + + .leftBar ul li a:hover { + background-color: var(--menuhover); + color: #515151; + } + + .leftBar ul li:active { + border-bottom: none; + } + + .leftBar ul li a.active { + color: #515151; + background-color: var(--menuactive); + border-left: 2px solid #515151; + margin-left: -2px; + } + + .mainPage { + background-color: var(--white); + color: var(--black); + border: 1px solid var(--border); + padding: 10px 0 10px 0; + border-radius: 10px; + font-size: 16px; + text-align: center; + min-height: 460px; + } + + @media(max-width:700px) { + .mainPage { + margin-top: 30px; + } + } + + @media(min-width:765px) { + .container { + padding: 2em; + } + + .wrapper { + display: grid; + grid-template-columns: 1fr 5fr; + grid-gap: 20px; + } + + .wrapper > .mainPage { + padding: 2em; + } + + .leftBar { + text-align: left; + max-height: 320px; + max-width: 250px; + font-size: 16px; + } + + .mainPage { + font-size: 16px; + } + + } + mwc-textfield { width:100%; } @@ -71,6 +294,14 @@ class GroupManagement extends LitElement { --mdc-theme-primary: red; } + .warning { + --mdc-theme-primary: #f0ad4e; + } + + .green { + --mdc-theme-primary: #198754; + } + .red-button { --mdc-theme-primary: red; --mdc-theme-on-primary: white; @@ -130,14 +361,64 @@ class GroupManagement extends LitElement { .itemList { padding:0; } + + img { + border-radius: 25%; + max-width: 32px; + height: 100%; + max-height: 32px; + } + + .successBox { + height: 34px; + min-width: 300px; + width: 100%; + border: 1px solid green; + border-radius: 5px; + background-color: transparent; + margin-top: 15px; + } + + .errorBox { + height: 34px; + min-width: 300px; + width: 100%; + border: 1px solid red; + border-radius: 5px; + background-color: transparent; + margin-top: 15px; + } + + .manage-group-dialog { + min-height: 300px; + min-width: 350px; + box-sizing: border-box; + position: relative; + } + + .btn-clear-success { + --mdc-icon-button-size: 32px; + color: red; + } + + .btn-clear-error { + --mdc-icon-button-size: 32px; + color: green; + } ` } constructor() { super() + this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light' this.selectedAddress = {} this.publicGroups = [] this.joinedGroups = [] + this.groupInvites = [] + this.newMembersList = [] + this.newAdminsList = [] + this.newBannedList = [] + this.newGroupInvitesList = [] this.manageGroupObj = {} this.joinGroupObj = {} this.leaveGroupObj = {} @@ -147,7 +428,699 @@ class GroupManagement extends LitElement { this.createFee = 0.001 this.joinFee = 0.001 this.leaveFee = 0.001 - this.theme = localStorage.getItem('qortalTheme') ? localStorage.getItem('qortalTheme') : 'light' + this.addGroupAdminFee = 0.001 + this.kickGroupAdminFee = 0.001 + this.createBanFee = 0.001 + this.cancelBanFee = 0.001 + this.kickGroupMemberFee = 0.001 + this.inviteGroupMemberFee = 0.001 + this.cancelInviteGroupMemberFee = 0.001 + this.manageGroupId = '' + this.theGroupOwner = '' + this.manageGroupName = '' + this.manageGroupCount = '' + this.manageGroupType = '' + this.memberToAdmin = '' + this.kickGroupAdminAddress = '' + this.toBanName = '' + this.toBanAddress = '' + this.banReason = '' + this.toCancelBanName = '' + this.toCancelBanAddress = '' + this.toKickMemberName = '' + this.toKickMemberAddress = '' + this.kickMemberReason = '' + this.toInviteMemberToGroup = '' + this.toCancelInviteMemberName = '' + this.toCancelInviteMemberAddress = '' + this.errorMessage = '' + this.successMessage = '' + this.selectedView = { id: 'group-members', name: 'Group Members' } + } + + groupMemberTemplate() { + return html` + + { + render(html`${this.renderAvatar(data.item)}`, root) + }} + > + { + render(html`${data.item.name}`, root) + }} + > + { + render(html`${data.item.owner}`, root) + }} + > + { + render(html`${this.renderBanButton(data.item)}`, root) + }} + > + { + render(html`${this.renderKickGroupMemberButton(data.item)}`, root) + }} + > + { + render(html`${this.renderMakeAdminButton(data.item.owner)}`, root) + }} + > + + + +
+
+

${translate("managegroup.mg17")}

+
+
+
+

+ + +

+

+ + +

+

+ + +

+

+ ${translate("managegroup.mg20")} + +

+
+

${translate("walletpage.wchange21")} ${this.addGroupAdminFee} QORT

+
+
+ ${this.renderClearSuccess()} + ${this.renderClearError()} + ${this.isLoading ? html`` : ''} +
+
+ this.createBanMember(this.manageGroupId)}> + + ${translate("managegroup.mg17")} + +
+
+
+ + ${translate("general.close")} + +
+ + +
+
+

${translate("managegroup.mg31")}

+
+
+
+

+ + +

+

+ + +

+

+ + +

+
+

${translate("walletpage.wchange21")} ${this.kickGroupMemberFee} QORT

+
+
+ ${this.renderClearSuccess()} + ${this.renderClearError()} + ${this.isLoading ? html`` : ''} +
+
+ this.kickGroupMember(this.manageGroupId)}> + + ${translate("managegroup.mg31")} + +
+
+
+ + ${translate("general.close")} + +
+ + +
+
+

${translate("managegroup.mg10")}

+
+
+
+

+ + +

+
+

${translate("walletpage.wchange21")} ${this.addGroupAdminFee} QORT

+
+
+ ${this.renderClearSuccess()} + ${this.renderClearError()} + ${this.isLoading ? html`` : ''} +
+
+ this.addGroupAdmin(this.manageGroupId)}> + + ${translate("managegroup.mg10")} + +
+
+
+ + ${translate("general.close")} + +
+ ` + } + + groupBannedTemplate() { + return html` + + { + render(html`${this.renderAvatar(data.item)}`, root) + }} + > + { + render(html`${data.item.name}`, root) + }} + > + { + render(html`${data.item.owner}`, root) + }} + > + { + const dateString = new Date(data.item.expiry).toLocaleString() + render(html`${dateString}`, root) + }} + > + { + render(html`${this.renderCancelBanButton(data.item)}`, root) + }} + > + + + +
+
+

${translate("managegroup.mg28")}

+
+
+
+

+ + +

+

+ + +

+
+

${translate("walletpage.wchange21")} ${this.cancelBanFee} QORT

+
+
+ ${this.renderClearSuccess()} + ${this.renderClearError()} + ${this.isLoading ? html`` : ''} +
+
+ this.cancelBanMember(this.manageGroupId)}> + + ${translate("managegroup.mg28")} + +
+
+
+ + ${translate("general.close")} + +
+ ` + } + + groupInviteTemplate() { + return html` + + { + render(html`${this.renderAvatar(data.item)}`, root) + }} + > + { + render(html`${data.item.name}`, root) + }} + > + { + render(html`${data.item.owner}`, root) + }} + > + { + const expiryString = new Date(data.item.expiry).toLocaleString() + render(html`${expiryString}`, root) + }} + > + { + render(html`${this.renderCancelInviteButton(data.item)}`, root) + }} + > + + ${this.isEmptyArray(this.newGroupInvitesList) ? html` + ${translate("managegroup.mg35")} + ` : html``} +
+ this.openInviteMemberToGroupDialog()}> + ${translate("managegroup.mg2")} + +
+ + +
+
+

${translate("managegroup.mg2")}

+
+
+
+

+ + +

+ ${translate("managegroup.mg36")} + +

+
+

${translate("walletpage.wchange21")} ${this.inviteGroupMemberFee} QORT

+
+
+ ${this.renderClearSuccess()} + ${this.renderClearError()} + ${this.isLoading ? html`` : ''} +
+
+ this.openMemberInfo(this.manageGroupId)}> + + ${translate("managegroup.mg2")} + +
+
+
+ + ${translate("general.close")} + +
+ + +
+
+

${translate("managegroup.mg47")}

+
+
+
+

+ + +

+

+ + +

+
+

${translate("walletpage.wchange21")} ${this.cancelInviteGroupMemberFee} QORT

+
+
+ ${this.renderClearSuccess()} + ${this.renderClearError()} + ${this.isLoading ? html`` : ''} +
+
+ this.cancelInviteGroupMember(this.manageGroupId)}> + + ${translate("managegroup.mg47")} + +
+
+
+ + ${translate("general.close")} + +
+ + +
+ warning +

${translate("explorerpage.exp4")}

+

${translate("explorerpage.exp5")}

+
+ + this.closeErrorDialog()} + class="red" + > + ${translate("general.close")} + +
+ + +
+ warning +

${translate("managegroup.mg39")}

+

${translate("walletpage.wchange44")}

+
+ + this.closeFieldErrorDialog()} + class="red" + > + ${translate("general.close")} + +
+ ` + } + + groupAdminTemplate() { + return html` + + { + render(html`${this.renderAvatar(data.item)}`, root) + }} + > + { + render(html`${data.item.name}`, root) + }} + > + { + render(html`${data.item.owner}`, root) + }} + > + { + const dateString = new Date(data.item.joined).toLocaleDateString() + render(html`${dateString}`, root) + }} + > + { + if (this.theGroupOwner === data.item.owner) { + render(html``, root) + } else { + render(html`${this.renderKickAdminButton(data.item.owner)}`, root) + } + }} + > + + + +
+
+

${translate("managegroup.mg13")}

+
+
+
+

+ + +

+
+

${translate("walletpage.wchange21")} ${this.kickGroupAdminFee} QORT

+
+
+ ${this.renderClearSuccess()} + ${this.renderClearError()} + ${this.isLoading ? html`` : ''} +
+
+ this.kickGroupAdmin(this.manageGroupId)}> + + ${translate("managegroup.mg13")} + +
+
+
+ + ${translate("general.close")} + +
+ ` + } + + groupUpdateTemplate() { + return html` +
+

${translate("managegroup.mg50")}

+
+ ` } render() { @@ -167,7 +1140,7 @@ class GroupManagement extends LitElement { { render(html`${this.renderRole(data.item)}`, root) }}> - { + { render(html`${this.renderManageButton(data.item)}`, root) }}> @@ -176,6 +1149,31 @@ class GroupManagement extends LitElement { `: ''} +
+

${translate("managegroup.mg36")}

+ + + + { + if (data.item.isOpen === true) { + render(html`${translate("managegroup.mg44")}`, root) + } else { + render(html`${translate("managegroup.mg45")}`, root) + } + }}> + { + const expiryString = new Date(data.item.expiry).toLocaleString() + render(html`${expiryString}`, root) + }}> + { + render(html` this.joinGroup(data.item)}>queue ${translate("grouppage.gchange51")}`, root) + }}> + + ${this.isEmptyArray(this.groupInvites) ? html` + ${translate("managegroup.mg35")} + `: ''} +
+

${translate("grouppage.gchange9")}

@@ -315,15 +1313,10 @@ class GroupManagement extends LitElement { ${translate("grouppage.gchange31")}
- - ${!this.joinGroupObj.updated ? "" : html`${translate("grouppage.gchange32")} -
-
`}
- ${translate("grouppage.gchange33")}   - - -
${translate("grouppage.gchange38")} ${this.manageGroupObj.groupName}
- - ${translate("general.close")} - -
+ +
+

${translate("grouppage.gchange4")}: ${this.manageGroupName} / ${translate("managegroup.mg8")}: ${this.manageGroupId} / ${translate("grouppage.gchange54")}: ${this.manageGroupCount}

+ this.closeManageGroupOwnerDialog()} title="${translate("managegroup.mg5")}">highlight_off +
+
+
+
+
${translate("grouppage.gchange40")}
+ +
+
+

${this.renderManageGroupHeaderViews()}

+

+ ${html`${this.renderManageGroupViews(this.selectedView)}`} +
+
+
+
@@ -452,6 +1458,13 @@ class GroupManagement extends LitElement { this.unitCreateFee() this.unitJoinFee() this.unitLeaveFee() + this.unitAddGroupAdminFee() + this.unitKickGroupAdminFee() + this.unitCreateBanFee() + this.unitCancelBanFee() + this.unitKickGroupMemberFee() + this.unitInviteGroupMemberFee() + this.unitCancelInviteGroupMemberFee() const getOpenPublicGroups = async () => { let openG = await parentEpml.request('apiCall', { @@ -468,6 +1481,55 @@ class GroupManagement extends LitElement { return joinedG } + const getGroupInvites = async () => { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + + let timerGroupInvites + let myInvitesObj = [] + let myArrObj = [] + this.myGroupInvites = [] + this.myGroupIdArr = [] + + await parentEpml.request('apiCall', { + url: `/groups/invites/${this.selectedAddress.address}` + }).then(res => { + this.myGroupInvites = res + }) + + if (this.isEmptyArray(this.myGroupInvites) === true) { + clearTimeout(timerGroupInvites) + timerGroupInvites = setTimeout(getGroupInvites, 300000) + } else { + this.myGroupInvites.map(a => { + let callTheNewInviteUrl = `${nodeUrl}/groups/${a.groupId}` + fetch(callTheNewInviteUrl).then(res => { + return res.json() + }).then(jsonRes => { + myArrObj.push(jsonRes) + if (myArrObj.length) { + myArrObj.map(b => { + const infoObjToAdd = { + invitee: a.invitee, + groupId: b.groupId, + owner: b.owner, + groupName: b.groupName, + description: b.description, + created: b.created, + isOpen: b.isOpen, + memberCount: b.memberCount, + expiry: a.expiry + } + myInvitesObj.push(infoObjToAdd) + }) + } + this.groupInvites = myInvitesObj + }) + }) + } + setTimeout(getGroupInvites, 300000) + } + const getOpen_JoinedGroups = async () => { let _joinedGroups = await getJoinedGroups() let _publicGroups = await getOpenPublicGroups() @@ -477,7 +1539,7 @@ class GroupManagement extends LitElement { }); this.publicGroups = results this.joinedGroups = _joinedGroups - setTimeout(getOpen_JoinedGroups, this.config.user.nodeSettings.pingInterval) + setTimeout(getOpen_JoinedGroups, 30000) } window.addEventListener("contextmenu", (event) => { @@ -521,6 +1583,7 @@ class GroupManagement extends LitElement { parentEpml.subscribe('config', c => { if (!configLoaded) { setTimeout(getOpen_JoinedGroups, 1) + setTimeout(getGroupInvites, 1) configLoaded = true } this.config = JSON.parse(c) @@ -562,86 +1625,649 @@ class GroupManagement extends LitElement { renderErr2Text() { return html`${translate("grouppage.gchange42")}` } + renderErr3Text() { return html`${translate("grouppage.gchange43")}` } + renderErr4Text() { return html`${translate("grouppage.gchange44")}` } + renderErr5Text() { return html`${translate("grouppage.gchange45")}` } + renderErr6Text() { return html`${translate("grouppage.gchange46")}` } + renderErr7Text() { return html`${translate("grouppage.gchange47")}` } + renderErr8Text() { return html`${translate("grouppage.gchange48")}` } + renderErr9Text() { return html`${translate("grouppage.gchange49")}` } + renderSuccessText() { + return html`${translate("walletpage.wchange30")}` + } + + renderClearSuccess() { + let strSuccessValue = this.successMessage + if (strSuccessValue === "") { + return html`` + } else { + return html` +
+ ${this.successMessage} + +
+
+

${translate("walletpage.wchange43")}

+
+ ` + } + } + + renderClearError() { + let strErrorValue = this.errorMessage + if (strErrorValue === "") { + return html`` + } else { + return html` +
+ ${this.errorMessage} + +
+
+

${translate("walletpage.wchange44")}

+
+ ` + } + } + + renderBanButton(groupObj) { + return html` this.openCreateBanMemberDialog(groupObj)}>create ${translate("managegroup.mg6")}` + } + + openCreateBanMemberDialog(groupObj) { + this.toBanName = '' + this.toBanAddress = '' + this.banReason = '' + this.shadowRoot.getElementById("banReason").value = '' + this.shadowRoot.getElementById("banMemberTime").value = 'reject' + this.toBanName = groupObj.name + this.toBanAddress = groupObj.owner + this.shadowRoot.querySelector('#createBanMemberDialog').show() + } + + closeCreateBanMemberDialog() { + this.shadowRoot.querySelector('#createBanMemberDialog').close() + this.shadowRoot.getElementById('toBanName').value = '' + this.shadowRoot.getElementById('toBanAddress').value = '' + this.shadowRoot.getElementById("banReason").value = '' + this.shadowRoot.getElementById("banMemberTime").value = 'reject' + this.toBanName = '' + this.toBanAddress = '' + this.banReason = '' + this.successMessage = '' + this.errorMessage = '' + } + + renderCancelBanButton(groupObj) { + return html` this.openCancelBanMemberDialog(groupObj)}>person_remove  ${translate("managegroup.mg26")}` + } + + openCancelBanMemberDialog(groupObj) { + this.toCancelBanName = '' + this.toCancelBanAddress = '' + this.toCancelBanName = groupObj.name + this.toCancelBanAddress = groupObj.owner + this.shadowRoot.querySelector('#cancelBanMemberDialog').show() + } + + closeCancelBanMemberDialog() { + this.shadowRoot.querySelector('#cancelBanMemberDialog').close() + this.shadowRoot.getElementById('toCancelBanName').value = '' + this.shadowRoot.getElementById('toCancelBanAddress').value = '' + this.toCancelBanName = '' + this.toCancelBanAddress = '' + this.successMessage = '' + this.errorMessage = '' + } + + renderKickGroupMemberButton(groupObj) { + return html` this.openKickGroupMemberDialog(groupObj)}>exit_to_app ${translate("managegroup.mg7")}` + } + + openKickGroupMemberDialog(groupObj) { + this.toKickMemberName = '' + this.toKickMemberAddresss = '' + this.kickMemberReason = '' + this.toKickMemberName = groupObj.name + this.toKickMemberAddress = groupObj.owner + this.shadowRoot.querySelector('#kickGroupMemberDialog').show() + } + + closeKickGroupMemberDialog() { + this.shadowRoot.querySelector('#kickGroupMemberDialog').close() + this.shadowRoot.getElementById('toKickMemberName').value = '' + this.shadowRoot.getElementById('toKickMemberAddress').value = '' + this.shadowRoot.getElementById('kickMemberReason').value = '' + this.toKickMemberName = '' + this.toKickMemberAddress = '' + this.kickMemberReason = '' + this.successMessage = '' + this.errorMessage = '' + } + + renderMakeAdminButton(groupObj) { + return html` this.openAddGroupAdminDialog(groupObj)}>queue ${translate("grouppage.gchange52")}` + } + + openAddGroupAdminDialog(makeAdmin) { + this.memberToAdmin = '' + this.memberToAdmin = makeAdmin + this.shadowRoot.querySelector('#addGroupAdminDialog').show() + } + + closeAddGroupAdminDialog() { + this.shadowRoot.querySelector('#addGroupAdminDialog').close() + this.shadowRoot.getElementById('memberToAdmin').value = '' + this.memberToAdmin = '' + this.successMessage = '' + this.errorMessage = '' + } + + renderKickAdminButton(groupObj) { + return html` this.openKickGroupAdminDialog(groupObj)}>exit_to_app ${translate("managegroup.mg7")}` + } + + openKickGroupAdminDialog(kickAdmin) { + this.kickGroupAdminAddress = '' + this.kickGroupAdminAddress = kickAdmin + this.shadowRoot.querySelector('#kickGroupAdminDialog').show() + } + + closeKickGroupAdminDialog() { + this.shadowRoot.querySelector('#kickGroupAdminDialog').close() + this.shadowRoot.getElementById('kickGroupAdminAddress').value = '' + this.kickGroupAdminAddress = '' + this.successMessage = '' + this.errorMessage = '' + } + + openInviteMemberToGroupDialog() { + this.shadowRoot.getElementById("toInviteMemberToGroup").value = '' + this.shadowRoot.getElementById("inviteMemberTime").value = 'reject' + this.toInviteMemberToGroup = '' + this.successMessage = '' + this.errorMessage = '' + this.shadowRoot.querySelector('#inviteMemberToGroupDialog').show() + } + + closeInviteMemberToGroupDialog() { + this.shadowRoot.querySelector('#inviteMemberToGroupDialog').close() + this.shadowRoot.getElementById('toInviteMemberToGroup').value = '' + this.shadowRoot.getElementById("inviteMemberTime").value = 'reject' + this.toInviteMemberToGroup = '' + this.inviteMemberTime = 'reject' + this.successMessage = '' + this.errorMessage = '' + } + + renderCancelInviteButton(groupObj) { + return html` this.openCancelInviteMemberToGroupDialog(groupObj)}>cancel_schedule_send ${translate("apipage.achange4")}` + } + + openCancelInviteMemberToGroupDialog(groupObj) { + this.toCancelInviteMemberName = groupObj.name + this.toCancelInviteMemberAddress = groupObj.owner + this.successMessage = '' + this.errorMessage = '' + this.shadowRoot.querySelector('#cancelInviteMemberToGroupDialog').show() + } + + closeCancelInviteMemberToGroupDialog() { + this.shadowRoot.querySelector('#cancelInviteMemberToGroupDialog').close() + this.shadowRoot.getElementById('toCancelInviteMemberName').value = '' + this.shadowRoot.getElementById("toCancelInviteMemberAddress").value = '' + this.toCancelInviteMemberName = '' + this.toCancelInviteMemberAddress = '' + this.successMessage = '' + this.errorMessage = '' + } + + openMemberInfo(inviteGroupId) { + const _inviteMemberInfo = this.shadowRoot.getElementById('toInviteMemberToGroup').value + const _nviteMemberTime = this.shadowRoot.getElementById("inviteMemberTime").value + const _inviteGroupId = inviteGroupId + + if (_inviteMemberInfo === '' || _nviteMemberTime === 'reject') { + this.shadowRoot.querySelector('#fieldErrorDialog').show() + } else { + if (_inviteMemberInfo.startsWith('Q') && _inviteMemberInfo.length == 34) { + this.getAddressUserResult(_inviteMemberInfo, _nviteMemberTime, _inviteGroupId) + } else { + this.getNameUserResult(_inviteMemberInfo, _nviteMemberTime, _inviteGroupId) + } + } + } + + async getAddressUserResult(_inviteMemberInfo, _nviteMemberTime, _inviteGroupId) { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const addressUrl = `${nodeUrl}/addresses/${_inviteMemberInfo}` + + await fetch(addressUrl).then(res => { + if (res.status === 400) { + this.shadowRoot.querySelector('#userErrorDialog').show() + } else { + this.createInviteGroupMember(_inviteMemberInfo, _nviteMemberTime, _inviteGroupId) + } + }) + } + + async getNameUserResult(_inviteMemberInfo, _nviteMemberTime, _inviteGroupId) { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const nameUrl = `${nodeUrl}/names/${_inviteMemberInfo}` + + await fetch(nameUrl).then(res => { + if (res.status === 404) { + this.shadowRoot.querySelector('#userErrorDialog').show() + } else { + this.getAddressFromName(_inviteMemberInfo, _nviteMemberTime, _inviteGroupId) + } + }) + } + + async getAddressFromName(_inviteMemberInfo, _nviteMemberTime, _inviteGroupId) { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const fromNameUrl = `${nodeUrl}/names/${_inviteMemberInfo}` + + const qortalNameInfo = await fetch(fromNameUrl).then(response => { + return response.json() + }) + + this.nameAddressResult = qortalNameInfo + const _inviteMemberNameInfo = this.nameAddressResult.owner + this.createInviteGroupMember(_inviteMemberNameInfo, _nviteMemberTime, _inviteGroupId) + } + + closeErrorDialog() { + this.shadowRoot.querySelector('#userErrorDialog').close() + } + + closeFieldErrorDialog() { + this.shadowRoot.querySelector('#fieldErrorDialog').close() + } async unitCreateFee() { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; - const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port; - const url = `${nodeUrl}/transactions/unitfee?txType=CREATE_GROUP`; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=CREATE_GROUP` await fetch(url).then((response) => { if (response.ok) { - return response.json(); + return response.json() } - return Promise.reject(response); + return Promise.reject(response) }).then((json) => { - this.createFee = (Number(json) / 1e8).toFixed(8); + this.createFee = (Number(json) / 1e8).toFixed(8) }) } async unitJoinFee() { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; - const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port; - const url = `${nodeUrl}/transactions/unitfee?txType=JOIN_GROUP`; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=JOIN_GROUP` await fetch(url).then((response) => { if (response.ok) { - return response.json(); + return response.json() } - return Promise.reject(response); + return Promise.reject(response) }).then((json) => { - this.joinFee = (Number(json) / 1e8).toFixed(8); + this.joinFee = (Number(json) / 1e8).toFixed(8) }) } async unitLeaveFee() { - const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node]; - const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port; - const url = `${nodeUrl}/transactions/unitfee?txType=LEAVE_GROUP`; + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=LEAVE_GROUP` await fetch(url).then((response) => { if (response.ok) { - return response.json(); + return response.json() } - return Promise.reject(response); + return Promise.reject(response) }).then((json) => { - this.leaveFee = (Number(json) / 1e8).toFixed(8); + this.leaveFee = (Number(json) / 1e8).toFixed(8) }) } + async unitAddGroupAdminFee() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=ADD_GROUP_ADMIN` + await fetch(url).then((response) => { + if (response.ok) { + return response.json() + } + return Promise.reject(response) + }).then((json) => { + this.addGroupAdminFee = (Number(json) / 1e8).toFixed(8) + }) + } + + async unitKickGroupAdminFee() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=REMOVE_GROUP_ADMIN` + await fetch(url).then((response) => { + if (response.ok) { + return response.json() + } + return Promise.reject(response) + }).then((json) => { + this.kickGroupAdminFee = (Number(json) / 1e8).toFixed(8) + }) + } + + async unitCreateBanFee() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=GROUP_BAN` + await fetch(url).then((response) => { + if (response.ok) { + return response.json() + } + return Promise.reject(response) + }).then((json) => { + this.createBanFee = (Number(json) / 1e8).toFixed(8) + }) + } + + async unitCancelBanFee() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port; + const url = `${nodeUrl}/transactions/unitfee?txType=CANCEL_GROUP_BAN` + await fetch(url).then((response) => { + if (response.ok) { + return response.json() + } + return Promise.reject(response) + }).then((json) => { + this.cancelBanFee = (Number(json) / 1e8).toFixed(8) + }) + } + + async unitKickGroupMemberFee() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=GROUP_KICK` + await fetch(url).then((response) => { + if (response.ok) { + return response.json() + } + return Promise.reject(response) + }).then((json) => { + this.kickGroupMemberFee = (Number(json) / 1e8).toFixed(8) + }) + } + + async unitInviteGroupMemberFee() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=GROUP_INVITE` + await fetch(url).then((response) => { + if (response.ok) { + return response.json() + } + return Promise.reject(response) + }).then((json) => { + this.inviteGroupMemberFee = (Number(json) / 1e8).toFixed(8) + }) + } + + async unitCancelInviteGroupMemberFee() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/transactions/unitfee?txType=CANCEL_GROUP_INVITE` + await fetch(url).then((response) => { + if (response.ok) { + return response.json() + } + return Promise.reject(response) + }).then((json) => { + this.cancelInviteGroupMemberFee = (Number(json) / 1e8).toFixed(8) + }) + } + + async getNewMemberList(theGroup) { + let callMembers = theGroup + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const callMembersUrl = `${nodeUrl}/groups/members/${callMembers}?limit=0&reverse=true` + + let obj = [] + let obj1 = [] + + await fetch(callMembersUrl).then(res => { + return res.json() + }).then(data => { + let groupMemberToParse = data + groupMemberToParse.members.map(a => { + if (a.isAdmin === undefined) { + let callTheNewMember = a.member + let callSingleMemberUrl = `${nodeUrl}/names/address/${callTheNewMember}` + fetch(callSingleMemberUrl).then(res => { + return res.json() + }).then(jsonRes => { + if (jsonRes.length) { + jsonRes.map(b => { + const objToAdd = { + name: b.name, + owner: b.owner, + joined: a.joined + } + obj.push(objToAdd) + }) + } else { + const noName = 'No registered name' + const noNameObj = { + name: noName, + owner: a.member, + joined: a.joined + } + obj.push(noNameObj) + } + this.newMembersList = obj + }) + } else if (a.isAdmin === true) { + let callTheNewAdmin = a.member + let callSingleAdminUrl = `${nodeUrl}/names/address/${callTheNewAdmin}` + fetch(callSingleAdminUrl).then(res => { + return res.json() + }).then(jsonRes => { + if (jsonRes.length) { + jsonRes.map(c => { + const obj1ToAdd = { + name: c.name, + owner: c.owner, + joined: a.joined + } + obj1.push(obj1ToAdd) + }) + } else { + const noName = 'No registered name' + const noNameObj1 = { + name: noName, + owner: a.member, + joined: a.joined + } + obj1.push(noNameObj1) + } + this.newAdminsList = obj1 + }) + } + }) + }) + } + + async getNewBannedList(theGroup) { + let callGroupID = theGroup + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + + let banObj = [] + this.bannedMembers = [] + + await parentEpml.request('apiCall', { + url: `/groups/bans/${callGroupID}` + }).then(res => { + this.bannedMembers = res + }) + + if (this.bannedMembers.length === 0) { + return + } else { + this.bannedMembers.map(a => { + let callTheBannedMember = a.offender + let callSingleBannedMemberUrl = `${nodeUrl}/names/address/${callTheBannedMember}` + fetch(callSingleBannedMemberUrl).then(res => { + return res.json() + }).then(jsonRes => { + if (jsonRes.length) { + jsonRes.map(b => { + const banObjToAdd = { + name: b.name, + owner: b.owner, + banned: a.banned, + reason: a.reason, + expiry: a.expiry + } + banObj.push(banObjToAdd) + }) + } else { + const noName = 'No registered name' + const noNameObj = { + name: noName, + owner: a.offender, + banned: a.banned, + reason: a.reason, + expiry: a.expiry + } + banObj.push(noNameObj) + } + this.newBannedList = banObj + }) + }) + } + } + + async getNewGroupInvitesList(theGroup) { + let callGroupID = theGroup + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + + let inviteObj = [] + this.groupInviteMembers = [] + + await parentEpml.request('apiCall', { + url: `/groups/invites/group/${callGroupID}` + }).then(res => { + this.groupInviteMembers = res + }) + + if (this.groupInviteMembers.length === 0) { + return + } else { + this.groupInviteMembers.map(a => { + let callTheInviteMember = a.invitee + let callSingleInviteMemberUrl = `${nodeUrl}/names/address/${callTheInviteMember}` + fetch(callSingleInviteMemberUrl).then(res => { + return res.json() + }).then(jsonRes => { + if (jsonRes.length) { + jsonRes.map(b => { + const inviteObjToAdd = { + name: b.name, + owner: b.owner, + expiry: a.expiry + } + inviteObj.push(inviteObjToAdd) + }) + } else { + const noName = 'No registered name' + const noNameObj = { + name: noName, + owner: a.invitee, + expiry: a.expiry + } + inviteObj.push(noNameObj) + } + this.newGroupInvitesList = inviteObj + }) + }) + } + } + + closeManageGroupOwnerDialog() { + this.resetDefaultSettings() + this.shadowRoot.getElementById('manageGroupOwnerDialog').close() + window.location.reload() + } + resetDefaultSettings() { this.error = false this.message = '' this.isLoading = false } - manageGroupOwner(groupObj) { - this.resetDefaultSettings() + async manageGroupOwner(groupObj) { + this.manageGroupId = '' + this.theGroupOwner = '' + this.manageGroupName = '' + this.manageGroupCount = '' + this.manageGroupType = '' + const manageGroupDelay = ms => new Promise(res => setTimeout(res, ms)) this.manageGroupObj = groupObj - this.shadowRoot.querySelector('#manageGroupOwnerDialog').show() + this.manageGroupId = groupObj.groupId + this.theGroupOwner = groupObj.owner + this.manageGroupName = groupObj.groupName + this.manageGroupCount = groupObj.memberCount + this.manageGroupType = groupObj.isOpen + await this.getNewMemberList(groupObj.groupId) + await this.getNewBannedList(groupObj.groupId) + await this.getNewGroupInvitesList(groupObj.groupId) + await manageGroupDelay(1000) + this.shadowRoot.getElementById('manageGroupOwnerDialog').open() } - manageGroupAdmin(groupObj) { - this.resetDefaultSettings() + async manageGroupAdmin(groupObj) { + this.manageGroupId = '' + this.theGroupOwner = '' + this.manageGroupName = '' + this.manageGroupCount = '' + this.manageGroupType = '' + const manageGroupDelay = ms => new Promise(res => setTimeout(res, ms)) this.manageGroupObj = groupObj - this.shadowRoot.querySelector('#manageGroupAdminDialog').show() + this.manageGroupId = groupObj.groupId + this.theGroupOwner = groupObj.owner + this.manageGroupName = groupObj.groupName + this.manageGroupCount = groupObj.memberCount + this.manageGroupType = groupObj.isOpen + await this.getNewMemberList(groupObj.groupId) + await this.getNewBannedList(groupObj.groupId) + await this.getNewGroupInvitesList(groupObj.groupId) + await manageGroupDelay(1000) + this.shadowRoot.getElementById('manageGroupOwnerDialog').open() } joinGroup(groupObj) { @@ -677,17 +2303,64 @@ class GroupManagement extends LitElement { renderManageButton(groupObj) { if (groupObj.owner === this.selectedAddress.address) { - // render owner actions btn to modal return html` this.manageGroupOwner(groupObj)}>create ${translate("grouppage.gchange40")}` } else if (groupObj.isAdmin === true) { - // render admin actions modal return html` this.manageGroupAdmin(groupObj)}>create ${translate("grouppage.gchange40")}` } else { - // render member leave group modal return html` this.leaveGroup(groupObj)}>exit_to_app ${translate("grouppage.gchange50")}` } } + renderManageGroupViews(selectedView) { + if (selectedView.id === 'group-members') { + return html`${this.groupMemberTemplate()}` + } else if (selectedView.id === 'group-banned') { + return html`${this.groupBannedTemplate()}` + } else if (selectedView.id === 'group-invite') { + return html`${this.groupInviteTemplate()}` + } else if (selectedView.id === 'group-admin') { + return html`${this.groupAdminTemplate()}` + } else if (selectedView.id === 'group-update') { + return html`${this.groupUpdateTemplate()}` + } + } + + renderManageGroupHeaderViews() { + if (this.selectedView.id === 'group-members') { + return html`${translate("managegroup.mg1")}` + } else if (this.selectedView.id === 'group-banned') { + return html`${translate("managegroup.mg25")}` + } else if (this.selectedView.id === 'group-invite') { + return html`${translate("managegroup.mg2")}` + } else if (this.selectedView.id === 'group-admin') { + return html`${translate("managegroup.mg3")}` + } else if (this.selectedView.id === 'group-update') { + return html`${translate("managegroup.mg4")}` + } + } + + setManageGroupView(pageId) { + if (pageId === 'group-members') { + return this.selectedView = { id: 'group-members', name: 'Group Members' } + } else if (pageId === 'group-banned') { + return this.selectedView = { id: 'group-banned', name: 'Banned Members' } + } else if (pageId === 'group-invite') { + return this.selectedView = { id: 'group-invite', name: 'Invite To Group' } + } else if (pageId === 'group-admin') { + return this.selectedView = { id: 'group-admin', name: 'Group Admins' } + } else if (pageId === 'group-update') { + return this.selectedView = { id: 'group-update', name: 'Update Group' } + } + } + + renderAvatar(groupObj) { + let name = groupObj.name + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port + const url = `${nodeUrl}/arbitrary/THUMBNAIL/${name}/qortal_avatar?async=true&apiKey=${this.getApiKey()}` + return html`` + } + _textMenu(event) { const getSelectedText = () => { var text = ""; @@ -711,7 +2384,6 @@ class GroupManagement extends LitElement { } async createGroup(e) { - // Reset Default Settings... this.resetDefaultSettings() const createFeeInput = this.createFee const groupNameInput = this.shadowRoot.getElementById("groupNameInput").value @@ -723,7 +2395,6 @@ class GroupManagement extends LitElement { this.isLoading = true - // Get Last Ref const getLastRef = async () => { let myRef = await parentEpml.request('apiCall', { type: 'api', @@ -745,7 +2416,6 @@ class GroupManagement extends LitElement { } - // Make Transaction Request const makeTransactionRequest = async (_groupTypeInput, _groupApprovalInput, _groupMinDelayInput, _groupMaxDelayInput, lastRef) => { let groupdialog5 = get("transactions.groupdialog5") let groupdialog6 = get("transactions.groupdialog6") @@ -816,19 +2486,16 @@ class GroupManagement extends LitElement { this.isLoading = false } else { this.error = false - // Call validateReceiver validateReceiver() } } async _joinGroup(groupId, groupName) { - // Reset Default Settings... this.resetDefaultSettings() const joinFeeInput = this.joinFee this.isLoading = true - // Get Last Ref const getLastRef = async () => { let myRef = await parentEpml.request('apiCall', { type: 'api', @@ -845,7 +2512,6 @@ class GroupManagement extends LitElement { } - // Make Transaction Request const makeTransactionRequest = async (lastRef) => { let groupdialog1 = get("transactions.groupdialog1") let groupdialog2 = get("transactions.groupdialog2") @@ -859,7 +2525,7 @@ class GroupManagement extends LitElement { rGroupId: groupId, lastReference: lastRef, groupdialog1: groupdialog1, - groupdialog2: groupdialog2, + groupdialog2: groupdialog2 } }) return myTxnrequest @@ -884,13 +2550,11 @@ class GroupManagement extends LitElement { } async _leaveGroup(groupId, groupName) { - // Reset Default Settings... this.resetDefaultSettings() const leaveFeeInput = this.leaveFee this.isLoading = true - // Get Last Ref const getLastRef = async () => { let myRef = await parentEpml.request('apiCall', { type: 'api', @@ -907,7 +2571,6 @@ class GroupManagement extends LitElement { } - // Make Transaction Request const makeTransactionRequest = async (lastRef) => { let groupdialog3 = get("transactions.groupdialog3") let groupdialog4 = get("transactions.groupdialog4") @@ -921,7 +2584,7 @@ class GroupManagement extends LitElement { rGroupId: groupId, lastReference: lastRef, groupdialog3: groupdialog3, - groupdialog4: groupdialog4, + groupdialog4: groupdialog4 } }) return myTxnrequest @@ -946,6 +2609,534 @@ class GroupManagement extends LitElement { this.resetDefaultSettings() } + async createBanMember(groupId) { + const member = this.shadowRoot.getElementById('toBanAddress').value + const reason = this.shadowRoot.getElementById('banReason').value + const banTime = this.shadowRoot.getElementById('banMemberTime').value + const createBanFeeInput = this.createBanFee + const theGroupId = groupId + this.isLoading = true + this.btnDisable = true + + const getLastRef = async () => { + let myRef = await parentEpml.request('apiCall', { + type: 'api', + url: `/addresses/lastreference/${this.selectedAddress.address}` + }) + return myRef + } + + const validateReceiver = async () => { + let lastRef = await getLastRef() + let _banTime = parseInt(banTime) + let myTransaction = await makeTransactionRequest(_banTime, lastRef) + getTxnRequestResponse(myTransaction) + + } + + const makeTransactionRequest = async (_banTime, lastRef) => { + const myMember = member + const myLastRef = lastRef + const myGroupId = theGroupId + const myFee = createBanFeeInput + const myBanTime = _banTime + const myReason = reason + const myBanMemberDialog1 = get("managegroup.mg22") + const myBanMemberDialog2 = get("managegroup.mg23") + + let myTxnrequest = await parentEpml.request('transaction', { + type: 26, + nonce: this.selectedAddress.nonce, + params: { + fee: myFee, + recipient: myMember, + rGroupId: myGroupId, + rBanReason: myReason, + rBanTime: myBanTime, + lastReference: myLastRef, + banMemberDialog1: myBanMemberDialog1, + banMemberDialog2: myBanMemberDialog2 + } + }) + return myTxnrequest + } + + const getTxnRequestResponse = (txnResponse) => { + if (txnResponse.success === false && txnResponse.message) { + this.errorMessage = txnResponse.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } else if (txnResponse.success === true && !txnResponse.data.error) { + this.shadowRoot.getElementById('toBanName').value = '' + this.shadowRoot.getElementById('toBanAddress').value = '' + this.shadowRoot.getElementById("banReason").value = '' + this.shadowRoot.getElementById("banMemberTime").value = 'reject' + this.toBanName = '' + this.toBanAddress = '' + this.banReason = '' + this.errorMessage = '' + this.toBanAddress = '' + this.successMessage = this.renderSuccessText() + this.isLoading = false + this.btnDisable = false + } else { + this.errorMessage = txnResponse.data.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } + } + + if (reason.length < 3) { + this.error = true + this.message = this.renderErr2Text() + this.isLoading = false + } else if (banTime === 'reject') { + this.error = true + this.message = this.renderErr4Text() + this.isLoading = false + } else { + this.error = false + validateReceiver() + } + } + + async cancelBanMember(groupId) { + const member = this.shadowRoot.getElementById('toCancelBanAddress').value + const cancelBanFeeInput = this.cancelBanFee + const theGroupId = groupId + this.isLoading = true + this.btnDisable = true + + const getLastRef = async () => { + let myRef = await parentEpml.request('apiCall', { + type: 'api', + url: `/addresses/lastreference/${this.selectedAddress.address}` + }) + return myRef + } + + const validateReceiver = async () => { + let lastRef = await getLastRef() + let myTransaction = await makeTransactionRequest(lastRef) + getTxnRequestResponse(myTransaction) + + } + + const makeTransactionRequest = async (lastRef) => { + const myMember = member + const myLastRef = lastRef + const myGroupId = theGroupId + const myFee = cancelBanFeeInput + const myCancelBanMemberDialog1 = get("managegroup.mg29") + const myCancelBanMemberDialog2 = get("managegroup.mg30") + + let myTxnrequest = await parentEpml.request('transaction', { + type: 27, + nonce: this.selectedAddress.nonce, + params: { + fee: myFee, + recipient: myMember, + rGroupId: myGroupId, + lastReference: myLastRef, + cancelBanMemberDialog1: myCancelBanMemberDialog1, + cancelBanMemberDialog2: myCancelBanMemberDialog2 + } + }) + return myTxnrequest + } + + const getTxnRequestResponse = (txnResponse) => { + if (txnResponse.success === false && txnResponse.message) { + this.errorMessage = txnResponse.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } else if (txnResponse.success === true && !txnResponse.data.error) { + this.shadowRoot.getElementById('toCancelBanAddress').value = '' + this.toCancelBanAddress = '' + this.errorMessage = '' + this.successMessage = this.renderSuccessText() + this.isLoading = false + this.btnDisable = false + } else { + this.errorMessage = txnResponse.data.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } + } + validateReceiver() + } + + async createInviteGroupMember(_inviteMemberNameInfo, _nviteMemberTime, _inviteGroupId) { + const member = _inviteMemberNameInfo + const inviteTime = _nviteMemberTime + const inviteGroupMemberFeeInput = this.inviteGroupMemberFee + const theGroupId = _inviteGroupId + this.isLoading = true + this.btnDisable = true + + const getLastRef = async () => { + let myRef = await parentEpml.request('apiCall', { + type: 'api', + url: `/addresses/lastreference/${this.selectedAddress.address}` + }) + return myRef + } + + const validateReceiver = async () => { + let lastRef = await getLastRef() + let myTransaction = await makeTransactionRequest(lastRef) + getTxnRequestResponse(myTransaction) + } + + const makeTransactionRequest = async (lastRef) => { + const myMember = member + const myLastRef = lastRef + const myGroupId = theGroupId + const myFee = inviteGroupMemberFeeInput + const myInviteTime = inviteTime + const myInviteMemberDialog1 = get("managegroup.mg40") + const myInviteMemberDialog2 = get("managegroup.mg41") + + let myTxnrequest = await parentEpml.request('transaction', { + type: 29, + nonce: this.selectedAddress.nonce, + params: { + fee: myFee, + recipient: myMember, + rGroupId: myGroupId, + rInviteTime: myInviteTime, + lastReference: myLastRef, + inviteMemberDialog1: myInviteMemberDialog1, + inviteMemberDialog2: myInviteMemberDialog2 + } + }) + return myTxnrequest + } + + const getTxnRequestResponse = (txnResponse) => { + if (txnResponse.success === false && txnResponse.message) { + this.errorMessage = txnResponse.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } else if (txnResponse.success === true && !txnResponse.data.error) { + this.shadowRoot.getElementById('toInviteMemberToGroup').value = '' + this.shadowRoot.getElementById("inviteMemberTime").value = 'reject' + this.toInviteMemberToGroup = '' + this.inviteMemberTime = 'reject' + this.errorMessage = '' + this.successMessage = this.renderSuccessText() + this.isLoading = false + this.btnDisable = false + } else { + this.errorMessage = txnResponse.data.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } + } + validateReceiver() + } + + async cancelInviteGroupMember(groupId) { + const name = this.shadowRoot.getElementById('toCancelInviteMemberName').value + const member = this.shadowRoot.getElementById('toCancelInviteMemberAddress').value + const cancelInviteGroupMemberFeeInput = this.cancelInviteGroupMemberFee + const theGroupId = groupId + this.isLoading = true + this.btnDisable = true + + const getLastRef = async () => { + let myRef = await parentEpml.request('apiCall', { + type: 'api', + url: `/addresses/lastreference/${this.selectedAddress.address}` + }) + return myRef + } + + const validateReceiver = async () => { + let lastRef = await getLastRef() + let myTransaction = await makeTransactionRequest(lastRef) + getTxnRequestResponse(myTransaction) + } + + const makeTransactionRequest = async (lastRef) => { + const myName = name + const myMember = member + const myLastRef = lastRef + const myGroupId = theGroupId + const myFee = cancelInviteGroupMemberFeeInput + const myCancelInviteDialog1 = get("managegroup.mg48") + const myCancelInviteDialog2 = get("managegroup.mg49") + + let myTxnrequest = await parentEpml.request('transaction', { + type: 30, + nonce: this.selectedAddress.nonce, + params: { + fee: myFee, + memberName: myName, + recipient: myMember, + rGroupId: myGroupId, + lastReference: myLastRef, + cancelInviteDialog1: myCancelInviteDialog1, + cancelInviteDialog2: myCancelInviteDialog2 + } + }) + return myTxnrequest + } + + const getTxnRequestResponse = (txnResponse) => { + if (txnResponse.success === false && txnResponse.message) { + this.errorMessage = txnResponse.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } else if (txnResponse.success === true && !txnResponse.data.error) { + this.shadowRoot.getElementById('toCancelInviteMemberName').value = '' + this.shadowRoot.getElementById('toCancelInviteMemberAddress').value = '' + this.toCancelInviteMemberName = '' + this.toCancelInviteMemberAddress = '' + this.errorMessage = '' + this.successMessage = this.renderSuccessText() + this.isLoading = false + this.btnDisable = false + } else { + this.errorMessage = txnResponse.data.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } + } + validateReceiver() + } + + async addGroupAdmin(groupId) { + const member = this.shadowRoot.getElementById('memberToAdmin').value + const addGroupAdminFeeInput = this.addGroupAdminFee + const theGroupId = groupId + this.isLoading = true + this.btnDisable = true + + const getLastRef = async () => { + let myRef = await parentEpml.request('apiCall', { + type: 'api', + url: `/addresses/lastreference/${this.selectedAddress.address}` + }) + return myRef + } + + const validateReceiver = async () => { + let lastRef = await getLastRef() + let myTransaction = await makeTransactionRequest(lastRef) + getTxnRequestResponse(myTransaction) + } + + const makeTransactionRequest = async (lastRef) => { + const myMember = member + const myLastRef = lastRef + const myGroupId = theGroupId + const myFee = addGroupAdminFeeInput + const myAddAdminDialog1 = get("managegroup.mg11") + const myAddAdminDialog2 = get("managegroup.mg12") + + let myTxnrequest = await parentEpml.request('transaction', { + type: 24, + nonce: this.selectedAddress.nonce, + params: { + fee: myFee, + recipient: myMember, + rGroupId: myGroupId, + lastReference: myLastRef, + addAdminDialog1: myAddAdminDialog1, + addAdminDialog2: myAddAdminDialog2 + } + }) + return myTxnrequest + } + + const getTxnRequestResponse = (txnResponse) => { + if (txnResponse.success === false && txnResponse.message) { + this.errorMessage = txnResponse.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } else if (txnResponse.success === true && !txnResponse.data.error) { + this.shadowRoot.getElementById('memberToAdmin').value = '' + this.errorMessage = '' + this.memberToAdmin = '' + this.successMessage = this.renderSuccessText() + this.isLoading = false + this.btnDisable = false + } else { + this.errorMessage = txnResponse.data.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } + } + validateReceiver() + } + + async kickGroupMember(groupId) { + const member = this.shadowRoot.getElementById('toKickMemberAddress').value + const reason = this.shadowRoot.getElementById('kickMemberReason').value + const kickGroupMemberFeeInput = this.kickGroupMemberFee + const theGroupId = groupId + this.isLoading = true + this.btnDisable = true + + const getLastRef = async () => { + let myRef = await parentEpml.request('apiCall', { + type: 'api', + url: `/addresses/lastreference/${this.selectedAddress.address}` + }) + return myRef + } + + const validateReceiver = async () => { + let lastRef = await getLastRef() + let myTransaction = await makeTransactionRequest(lastRef) + getTxnRequestResponse(myTransaction) + } + + const makeTransactionRequest = async (lastRef) => { + const myMember = member + const myLastRef = lastRef + const myGroupId = theGroupId + const myFee = kickGroupMemberFeeInput + const myReason = reason + const myKickMemberDialog1 = get("managegroup.mg33") + const myKickMemberDialog2 = get("managegroup.mg34") + + let myTxnrequest = await parentEpml.request('transaction', { + type: 28, + nonce: this.selectedAddress.nonce, + params: { + fee: myFee, + recipient: myMember, + rGroupId: myGroupId, + rBanReason: myReason, + lastReference: myLastRef, + kickMemberDialog1: myKickMemberDialog1, + kickMemberDialog2: myKickMemberDialog2 + } + }) + return myTxnrequest + } + + const getTxnRequestResponse = (txnResponse) => { + if (txnResponse.success === false && txnResponse.message) { + this.errorMessage = txnResponse.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } else if (txnResponse.success === true && !txnResponse.data.error) { + this.shadowRoot.getElementById('toKickMemberName').value = '' + this.shadowRoot.getElementById('toKickMemberAddress').value = '' + this.shadowRoot.getElementById('kickMemberReason').value = '' + this.toKickMemberName = '' + this.toKickMemberAddress = '' + this.kickMemberReason = '' + this.errorMessage = '' + this.successMessage = this.renderSuccessText() + this.isLoading = false + this.btnDisable = false + } else { + this.errorMessage = txnResponse.data.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } + } + + if (reason.length < 3) { + this.error = true + this.message = this.renderErr2Text() + this.isLoading = false + } else { + this.error = false + validateReceiver() + } + } + + async kickGroupAdmin(groupId) { + const kickAdmin = this.shadowRoot.getElementById('kickGroupAdminAddress').value + const kickGroupAdminFeeInput = this.kickGroupAdminFee + const theGroupId = groupId + this.isLoading = true + this.btnDisable = true + + const getLastRef = async () => { + let myRef = await parentEpml.request('apiCall', { + type: 'api', + url: `/addresses/lastreference/${this.selectedAddress.address}` + }) + return myRef + } + + const validateReceiver = async () => { + let lastRef = await getLastRef() + let myTransaction = await makeTransactionRequest(lastRef) + getTxnRequestResponse(myTransaction) + + } + + const makeTransactionRequest = async (lastRef) => { + const myKickAdmin = kickAdmin + const myLastRef = lastRef + const myGroupId = theGroupId + const myFee = kickGroupAdminFeeInput + const myKickAdminDialog1 = get("managegroup.mg15") + const myKickAdminDialog2 = get("managegroup.mg16") + + let myTxnrequest = await parentEpml.request('transaction', { + type: 25, + nonce: this.selectedAddress.nonce, + params: { + fee: myFee, + recipient: myKickAdmin, + rGroupId: myGroupId, + lastReference: myLastRef, + kickAdminDialog1: myKickAdminDialog1, + kickAdminDialog2: myKickAdminDialog2 + } + }) + return myTxnrequest + } + + const getTxnRequestResponse = (txnResponse) => { + if (txnResponse.success === false && txnResponse.message) { + this.errorMessage = txnResponse.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } else if (txnResponse.success === true && !txnResponse.data.error) { + this.shadowRoot.getElementById('kickGroupAdminAddress').value = '' + this.errorMessage = '' + this.kickGroupAdminAddress = '' + this.successMessage = this.renderSuccessText() + this.isLoading = false + this.btnDisable = false + } else { + this.errorMessage = txnResponse.data.message + this.isLoading = false + this.btnDisable = false + throw new Error(txnResponse) + } + } + validateReceiver() + } + + getApiKey() { + const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] + let apiKey = myNode.apiKey + return apiKey + } + clearSelection() { window.getSelection().removeAllRanges() window.parent.getSelection().removeAllRanges()