/** * Created by tlams on 10/11/16. */ $(document).ready(function() { /* MAC ADDR Tooltip */ $('[data-toggle="tooltip"]').tooltip({ 'selector': '', 'placement': 'left', 'container':'body' }); /* ARRAY CONFIGURATION */ $('#dataTables-storages').DataTable( { "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "all"]], "paging": true, "searching": true, "ordering": true, "info": true, responsive: { details: { type: 'inline', target: 'tr' } }, columnDefs: [ { className: 'control', orderable: false, targets: 0 } ], order: [ 1, 'asc' ] } ); $('#dataTables-cluster').DataTable( { "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "all"]], "paging": true, "searching": true, "ordering": true, "info": true, responsive: { details: { type: 'inline', target: 'tr' } }, columnDefs: [ { className: 'control', orderable: false, targets: 0 } ], order: [ 1, 'asc' ] } ); $('#dataTables-hypervisors').DataTable( { "lengthMenu": [[25, 50, 100, 500, -1], [25, 50, 100, 500, "all"]], "paging": true, "searching": true, "ordering": true, "info": true, responsive: { details: { type: 'inline', target: 'tr' } }, columnDefs: [ { className: 'control', orderable: false, targets: 0 } ], order: [ 1, 'asc' ] } ); $('#dataTables-hypervisor').DataTable( { "paging": false, "searching": false, "ordering": false, "info": true, responsive: { details: { type: 'inline', target: 'tr' } }, columnDefs: [ { className: 'control', orderable: false, targets: 0 } ], order: [ 2, 'asc' ] } ); $('.dataTables-vm').DataTable({ "lengthMenu": [[25, 50, 100, 500, -1], [25, 50, 100, 500, "all"]], "paging": true, "searching": true, "ordering": true, "info": true, "pagingType": "simple_numbers", responsive: { details: { type: 'column', target: 'tr' } }, columnDefs: [ { className: 'control', orderable: false, targets: 0 } ], order: [ 1, 'asc' ] } ); $( function() { /* VM GESTION */ function sendrequest() { var action = $( "#action" ); var id = $( "#bbaction" ); var box = $('.result'); var commandinfo = "The status available in the table is not dynamically update, you must wait the next cron rotate.
You can play the status command to have an updated informations"; box.html('
'); $.ajax({ url: 'requires/pveaction.php?id='+id.val()+'&action=status', type : 'GET', timeout: 32000, success: function (data) { box.html('
Command return: '+data+'
'+ commandinfo +'
'); }, error: function() { box.html('
Error: Command failed, try again or contact an true admin.
'); } }); } /* NODE NON GRATA */ function nongrataswitch(node, action) { // J'initialise le variable box var box = $('.result'); var commandinfo = "This information will be automatic applied in the next update."; box.html('
'); var divid = '#'+node; // Je définis ma requête ajax $.ajax({ // Adresse à laquelle la requête est envoyée url: 'requires/pcmaction.php', type : 'POST', data : 'node=' + node + '&action=' + action, // Le délai maximun en millisecondes de traitement de la demande timeout: 32000, // La fonction à apeller si la requête aboutie success: function (data) { // Je charge les données dans box box.html('
information: ' + commandinfo); if (data == "sw_OFF") $(divid).html(' Nongrataimg'); else if (data == "sw_ON") $(divid).html(' Nongrataimg'); else $(divid).html(':('); }, // La fonction à appeler si la requête n'a pas abouti error: function() { // J'affiche un message d'erreur box.html('
Error: Command failed, try again or contact an administrator.
'); } }); dialog.dialog( "close" ); } $('.nongratalink').click(function() { var node = $(this).attr('node'); var action = $(this).attr('action'); nongrataswitch(node, action); return false; // return false so the browser will not scroll your page }); /* NEWVM -- SEARCH NODES */ $('#bbaction').on('click', function(event) { event.preventDefault(); // To prevent following the link (optional) sendrequest(); }); function newvm() { // J'initialise le variable box var box = $('#result'); var cpu = $( "#cpu" ); var ram = $( "#ram" ); var disk = $( "#disk" ); var cluster = $( "#enableClickableOptGroups" ); box.html('

Please wait... can take more than 1 minute
'); $.ajax({ // Adresse à laquelle la requête est envoyée url: 'requires/newvm.php', type : 'POST', data : 'cpu=' + cpu.val() + '&ram=' + ram.val() + '&disk=' + disk.val() + '&cluster=' + cluster.val(), // Le délai maximun en millisecondes de traitement de la demande timeout: 500000, // La fonction à apeller si la requête aboutie success: function (data) { // Je charge les données dans box box.html(data); }, // La fonction à appeler si la requête n'a pas abouti error: function() { // J'affiche un message d'erreur box.html('
Error: Command failed, try again or contact an admin.
'); } }); } $("#buttonnewvm").click(newvm); }); } );