forked from Seitanas/kvm-vdi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_hypervisors.php
116 lines (112 loc) · 4.08 KB
/
list_hypervisors.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
/*
KVM-VDI
Tadas Ustinavičius
Vilnius University.
Center of Information Technology Development.
Vilnius,Lithuania.
2016-10-28
*/
include ('functions/config.php');
require_once('functions/functions.php');
if (!check_session()){
header ("Location: $serviceurl/?error=1");
exit;
}
set_lang();
$hypervisors_reply=get_SQL_array("SELECT * FROM hypervisors ORDER BY name,ip DESC");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link href="inc/x-editable/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet">
<script src="inc/x-editable/bootstrap3-editable/js/bootstrap-editable.js"></script>
</head>
<body>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><?php echo _("Modify hypervisors");?></h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-3 hypervisor-line">
Name
</div>
<div class="col-md-3 hypervisor-line">
Address
</div>
<div class="col-md-3 hypervisor-line">
SPICE address
</div>
<div class="col-md-3 hypervisor-line">
</div>
</div>
<?php
$x=0;
while ($x<sizeof($hypervisors_reply)){
echo '<div class="row hypervisor-list" id="row-name-' . $hypervisors_reply[$x]['id'] . '">
<div class="col-md-3 hypervisor-line name-' . $hypervisors_reply[$x]['id'] . '">
<a href="#" class="hypervisor" data-type="text" data-name="update-name" data-pk="' . $hypervisors_reply[$x]['id'] . '" data-url="update_hypervisors.php">' . $hypervisors_reply[$x]['name'] . '</a>
</div>
<div class="col-md-3 hypervisor-line name-' . $hypervisors_reply[$x]['id'] . '">
<a href="#" class="hypervisor" data-type="text" data-name="update-address" data-pk="' . $hypervisors_reply[$x]['id'] . '" data-url="update_hypervisors.php">' . $hypervisors_reply[$x]['ip'] . '</a>
</div>
<div class="col-md-3 hypervisor-line name-' . $hypervisors_reply[$x]['id'] . '">
<a href="#" class="hypervisor" data-type="text" data-name="update-spice" data-pk="' . $hypervisors_reply[$x]['id'] . '" data-url="update_hypervisors.php">' . $hypervisors_reply[$x]['address2'] . '</a>
</div>
<div class="col-md-3 hypervisor-line">
<input class="hide" type="checkbox" name="hypervisor[]" value="' . $hypervisors_reply[$x]['id'] . '" id="hypervisor-' . $hypervisors_reply[$x]['id'] . '">
<button type="button" class="btn btn-warning delete" data-id="' . $hypervisors_reply[$x]['id'] . '">' . _("Delete") . '</button>
</div>
</div>';
++$x;
}
?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo _("Close");?></button>
<button type="submit" class="btn btn-primary hide" id="submit"><?php echo _("Save changes");?></button>
</div>
</div>
</body>
<script>
$(document).ready(function(){
$('.hypervisor').editable({
success: function(response, newValue) {
draw_table();
}
})
$('.delete').click(function() {
$("#submit").removeClass('hide');
var id = $(this).data('id');
$('#hypervisor-'+id).prop('checked', true);
$(".name-"+id).addClass('hypervisor-deleted');
})
$('#submit').click(function() {
var question=confirm("<?php echo _("Are you sure you wish to save changes?");?>");
var to_delete = [];
if (question){
$(":checked").each(function() {
if ($(this).val()!='on')
to_delete.push($(this).val());
$("#row-name-"+$(this).val()).remove();
});
$.ajax({
type : 'POST',
url : 'update_hypervisors.php',
data: {
type : 'delete',
hypervisor : to_delete,
},
success:function (data) {
$("#submit").addClass('hide');
draw_table();
}
})
}
})
})
</script>
</html>