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
03904ec9
Commit
03904ec9
authored
Aug 03, 2023
by
nickchen
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: license page
parent
bec52ba1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
148 additions
and
15 deletions
+148
-15
UserController.cs
... Vault Management/backstage/Controllers/UserController.cs
+65
-1
User.cs
...ant Token Vault Management/backstage/Models/Users/User.cs
+21
-3
ListUsers.cshtml
...en Vault Management/backstage/Views/User/ListUsers.cshtml
+3
-2
UploadLicense.cshtml
...ault Management/backstage/Views/User/UploadLicense.cshtml
+59
-9
No files found.
Merchant Token Vault Management/backstage/Controllers/UserController.cs
View file @
03904ec9
...
...
@@ -24,6 +24,8 @@ using Microsoft.AspNetCore.Localization;
using
System.Text.Json
;
using
DocumentFormat.OpenXml.Office2010.Excel
;
using
DocumentFormat.OpenXml.Wordprocessing
;
using
DocumentFormat.OpenXml.Spreadsheet
;
using
static
Microsoft
.
EntityFrameworkCore
.
DbLoggerCategory
;
namespace
backstage.Controllers
{
...
...
@@ -1870,5 +1872,67 @@ namespace backstage.Controllers
return
RedirectToAction
(
nameof
(
Login
));
}
}
[
Authorize
(
Policy
=
"AdminOnly"
)]
[
HttpGet
]
public
async
Task
<
IActionResult
>
UploadLicense
()
{
var
url
=
_config
[
"IP"
]
+
"/license/get"
;
var
httpMethod
=
HttpMethod
.
Post
;
var
parameters
=
new
Dictionary
<
string
,
string
>();
var
apiResult
=
await
_callApi
.
CallAPI
(
url
,
parameters
,
httpMethod
);
if
(
apiResult
.
IsSuccess
)
{
try
{
var
licenseResponse
=
JsonConvert
.
DeserializeObject
<
LicenseResponse
>(
apiResult
.
Data
.
ToString
());
if
(
licenseResponse
.
r
==
0
)
{
var
license
=
licenseResponse
.
License
;
return
View
(
license
);
}
}
catch
{
}
}
return
View
(
new
License
());
}
[
Authorize
(
Policy
=
"AdminOnly"
)]
[
HttpPost
]
public
async
Task
<
ResultModel
>
UploadLicenseAjax
(
string
license
)
{
var
result
=
new
ResultModel
();
var
url
=
_config
[
"IP"
]
+
"/license"
;
var
httpMethod
=
HttpMethod
.
Post
;
var
parameters
=
new
Dictionary
<
string
,
string
>
{
{
"license"
,
license
}
};
var
apiResult
=
await
_callApi
.
CallAPI
(
url
,
parameters
,
httpMethod
);
if
(
apiResult
.
IsSuccess
)
{
try
{
var
response
=
JsonConvert
.
DeserializeObject
<
Response
>(
apiResult
.
Data
.
ToString
());
if
(
response
.
r
==
0
)
{
result
.
IsSuccess
=
true
;
result
.
Message
=
"License update completed."
;
return
result
;
}
}
catch
{
}
}
result
.
IsSuccess
=
false
;
result
.
Message
=
"License update fail."
;
return
result
;
}
}
}
\ No newline at end of file
Merchant Token Vault Management/backstage/Models/Users/User.cs
View file @
03904ec9
...
...
@@ -49,7 +49,7 @@ namespace backstage.Models.Users
}
public
class
emaildata
public
class
emaildata
{
public
int
id
{
get
;
set
;
}
...
...
@@ -118,6 +118,24 @@ public class emaildata
}
public
class
LicenseResponse
{
//user/list response
public
int
r
{
get
;
set
;
}
public
Object
m
{
get
;
set
;
}
public
string
flags
{
get
;
set
;
}
public
License
License
{
get
;
set
;
}
}
public
class
License
{
public
string
Product_name
{
get
;
set
;
}
public
string
Expiration_date
{
get
;
set
;
}
public
string
Product_max_version
{
get
;
set
;
}
public
string
Department
{
get
;
set
;
}
public
string
Creation_date
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
string
Other
{
get
;
set
;
}
}
}
Merchant Token Vault Management/backstage/Views/User/ListUsers.cshtml
View file @
03904ec9
...
...
@@ -119,14 +119,15 @@
@section Scripts{
<script nonce="KUY8VewuvyUYVEIvEFue4vwyiuf">
var msg = '@TempData["msg"]';
var msg = '@TempData["msg"]';
var IsSuccess = '@TempData["IsSuccess"]';
console.log(IsSuccess + msg);
if (msg != '') {
showAlert(IsSuccess, msg);
}
$('.userRow').each(function () {
var uid = $(this).find('td:first-child').text(); // 獲取行中的 UID 值
console.log('uid=' + uid)
...
...
Merchant Token Vault Management/backstage/Views/User/UploadLicense.cshtml
View file @
03904ec9
@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
@model backstage.Models.Users.
UserRespo
nse
@model backstage.Models.Users.
Lice
nse
@{
bool isAdmin = User.IsInRole("Admin");
string disabledClass = isAdmin ? "" : "disabled";
...
...
@@ -42,7 +42,7 @@
</div>
<div class="col-md-4 col-lg-6 form-group0">
<div class="SubmitBlock0 SubmitBlock_sm0">
<button type="button" id="" class="btn btn-primary">Upload</button>
<button type="button" id="
Upload
" class="btn btn-primary">Upload</button>
</div>
</div>
</div>
...
...
@@ -54,31 +54,31 @@
<tbody>
<tr>
<th style=" border-left: solid 1px #d9d9d9;">Product Name</th>
<td>
Token Vault
</td>
<td>
@Model.Product_name
</td>
</tr>
<tr>
<th>Expireation Date</th>
<td>
2033-07-21 17:00:30
</td>
<td>
@Model.Expiration_date
</td>
</tr>
<tr>
<th>Product Max Version</th>
<td>
1.0
</td>
<td>
@Model.Product_max_version
</td>
</tr>
<tr>
<th>Department</th>
<td>
Taipay
</td>
<td>
@Model.Department
</td>
</tr>
<tr>
<th>Creation Date</th>
<td>
2023-07-17 17:49:30
</td>
<td>
@Model.Creation_date
</td>
</tr>
<tr>
<th>Name</th>
<td>
API Licens
e</td>
<td>
@Model.Nam
e</td>
</tr>
<tr>
<th style=" border-right: solid 0.1px #d9d9d9;">Other</th>
<td></td>
<td>
@Model.Other
</td>
</tr>
</tbody>
</table>
...
...
@@ -89,3 +89,53 @@
</div>
</div>
@section Scripts{
<script nonce="KUY8VewuvyUYVEIvEFue4vwyiuf">
var msg = '@TempData["msg"]';
var IsSuccess = '@TempData["IsSuccess"]';
console.log(IsSuccess + msg);
if (msg != '') {
showAlert(IsSuccess, msg);
}
//改變成上傳的檔案名
$('#uploadLicenseFile').on('change', function () {
let file = event.target.files[0];
let fileName = file.name;
$(this).siblings('label').text(fileName);
});
$('#Upload').on('click', function () {
let file = $('#uploadLicenseFile')[0].files[0];
let reader = new FileReader();
reader.onload = function (e) {
let fileContent = e.target.result;
$.ajax({
url: '/user/UploadLicenseAjax', // 替換為適當的控制器方法路徑
type: 'POST', // 或 'GET',根據實際需求
data: {
license: fileContent,
},
success: function (response) {
//console.log(response);
showAlert(response.isSuccess, response.message)
setTimeout(function () {
location.reload();
}, 2000);
},
error: function (xhr, status, error) {
// 在發生錯誤時的處理邏輯
//console.log(xhr.responseText);
showAlert(false, "發生錯誤");
}
});
};
if (file != null) {
reader.readAsText(file);
}
})
</script>
}
\ No newline at end of file
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