Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
TokenVaultManagement
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jasonwai
TokenVaultManagement
Commits
43bf888c
Commit
43bf888c
authored
Jul 12, 2023
by
nickchen
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: 建立key後顯示KCV值
add: 刪除部門功能 add: 刪除儲存庫功能
parent
1b4f8e58
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
525 additions
and
62 deletions
+525
-62
KeyController.cs
...n Vault Management/backstage/Controllers/KeyController.cs
+18
-5
TokenVaultController .cs
...Management/backstage/Controllers/TokenVaultController .cs
+143
-10
UserController.cs
... Vault Management/backstage/Controllers/UserController.cs
+140
-17
List.zh.resx
...agement/backstage/Resources/Views/TokenVault/List.zh.resx
+15
-0
ListDepartments.zh.resx
...nt/backstage/Resources/Views/User/ListDepartments.zh.resx
+15
-0
ListKeys.cshtml
...oken Vault Management/backstage/Views/Key/ListKeys.cshtml
+37
-9
List.cshtml
...n Vault Management/backstage/Views/TokenVault/List.cshtml
+69
-2
ListDepartments.cshtml
...lt Management/backstage/Views/User/ListDepartments.cshtml
+88
-19
No files found.
Merchant Token Vault Management/backstage/Controllers/KeyController.cs
View file @
43bf888c
...
...
@@ -20,6 +20,10 @@ using Microsoft.AspNetCore.Http;
using
Microsoft.AspNetCore.Hosting
;
using
System.IO
;
using
DocumentFormat.OpenXml.Wordprocessing
;
using
System.IdentityModel.Tokens.Jwt
;
using
static
backstage
.
Models
.
Enums
;
using
Newtonsoft.Json.Linq
;
using
System.Text
;
namespace
backstage.Controllers
{
...
...
@@ -225,7 +229,6 @@ namespace backstage.Controllers
switch
(
_currentLanguage
)
{
case
"en"
:
msg
=
"Create key success."
;
break
;
...
...
@@ -235,13 +238,23 @@ namespace backstage.Controllers
default
:
msg
=
"新增鑰匙成功"
;
break
;
}
result
.
IsSuccess
=
true
;
/*var ktList = new List<KeyToken>();
var handler = new JwtSecurityTokenHandler();
foreach (var key in keys)
{
byte[] bytes = Convert.FromBase64String(key);
// 將位元組陣列轉換為原始字串
string decodedStr = Encoding.UTF8.GetString(bytes);
var kt = JsonConvert.DeserializeObject<KeyToken>(decodedStr);
kt.Key = key;
ktList.Add(kt);
}*/
result
.
IsSuccess
=
true
;
result
.
Message
=
msg
;
result
.
Data
=
keys
;
// 回傳兩把key
//result.Data = ktList
;// 回傳兩把key
result
.
Data
=
keys
;
return
result
;
}
else
...
...
Merchant Token Vault Management/backstage/Controllers/TokenVaultController .cs
View file @
43bf888c
...
...
@@ -85,7 +85,8 @@ namespace backstage.Controllers
{
ViewBag
.
DepartmentsList
=
(
from
o
in
DepartmentsResponse
.
merchants
select
new
SelectListItem
where
o
.
enabled
==
1
select
new
SelectListItem
{
Value
=
o
.
merchant_id
.
ToString
(),
Text
=
o
.
merchant_id
+
"_"
+
o
.
name
...
...
@@ -1810,7 +1811,7 @@ namespace backstage.Controllers
{
if
(
TokenVaultResponse
.
info
.
Count
>
0
)
{
var
sortedData
=
TokenVaultResponse
.
info
.
OrderBy
(
a
=>
a
.
vault_id
);
var
sortedData
=
TokenVaultResponse
.
info
.
Where
(
a
=>
a
.
enabled
==
1
).
OrderBy
(
a
=>
a
.
vault_id
);
switch
(
_currentLanguage
)
{
...
...
@@ -1890,7 +1891,11 @@ namespace backstage.Controllers
</
td
>
<
td
>{
vault
.
tokenCount
}</
td
>
<
td
>{
vault
.
userCount
}</
td
>
<
td
>
<
a
class
=""
delVaultBtn
""
data
-
merchant_id
=
""
{
merchantId
}
""
data
-
vault_id
=
""
{
vault
.
vault_id
}
""
data
-
toggle
=
""
modal
""
data
-
target
=
""
#
delModal
""
title
=
""
Delete
""
>
<
i
class
=""
fa
-
solid
fa
-
trash
-
can
""
></
i
>
</
a
>
</
td
>
</
tr
>
";
outputHtml
+=
htmlCode
;
...
...
@@ -1942,7 +1947,8 @@ namespace backstage.Controllers
{
ViewBag
.
DepartmentsList
=
(
from
o
in
DepartmentsResponse
.
merchants
select
new
SelectListItem
where
o
.
enabled
==
1
select
new
SelectListItem
{
Value
=
o
.
merchant_id
.
ToString
(),
Text
=
o
.
merchant_id
+
"_"
+
o
.
name
...
...
@@ -1979,6 +1985,7 @@ namespace backstage.Controllers
{
ViewBag
.
DepartmentsList
=
(
from
o
in
DepartmentsResponse
.
merchants
where
o
.
enabled
==
1
select
new
SelectListItem
{
Value
=
o
.
merchant_id
.
ToString
(),
...
...
@@ -2108,7 +2115,7 @@ namespace backstage.Controllers
}
//修改vault
existVault
.
name
=
tokenVault
.
name
;
existVault
.
name
=
tokenVault
.
name
.
Trim
()
;
existVault
.
desc
=
tokenVault
.
desc
;
existVault
.
merchant_id
=
tokenVault
.
merchant_id
;
...
...
@@ -2207,7 +2214,8 @@ namespace backstage.Controllers
{
ViewBag
.
DepartmentsList
=
(
from
o
in
DepartmentsResponse
.
merchants
select
new
SelectListItem
where
o
.
enabled
==
1
select
new
SelectListItem
{
Value
=
o
.
merchant_id
.
ToString
(),
Text
=
o
.
merchant_id
+
"_"
+
o
.
name
...
...
@@ -2255,11 +2263,11 @@ namespace backstage.Controllers
if
(!
ModelState
.
IsValid
)
{
return
View
(
tokenVault
);
}
}
tokenVault
.
name
=
tokenVault
.
name
.
Trim
();
url
=
_config
[
"IP"
]
+
"/tsp/merchant/vault/add"
;
url
=
_config
[
"IP"
]
+
"/tsp/merchant/vault/add"
;
parameters
=
new
Dictionary
<
string
,
string
>
{
...
...
@@ -2313,7 +2321,8 @@ namespace backstage.Controllers
{
ViewBag
.
DepartmentsList
=
(
from
o
in
DepartmentsResponse
.
merchants
select
new
SelectListItem
where
o
.
enabled
==
1
select
new
SelectListItem
{
Value
=
o
.
merchant_id
.
ToString
(),
Text
=
o
.
merchant_id
+
"_"
+
o
.
name
...
...
@@ -2593,6 +2602,130 @@ namespace backstage.Controllers
result
.
Message
=
msg
;
return
result
;
}
/// <summary>
/// 刪除儲存庫,實際隱藏 ajax
/// </summary>
/// <param name="vault_id"></param>
/// <param name="merchant_id"></param>
/// <param name="field_id"></param>
/// <returns></returns>
[
Authorize
(
Policy
=
"AdminOnly"
)]
[
HttpPost
]
public
async
Task
<
ResultModel
>
DelVault
(
int
vault_id
,
int
merchant_id
)
{
var
result
=
new
ResultModel
();
var
vault
=
new
TokenVault
();
var
msg
=
""
;
string
token
=
User
.
FindFirstValue
(
"token"
);
var
httpMethod
=
HttpMethod
.
Post
;
#
region
call
api
/
v2
/
vault
/
get
取的要刪除的
vault
var
url
=
_config
[
"IP"
]
+
"/v2/vault/get"
;
var
parameters
=
new
Dictionary
<
string
,
string
>
{
{
"Merchant_id"
,
merchant_id
.
ToString
()},
{
"id"
,
vault_id
.
ToString
()},
{
"info"
,
"INFO"
},
};
var
apiResult
=
await
_callApi
.
CallAPI
(
url
,
parameters
,
httpMethod
);
if
(
apiResult
.
IsSuccess
)
{
try
{
var
response
=
JsonConvert
.
DeserializeObject
<
Response
>(
apiResult
.
Data
.
ToString
());
if
(
response
.
r
==
0
)
{
var
vaultInfoList
=
JsonConvert
.
DeserializeObject
<
List
<
TokenVault
>>(
response
.
info
.
ToString
());
vault
=
vaultInfoList
[
0
];
}
else
{
result
.
IsSuccess
=
false
;
result
.
Message
=
response
.
m
.
ToString
();
return
result
;
}
}
catch
(
Exception
ex
)
{
result
.
IsSuccess
=
false
;
result
.
Message
=
ex
.
Message
;
return
result
;
}
}
else
{
result
.
IsSuccess
=
false
;
result
.
Message
=
apiResult
.
Message
;
return
result
;
}
#
endregion
#
region
call
api
/
v2
/
vault
編輯商家儲存庫
url
=
_config
[
"IP"
]
+
"/v2/vault"
;
var
currentUnix
=
DateTimeOffset
.
UtcNow
.
ToUnixTimeSeconds
();
var
modData
=
new
{
name
=
vault
.
name
+
"_DeleteOn"
+
currentUnix
,
desc
=
vault
.
desc
??
""
,
type
=
vault
.
type
,
enabled
=
0
};
parameters
=
new
Dictionary
<
string
,
string
>
{
{
"Merchant_id"
,
merchant_id
.
ToString
()},
{
"id"
,
vault_id
.
ToString
()},
{
"info"
,
"INFO"
},
{
"data"
,
JsonConvert
.
SerializeObject
(
modData
)},
};
apiResult
=
await
_callApi
.
CallAPI
(
url
,
parameters
,
httpMethod
);
if
(
apiResult
.
IsSuccess
)
{
try
{
var
response
=
JsonConvert
.
DeserializeObject
<
Response
>(
apiResult
.
Data
.
ToString
());
if
(
response
.
r
==
0
)
{
switch
(
_currentLanguage
)
{
case
"zh"
:
msg
=
"存儲庫刪除成功"
;
break
;
case
"en"
:
msg
=
"Delete vault success."
;
break
;
default
:
msg
=
"Delete vault success."
;
break
;
}
result
.
IsSuccess
=
true
;
result
.
Message
=
msg
;
return
result
;
}
else
{
result
.
IsSuccess
=
false
;
result
.
Message
=
response
.
m
.
ToString
();
return
result
;
}
}
catch
(
Exception
ex
)
{
result
.
IsSuccess
=
false
;
result
.
Message
=
ex
.
Message
;
return
result
;
}
}
else
{
result
.
IsSuccess
=
false
;
result
.
Message
=
apiResult
.
Message
;
return
result
;
}
#
endregion
}
}
...
...
Merchant Token Vault Management/backstage/Controllers/UserController.cs
View file @
43bf888c
...
...
@@ -20,6 +20,9 @@ using System.Linq;
using
TokenVault_management.Models
;
using
Microsoft.Extensions.Localization
;
using
Microsoft.AspNetCore.Localization
;
using
System.Text.Json
;
using
DocumentFormat.OpenXml.Office2010.Excel
;
using
DocumentFormat.OpenXml.Wordprocessing
;
namespace
backstage.Controllers
{
...
...
@@ -1104,8 +1107,9 @@ namespace backstage.Controllers
{
return View(DepartmentsResponse);
}*/
var
merchants
=
DepartmentsResponse
.
merchants
.
Where
(
x
=>
x
.
enabled
==
1
).
ToList
();
return
View
(
DepartmentsResponse
);
return
View
(
merchants
);
}
...
...
@@ -1279,12 +1283,12 @@ namespace backstage.Controllers
var
parameters
=
new
Dictionary
<
string
,
string
>
{
{
"token"
,
token
},
{
"merchant"
,
JsonConvert
.
SerializeObject
(
data
)},
{
"uid"
,
department
.
merchant_id
.
ToString
()}
{
{
"token"
,
token
},
{
"merchant"
,
JsonConvert
.
SerializeObject
(
data
)},
{
"uid"
,
department
.
merchant_id
.
ToString
()}
};
};
var
apiResult
=
await
_callApi
.
CallAPI
(
url
,
parameters
,
httpMethod
);
if
(
apiResult
.
IsSuccess
)
{
...
...
@@ -1325,17 +1329,136 @@ namespace backstage.Controllers
return
RedirectToAction
(
"ListDepartments"
);
}
/// <summary>
/// enable做兩件事情,user加入admin,並且enable=true,
/// disable做一件事情就是enable=false
/// </summary>
/// <param name="uid"></param>
/// <param name="isAdmin"></param>
/// <returns></returns>
[
Authorize
(
Policy
=
"AdminOnly"
)]
/// <summary>
/// 部門刪除,實際上是隱藏 ajax
/// </summary>
/// <param name="merchant_id"></param>
/// <returns></returns>
[
Authorize
(
Policy
=
"AdminOnly"
)]
[
HttpPost
]
public
async
Task
<
ResultModel
>
DelDepartment
(
int
merchant_id
)
{
var
result
=
new
ResultModel
();
var
merchant
=
new
Department
();
var
msg
=
""
;
string
token
=
User
.
FindFirstValue
(
"token"
);
var
httpMethod
=
HttpMethod
.
Post
;
#
region
call
api
get
merchant
var
url
=
_config
[
"IP"
]
+
"/merchant/get"
;
var
parameters
=
new
Dictionary
<
string
,
string
>
{
{
"token"
,
token
},
{
"merchant_id"
,
merchant_id
.
ToString
()}
};
var
apiResult
=
await
_callApi
.
CallAPI
(
url
,
parameters
,
httpMethod
);
if
(
apiResult
.
IsSuccess
)
{
try
{
var
departmentsResponse
=
JsonConvert
.
DeserializeObject
<
DepartmentsResponse
>(
apiResult
.
Data
.
ToString
());
if
(
departmentsResponse
.
r
==
0
)
{
merchant
=
departmentsResponse
.
merchant
;
}
else
{
result
.
IsSuccess
=
false
;
result
.
Message
=
departmentsResponse
.
m
.
ToString
();
return
result
;
}
}
catch
(
Exception
ex
)
{
result
.
IsSuccess
=
false
;
result
.
Message
=
ex
.
Message
;
return
result
;
}
}
else
{
result
.
IsSuccess
=
false
;
result
.
Message
=
apiResult
.
Message
;
return
result
;
}
#
endregion
#
region
call
api
mod
merchant
url
=
_config
[
"IP"
]
+
"/merchant/mod"
;
var
currentUnix
=
DateTimeOffset
.
UtcNow
.
ToUnixTimeSeconds
();
var
modData
=
new
{
name
=
merchant
.
name
+
"_DeleteOn"
+
currentUnix
,
name_en
=
merchant
.
name_en
,
address
=
merchant
.
address
,
countryid
=
merchant
.
country_id
,
postcode
=
merchant
.
postcode
,
phone
=
merchant
.
phone
,
enabled
=
0
};
parameters
=
new
Dictionary
<
string
,
string
>
{
{
"token"
,
token
},
{
"uid"
,
merchant_id
.
ToString
()},
{
"merchant"
,
JsonConvert
.
SerializeObject
(
modData
)}
};
apiResult
=
await
_callApi
.
CallAPI
(
url
,
parameters
,
httpMethod
);
if
(
apiResult
.
IsSuccess
)
{
try
{
var
response
=
JsonConvert
.
DeserializeObject
<
Response
>(
apiResult
.
Data
.
ToString
());
if
(
response
.
r
==
0
)
{
switch
(
_currentLanguage
)
{
case
"zh"
:
msg
=
"刪除成功"
;
break
;
case
"en"
:
msg
=
"Delete department success."
;
break
;
default
:
msg
=
"Delete department success."
;
break
;
}
result
.
IsSuccess
=
true
;
result
.
Message
=
msg
;
return
result
;
}
else
{
result
.
IsSuccess
=
false
;
result
.
Message
=
response
.
m
.
ToString
();
return
result
;
}
}
catch
(
Exception
ex
)
{
result
.
IsSuccess
=
false
;
result
.
Message
=
ex
.
Message
;
return
result
;
}
}
else
{
result
.
IsSuccess
=
false
;
result
.
Message
=
apiResult
.
Message
;
return
result
;
}
#
endregion
}
/// <summary>
/// enable做兩件事情,user加入admin,並且enable=true,
/// disable做一件事情就是enable=false
/// </summary>
/// <param name="uid"></param>
/// <param name="isAdmin"></param>
/// <returns></returns>
[
Authorize
(
Policy
=
"AdminOnly"
)]
[
HttpPost
]
public
async
Task
<
ResultModel
>
AdminAddAjax
(
int
uid
,
int
isAdmin
)
{
...
...
Merchant Token Vault Management/backstage/Resources/Views/TokenVault/List.zh.resx
View file @
43bf888c
...
...
@@ -117,6 +117,9 @@
<resheader
name=
"writer"
>
<value>
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<data
name=
"Cancel"
xml:space=
"preserve"
>
<value>
取消
</value>
</data>
<data
name=
"Choose department"
xml:space=
"preserve"
>
<value>
選擇部門
</value>
</data>
...
...
@@ -126,6 +129,9 @@
<data
name=
"Close"
xml:space=
"preserve"
>
<value>
關閉
</value>
</data>
<data
name=
"Confirm"
xml:space=
"preserve"
>
<value>
確認
</value>
</data>
<data
name=
"Create Token Vault"
xml:space=
"preserve"
>
<value>
新增代碼庫
</value>
</data>
...
...
@@ -135,6 +141,12 @@
<data
name=
"Data Token Vault"
xml:space=
"preserve"
>
<value>
資料代碼保險庫
</value>
</data>
<data
name=
"Delete"
xml:space=
"preserve"
>
<value>
刪除
</value>
</data>
<data
name=
"Delete Vault"
xml:space=
"preserve"
>
<value>
刪除儲存庫
</value>
</data>
<data
name=
"Description"
xml:space=
"preserve"
>
<value>
描述
</value>
</data>
...
...
@@ -156,6 +168,9 @@
<data
name=
"Number of users"
xml:space=
"preserve"
>
<value>
使用者數量
</value>
</data>
<data
name=
"Please confirm to delete vault."
xml:space=
"preserve"
>
<value>
儲存庫刪除確認
</value>
</data>
<data
name=
"Serial number"
xml:space=
"preserve"
>
<value>
編號
</value>
</data>
...
...
Merchant Token Vault Management/backstage/Resources/Views/User/ListDepartments.zh.resx
View file @
43bf888c
...
...
@@ -120,12 +120,24 @@
<data
name=
"Back to List"
xml:space=
"preserve"
>
<value>
返回列表
</value>
</data>
<data
name=
"Cancel"
xml:space=
"preserve"
>
<value>
取消
</value>
</data>
<data
name=
"Confirm"
xml:space=
"preserve"
>
<value>
確認
</value>
</data>
<data
name=
"Create Department"
xml:space=
"preserve"
>
<value>
新增部門
</value>
</data>
<data
name=
"Creation Date"
xml:space=
"preserve"
>
<value>
建立日期
</value>
</data>
<data
name=
"Delete"
xml:space=
"preserve"
>
<value>
刪除
</value>
</data>
<data
name=
"Delete Department"
xml:space=
"preserve"
>
<value>
刪除部門
</value>
</data>
<data
name=
"Department ID"
xml:space=
"preserve"
>
<value>
部門ID
</value>
</data>
...
...
@@ -138,6 +150,9 @@
<data
name=
"Phone"
xml:space=
"preserve"
>
<value>
電話
</value>
</data>
<data
name=
"Please confirm to delete department."
xml:space=
"preserve"
>
<value>
部門刪除確認
</value>
</data>
<data
name=
"Username"
xml:space=
"preserve"
>
<value>
使用者名稱
</value>
</data>
...
...
Merchant Token Vault Management/backstage/Views/Key/ListKeys.cshtml
View file @
43bf888c
...
...
@@ -277,7 +277,7 @@
<div class="SubmitBlock">
<button id="edit_key_submit" type="button" class="btn btn-mainblue-solid btnSubmit0">@Localizer["Submit"]</button>
<button id="edit_key_submit" type="button" class="btn btn-mainblue-solid btnSubmit0">@Localizer["Submit"]</button>
<button type="button" class="btn btn-mainblue-hollow btnReset0" data-dismiss="modal">@Localizer["Cancel"]</button>
</div>
</form>
...
...
@@ -337,20 +337,23 @@
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="row">
<div class="row
mb-3
">
<div class="col-12 text-center">
<p class="qr-code-message">@Localizer["Please keep key1 and key2 safe."]</p>
<p class="text-danger qr-code-message">※@Localizer["Avoid being unable to restore the key after deletion"]!</p>
</div>
</div>
<div class="input-group my-3">
<p class="text-monospace">Key1KCV: <span id="key1KCV"></span></p>
<div class="input-group mb-3">
<input type="text" class="form-control" id="key1Copy" readonly>
<div class="input-group-append">
<button class="btn btn-outline-secondary copy-input" type="button">@Localizer["Copy"]</button>
</div>
</div>
<div class="input-group my-3">
<p class="text-monospace">Key2KCV: <span id="key2KCV"></span></p>
<div class="input-group mb-3">
<input type="text" class="form-control" id="key2Copy" readonly>
<div class="input-group-append">
<button class="btn btn-outline-secondary copy-input" type="button">@Localizer["Copy"]</button>
...
...
@@ -468,13 +471,28 @@
showAlert(response.isSuccess, response.message)
if (response.isSuccess) {
//atob 是 base64 decode function
let key1 = response.data[0];
let data1 = JSON.parse(atob(key1));
let kcv1 = data1.KCV;
console.log(kcv1);
let key2 = response.data[1];
console.log(key1);
console.log(key2);
$('#key1Copy').val(key1)
$('#key2Copy').val(key2);
let data2 = JSON.parse(atob(key2));
let kcv2 = data2.KCV;
console.log(kcv2);
if(data1.Order == 1){
$('#key1Copy').val(key1);
$('#key1KCV').text(kcv1);
$('#key2Copy').val(key2);
$('#key2KCV').text(kcv2);
}else{
$('#key1Copy').val(key2);
$('#key1KCV').text(kcv2);
$('#key2Copy').val(key1);
$('#key2KCV').text(kcv1);
}
$('#imageModal').modal({ backdrop: 'static', keyboard: false });
/*$('#newApp').modal('hide');
...
...
@@ -502,6 +520,7 @@
});
});
//copy 按鈕
$('.copy-input').on('click', function () {
var input = $(this).parent().prev('input'); // 使用 parent() 獲取父層,prev() 獲取前一個元素
...
...
@@ -509,6 +528,15 @@
document.execCommand('copy');
});
//qrcord modal 關閉後執行
$('#imageModal').on('hidden.bs.modal', function () {
// 在這裡執行你的操作
//console.log('imageModal 已關閉');
setTimeout(function () {
location.reload();
}, 2000);
});
$('#import_key_btn').on('click', function (e) {
document.getElementById("recoverKeyForm").classList.toggle("show");
...
...
Merchant Token Vault Management/backstage/Views/TokenVault/List.cshtml
View file @
43bf888c
...
...
@@ -58,7 +58,7 @@
<table class="table table-striped ">
<thead>
<tr class="">
<th>@Localizer["ID"]</th>
<th>
@Localizer["ID"]</th>
<th> @Localizer["Name"]</th>
<th> @Localizer["Description"]</th>
<th> @Localizer["Tpye"]</th>
...
...
@@ -67,7 +67,7 @@
<th> @Localizer["Manage"]</th>
<th> @Localizer["Number of codes"]</th>
<th> @Localizer["Number of users"]</th>
<th> @Localizer["Delete"]</th>
</tr>
</thead>
<tbody id="tbody">
...
...
@@ -160,7 +160,33 @@
</div>
</div>
<!-- END Restitute Modal -->
<!-- START delete department modal -->
<div class="modal fade " id="delModal" style=" padding-right: 17px;" role="dialog" tabindex="-1" aria-modal="true">
<div class="modal-dialog modal-md modalforMemberGo">
<div class="modal-content">
<div class="modal-header">
<h4>@Localizer["Delete Vault"]</h4>
</div>
<div class="modal-body" style="padding-top:35px; padding-bottom: 35px">
<form>
<p>@Localizer["Please confirm to delete vault."]</p>
<div class="SubmitBlock SubmitBlock_sm">
<button id="delConfirmBtn" class="btn btn-mainblue-solid">@Localizer["Confirm"]</button>
<button type="button" class="btn btn-mainblue-hollow" data-dismiss="modal">@Localizer["Cancel"]</button>
</div>
</form>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<!-- END delete department modal -->
@section Scripts{
...
...
@@ -374,7 +400,48 @@
})
// 儲存庫刪除Modal被觸發時執行
$('#delModal').on('show.bs.modal', function (e) {
//show.bs.modal = BS內建,觸發時執行
let btn = $(e.relatedTarget);//抓取觸發按鈕的資料
let mId = btn.data('merchant_id');
let vId = btn.data('vault_id');
console.log(mId);
console.log(vId);
let modal = $(this);//要修改的modal就是現在開啟的這個modal
modal.find('#delConfirmBtn').data('merchant_id', mId);
modal.find('#delConfirmBtn').data('vault_id', vId);
});
//刪除儲存庫確認
$("#delConfirmBtn").on("click", function (e) {
e.preventDefault(); // 防止點擊後刷新頁面(如果該鏈接是 <a> 標籤)
let mId = $(this).data('merchant_id');
let vId = $(this).data('vault_id');
$.ajax({
url: "/TokenVault/DelVault",
type: 'POST', // 或 'GET',根據實際需求
data: {
merchant_id: mId,
vault_id: vId
},
success: function (response) {
// API 呼叫成功的處理程式碼
showAlert(response.isSuccess, response.message)
//console.log(response);
if (response.isSuccess) {
$('#delModal').modal('hide');
setTimeout(function () {
location.reload();
}, 2000);
}
},
error: function (xhr, status, error) {
// API 呼叫失敗的處理程式碼
showAlert(false, error.responseText)
}
});
});
})
...
...
Merchant Token Vault Management/backstage/Views/User/ListDepartments.cshtml
View file @
43bf888c
@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
@model
backstage.Models.Users.DepartmentsResponse
@model
List<backstage.Models.Users.Department>
@{
bool isAdmin = User.IsInRole("Admin");
string disabledClass = isAdmin ? "" : "disabled";
...
...
@@ -31,12 +31,13 @@
@*<th>address</th>
<th>country_id</th>
<th>postcode</th>*@
<th>@Localizer["Phone"]</th>
<th>@Localizer["Phone"]</th>
@*<th>fax</th>*@
@*<th>vatid</th>*@
@*<th>enabled</th>*@
<th>@Localizer["Creation Date"]</th>
<th>@Localizer["Creation Date"]</th>
<th>@Localizer["Delete"]</th>
@*<th>vatid_verify</th>
<th>deposit_book_verify</th>
<th>user_natid_verify</th>
...
...
@@ -50,14 +51,14 @@
</thead>
<tbody>
@{
if (Model.
c
ount > 0)
if (Model.
C
ount > 0)
{
@foreach (var i in Model
.merchants
)
@foreach (var i in Model)
{
<tr
class="departmentRow" data-merchantId="@i.merchant_id"
>
<tr>
<td>@i.merchant_id</td>
<td>@i.name</td>
<td
class="departmentName" data-merchantId="@i.merchant_id"
>@i.name</td>
@*<td>@i.address</td>
<td>@i.country_id</td>
<td>@i.postcode</td>*@
...
...
@@ -67,6 +68,11 @@
<td>@i.enabled</td>*@
<td>@i.creation_date</td>
<td>
<a class="delDepartmentBtn" data-merchant_id="@i.merchant_id" data-toggle="modal" data-target="#delModal" title="Delete">
<i class="fa-solid fa-trash-can"></i>
</a>
</td>
@*<td>@i.vatid_verify</td>
<td>@i.deposit_book_verify</td>
<td>@i.user_natid_verify</td>
...
...
@@ -95,24 +101,87 @@
</div>
<!-- START delete department modal -->
<div class="modal fade " id="delModal" style=" padding-right: 17px;" role="dialog" tabindex="-1" aria-modal="true">
<div class="modal-dialog modal-md modalforMemberGo">
<div class="modal-content">
@section Scripts{
<div class="modal-header">
<h4>@Localizer["Delete Department"]</h4>
</div>
<script nonce="KUY8VewuvyUYVEIvEFue4vwyiuf">
var msg = '@TempData["msg"]';
var IsSuccess = '@TempData["IsSuccess"]';
console.log(IsSuccess + msg);
if (msg != '') {
showAlert(IsSuccess, msg);
}
<div class="modal-body" style="padding-top:35px; padding-bottom: 35px">
<form>
<p>@Localizer["Please confirm to delete department."]</p>
<div class="SubmitBlock SubmitBlock_sm">
<button id="delConfirmBtn" class="btn btn-mainblue-solid">@Localizer["Confirm"]</button>
<button type="button" class="btn btn-mainblue-hollow" data-dismiss="modal">@Localizer["Cancel"]</button>
</div>
</form>
</div>
<div class="modal-footer">
</div>
$('.departmentRow').click(function () {
var merchantId = $(this).data('merchantid');
window.location.href = '/User/GetDepartment/' + merchantId; // 根據你的路由設定和控制器來導航到部門詳細資料頁面
});
</div>
</div>
</div>
<!-- END delete department modal -->
@section Scripts{
<script nonce="KUY8VewuvyUYVEIvEFue4vwyiuf">
var msg = '@TempData["msg"]';
var IsSuccess = '@TempData["IsSuccess"]';
console.log(IsSuccess + msg);
if (msg != '') {
showAlert(IsSuccess, msg);
}
// 部門刪除Modal被觸發時執行
$('#delModal').on('show.bs.modal', function (e) {
//show.bs.modal = BS內建,觸發時執行
let btn = $(e.relatedTarget);//抓取觸發按鈕的資料
let mId = btn.data('merchant_id');
let modal = $(this);//要修改的modal就是現在開啟的這個modal
modal.find('#delConfirmBtn').data('merchant_id', mId);
});
//刪除部門
$("#delConfirmBtn").on("click", function (e) {
e.preventDefault(); // 防止點擊後刷新頁面(如果該鏈接是 <a> 標籤)
let mId = $(this).data('merchant_id');
$.ajax({
url: "/User/DelDepartment",
type: 'POST', // 或 'GET',根據實際需求
data: {
merchant_id: mId
},
success: function (response) {
// API 呼叫成功的處理程式碼
showAlert(response.isSuccess, response.message)
//console.log(response);
if (response.isSuccess) {
$('#delModal').modal('hide');
setTimeout(function () {
location.reload();
}, 2000);
}
},
error: function (xhr, status, error) {
// API 呼叫失敗的處理程式碼
showAlert(false, error.responseText)
}
});
});
$('.departmentName').click(function () {
var merchantId = $(this).data('merchantid');
window.location.href = '/User/GetDepartment/' + merchantId; // 根據你的路由設定和控制器來導航到部門詳細資料頁面
});
</script>
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment