-
Notifications
You must be signed in to change notification settings - Fork 205
/
build_image_cache.php
111 lines (99 loc) · 2.99 KB
/
build_image_cache.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
<?php
require_once( 'db.inc.php' );
$devMode=true;
require_once( 'facilities.inc.php' );
# $sql="Select DeviceID from fac_Device WHERE DeviceID>=5000;";
# foreach($dbh->query($sql) as $dcvrow){
# $dev=new Device($dcvrow['DeviceID']);
# $dev->DeleteDevice();
# }
global $sessID;
// everyone hates error_log spam
if(session_id()==""){
session_start();
}
$sessID = session_id();
session_write_close();
if (php_sapi_name()!="cli" && !isset($_GET["stage"]) && !isset($_GET["gauge"])) {
JobQueue::startJob( $sessID );
?>
<center>
<iframe src="?gauge" height="250" width="220" scrolling="no" style="border: 0px;"></iframe>
<?php
}elseif (php_sapi_name()!="cli" && isset($_GET["gauge"]) && !isset($_GET["stage"])){
?>
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/inventory.php" type="text/css">
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css">
<style type="text/css"></style>
<!--[if lt IE 9]>
<link rel="stylesheet" href="css/ie.css" type="text/css" />
<![endif]-->
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery-ui.min.js"></script>
<script type="text/javascript" src="scripts/gauge.min.js"></script>
<SCRIPT type="text/javascript" >
var timer;
var gauge;
$(document).ready( function() {
gauge=new Gauge({
renderTo: 'power-gauge',
type: 'canv-gauge',
title: '% Complete',
minValue: '0',
maxValue: '100',
majorTicks: [ 0,10,20,30,40,50,60,70,80,90,100 ],
minorTicks: '2',
strokeTicks: false,
units: '%',
valueFormat: { int : 3, dec : 0 },
glow: false,
animation: {
delay: 10,
duration: 200,
fn: 'bounce'
},
colors: {
needle: {start: '#000', end: '#000' },
title: '#00f',
},
highlights: [ {from: 0, to: 50, color: '#eaa'}, {from: 50, to: 80, color: '#fffacd'}, {from: 80, to: 100, color: '#0a0'} ],
});
gauge.draw().setValue(0);
timer = setInterval( function() {
$.ajax({
type: 'GET',
url: 'scripts/ajax_progress.php',
dataType: 'json',
success: function(data) {
$("#status").text(data.Status);
gauge.draw().setValue(data.Percentage);
if ( data.Percentage >= 100 ) {
clearInterval(timer);
// Reload with Stage 3 to send the file to the user
}
}
})
}, 1500 );
init=$('<iframe/>', {'src':location.href+'&stage=2', height:'100px',width:'100px'}).appendTo('body');
});
</script>
</head>
<body>
<div><canvas id="power-gauge" width="200" height="200"></canvas><h3><?php echo __("Building device image cache");?></h3</div>
</body>
</html>
<?php
}else{
$dev=new Device();
$dev->ParentDevice=0;
$payload=$dev->Search();
foreach($payload as $i => $device){
$device->UpdateDeviceCache();
JobQueue::updatePercentage( $sessID, ceil(($i/count($payload)*100)) );
}
}