full working version

This commit is contained in:
rnsrk 2023-11-15 01:53:03 +01:00
parent 2178db78f5
commit 308e21941a
22 changed files with 1434 additions and 366 deletions

29
js/accountOptions.js Normal file → Executable file
View file

@ -5,30 +5,37 @@
*/
Drupal.behaviors.accountOptions = {
attach: function (context, settings) {
once('accountOptions', '#wcam--table', context).forEach(function (form) {
once('accountOptions', '#wcam--table', context).forEach(function () {
$('.wcam--select').change(function () {
console.log($(this))
let selectedOption = $(this).val();
let itemId = $(this).closest('tr').find('.wcam--row--item-id').text();
let aid = $(this).closest('tr').find('.wcam--row--account-id').text().trim();
switch (selectedOption) {
case 'delete':
// Führen Sie hier Ihren JavaScript-Code für 'delete' aus.
console.log('delete:', itemId);
// Construct the URL for the delete route.
let deleteUrl = Drupal.url('wisski-cloud-account-manager/delete/' + aid);
// Redirect to the delete route.
window.location.href = deleteUrl;
break;
case 'edit':
// Führen Sie hier Ihren JavaScript-Code für 'edit' aus.
console.log('Edit:', itemId);
console.log('Edit:', aid);
break;
case 'provise':
// Führen Sie hier Ihren JavaScript-Code für 'provise' aus.
console.log('Provise', itemId);
// Construct the URL for the provise route.
let proviseUrl = Drupal.url('wisski-cloud-account-manager/provise/' + aid);
// Redirect to the provise route.
window.location.href = proviseUrl;
break;
case 'purge':
// Construct the URL for the purge route.
let purgeUrl = Drupal.url('wisski-cloud-account-manager/purge/' + aid);
// Redirect to the purge route.
window.location.href = purgeUrl;
break;
case 'validate':
// Führen Sie hier Ihren JavaScript-Code für 'validate' aus.
console.log('Die Option "validate" wurde ausgewählt.');
break;

37
js/provisionStatus.js Normal file
View file

@ -0,0 +1,37 @@
(function ($, Drupal, once) {
Drupal.behaviors.wcamProvisionStatus = {
attach: function (context, settings) {
once('wcamProvisionStatus', 'html', context).forEach(function () {
// Get the process idle animation.
let $animation = $('#process-idle-animation');
$animation.show(); // Show the spinner.
// Get the aid and initial provision status from the HTML.
let $rows = $('.wcam--table--row');
$rows.each(function () {
let $row = $(this);
let aid = $row.find('.wcam--row--account-id').text().trim();
let initialStatus = $row.find('#provision-status--aid-' + aid).text().trim();
// If the initial provision status is 'ongoing', start checking the provision status.
if (initialStatus === 'ongoing' || initialStatus === 'unknown') {
let intervalId = setInterval(function () {
$.get('/wisski-cloud-account-manager/provision-status/' + aid, function (data) {
// Update the provision status on the page.
let $status = $('#provision-status--aid-' + aid);
$status.text(data.status);
// If the provision status is not 'ongoing', stop the process idle animation.
if (data.status !== 'ongoing') {
if (data.status !== 'unknown') {
$row.find('#provision-status--row--aid-' + aid).text(data.status);
$animation.hide(); // Hide the spinner.
clearInterval(intervalId);
location.reload();
}
}
});
}, 3000);
}
});
});
}
};
})(jQuery, Drupal, once);