mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-03-28 00:05:53 +00:00
Replace GET_API_KEY with ADMIN_ACTION
This commit is contained in:
parent
287f582275
commit
ae2cc2b3d1
@ -112,5 +112,5 @@ export const GET_FRIENDS_LIST = 'GET_FRIENDS_LIST'
|
|||||||
// OPEN_PROFILE
|
// OPEN_PROFILE
|
||||||
export const OPEN_PROFILE = 'OPEN_PROFILE'
|
export const OPEN_PROFILE = 'OPEN_PROFILE'
|
||||||
|
|
||||||
// GET_API_KEY
|
// ADMIN_ACTION
|
||||||
export const GET_API_KEY = 'GET_API_KEY'
|
export const ADMIN_ACTION = 'ADMIN_ACTION'
|
||||||
|
@ -286,24 +286,50 @@ class WebBrowser extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.GET_API_KEY: {
|
case actions.ADMIN_ACTION: {
|
||||||
|
let type = data.type;
|
||||||
let res1 = await showModalAndWait(
|
let res1 = await showModalAndWait(
|
||||||
actions.GET_API_KEY,
|
actions.ADMIN_ACTION,
|
||||||
{
|
{
|
||||||
service: this.service,
|
service: this.service,
|
||||||
name: this.name
|
name: this.name,
|
||||||
|
type: type
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (res1 && res1.action === 'accept') {
|
if (res1 && res1.action === 'accept') {
|
||||||
let apiKey = this.getApiKey();
|
try {
|
||||||
response = JSON.stringify({ apiKey });
|
// Determine the API endpoint based on the type
|
||||||
|
let apiEndpoint = '';
|
||||||
|
switch (type.toLowerCase()) {
|
||||||
|
case 'stop':
|
||||||
|
apiEndpoint = '/admin/stop';
|
||||||
break;
|
break;
|
||||||
|
case 'restart':
|
||||||
|
apiEndpoint = '/admin/restart';
|
||||||
|
break;
|
||||||
|
case 'bootstrap':
|
||||||
|
apiEndpoint = '/admin/bootstrap';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown admin action type: ${type}`);
|
||||||
|
}
|
||||||
|
// Send the API request
|
||||||
|
let apiResponse = await parentEpml.request('apiCall', {
|
||||||
|
type: 'api',
|
||||||
|
url: `${apiEndpoint}?apiKey=${this.getApiKey()}`
|
||||||
|
});
|
||||||
|
response = JSON.stringify(apiResponse);
|
||||||
|
} catch (error) {
|
||||||
|
const data = {};
|
||||||
|
data['error'] = `Error performing admin action: ${error.message}`;
|
||||||
|
response = JSON.stringify(data);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const data = {};
|
const data = {};
|
||||||
data['error'] = "User declined to share API key";
|
data['error'] = `User declined admin action: ${type}`;
|
||||||
response = JSON.stringify(data);
|
response = JSON.stringify(data);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case actions.ENCRYPT_DATA: {
|
case actions.ENCRYPT_DATA: {
|
||||||
@ -3821,10 +3847,10 @@ async function showModalAndWait(type, data) {
|
|||||||
</div>
|
</div>
|
||||||
` : ''}
|
` : ''}
|
||||||
|
|
||||||
${type === actions.GET_API_KEY ? `
|
${type === actions.ADMIN_ACTION ? `
|
||||||
<div class="modal-subcontainer">
|
<div class="modal-subcontainer">
|
||||||
<p class="modal-paragraph">${`<span class="capitalize-first">${data.service.toLowerCase()}</span> wants to access your API key.`}</p>
|
<p class="modal-paragraph">${`<span class="capitalize-first">${data.service.toLowerCase()}</span> wants to perform an admin action.`}</p>
|
||||||
<p class="modal-paragraph">Allow ${data.service.toLowerCase()} to access your API key?</p>
|
<p class="modal-paragraph">Allow ${data.service.toLowerCase()} to ${data.type} your node?</p>
|
||||||
<p class="modal-paragraph">Please confirm your approval.</p>
|
<p class="modal-paragraph">Please confirm your approval.</p>
|
||||||
</div>
|
</div>
|
||||||
` : ''}
|
` : ''}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user