Skip to content

Commit

Permalink
Fix editing a searched client is buggy #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Alireza Ahmadi committed Feb 24, 2023
1 parent 4843c93 commit e1428ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions web/html/xui/inbound_client_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</a-tooltip>
<a-tooltip>
<template slot="title">{{ i18n "pages.client.edit" }}</template>
<a-icon style="font-size: 24px;" type="edit" @click="openEditClient(record.id,index);"></a-icon>
<a-icon style="font-size: 24px;" type="edit" @click="openEditClient(record.id,client);"></a-icon>
</a-tooltip>
<a-tooltip>
<template slot="title">{{ i18n "info" }}</template>
Expand All @@ -18,7 +18,7 @@
</a-tooltip>
<a-tooltip>
<template slot="title"><span style="color: #FF4D4F"> {{ i18n "delete"}}</span></template>
<a-icon style="font-size: 24px;" type="delete" v-if="isRemovable(record.id)" @click="delClient(record.id,index)"></a-icon>
<a-icon style="font-size: 24px;" type="delete" v-if="isRemovable(record.id)" @click="delClient(record.id,client)"></a-icon>
</a-tooltip>
</template>
<template slot="client" slot-scope="text, client">
Expand Down
15 changes: 12 additions & 3 deletions web/html/xui/inbounds.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,10 @@
isEdit: false
});
},
openEditClient(dbInbound_id, index) {
dbInbound = this.dbInbounds.find(row => row.id === dbInbound_id);
openEditClient(dbInboundId, client) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
clients = this.getInboundClients(dbInbound);
index = this.findIndexOfClient(clients, client);
clientModal.show({
title: '{{ i18n "pages.client.edit"}}',
okText: '{{ i18n "pages.client.submitEdit"}}',
Expand All @@ -378,6 +380,10 @@
isEdit: true
});
},
findIndexOfClient(clients,client) {
firstKey = Object.keys(client)[0];
return clients.findIndex(c => c[firstKey] === client[firstKey]);
},
async addClient(inbound, dbInbound) {
const data = {
id: dbInbound.id,
Expand Down Expand Up @@ -415,7 +421,10 @@
onOk: () => this.submit('/xui/inbound/del/' + dbInbound.id),
});
},
delClient(dbInboundId,index) {
delClient(dbInboundId,client) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
clients = this.getInboundClients(dbInbound);
index = this.findIndexOfClient(clients, client);
this.$confirm({
title: '{{ i18n "pages.inbounds.deleteInbound"}}',
content: '{{ i18n "pages.inbounds.deleteInboundContent"}}',
Expand Down

0 comments on commit e1428ff

Please sign in to comment.