Project

General

Profile

Download (15.2 KB) Statistics
| Branch: | Tag: | Revision:
1 2cd6010c Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4 757733b5 Renato Botelho
	index.php
5 5b237745 Scott Ullrich
*/
6 fd9ebcd5 Stephen Beaver
/* ====================================================================
7 40547fe4 Stephen Beaver
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
8 9da2cf1c Stephen Beaver
 *
9
 *  Some or all of this file is based on the m0nowall project which is
10
 *  Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
11 fd9ebcd5 Stephen Beaver
 *
12 40547fe4 Stephen Beaver
 *	Redistribution and use in source and binary forms, with or without modification,
13
 *	are permitted provided that the following conditions are met:
14 fd9ebcd5 Stephen Beaver
 *
15 40547fe4 Stephen Beaver
 *	1. Redistributions of source code must retain the above copyright notice,
16
 *		this list of conditions and the following disclaimer.
17 fd9ebcd5 Stephen Beaver
 *
18 40547fe4 Stephen Beaver
 *	2. Redistributions in binary form must reproduce the above copyright
19
 *		notice, this list of conditions and the following disclaimer in
20
 *		the documentation and/or other materials provided with the
21
 *		distribution.
22 fd9ebcd5 Stephen Beaver
 *
23 40547fe4 Stephen Beaver
 *	3. All advertising materials mentioning features or use of this software
24
 *		must display the following acknowledgment:
25
 *		"This product includes software developed by the pfSense Project
26
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
27 fd9ebcd5 Stephen Beaver
 *
28 40547fe4 Stephen Beaver
 *	4. The names "pfSense" and "pfSense Project" must not be used to
29
 *		 endorse or promote products derived from this software without
30
 *		 prior written permission. For written permission, please contact
31
 *		 coreteam@pfsense.org.
32 fd9ebcd5 Stephen Beaver
 *
33 40547fe4 Stephen Beaver
 *	5. Products derived from this software may not be called "pfSense"
34
 *		nor may "pfSense" appear in their names without prior written
35
 *		permission of the Electric Sheep Fencing, LLC.
36 fd9ebcd5 Stephen Beaver
 *
37 40547fe4 Stephen Beaver
 *	6. Redistributions of any form whatsoever must retain the following
38
 *		acknowledgment:
39 fd9ebcd5 Stephen Beaver
 *
40 40547fe4 Stephen Beaver
 *	"This product includes software developed by the pfSense Project
41
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
42 fd9ebcd5 Stephen Beaver
 *
43 40547fe4 Stephen Beaver
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
44
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
47
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
55 fd9ebcd5 Stephen Beaver
 *
56 40547fe4 Stephen Beaver
 *	====================================================================
57 fd9ebcd5 Stephen Beaver
 *
58
 */
59 7ac5a4cb Scott Ullrich
/*
60
	pfSense_BUILDER_BINARIES:	/sbin/ifconfig
61 40547fe4 Stephen Beaver
	pfSense_MODULE: interfaces
62 7ac5a4cb Scott Ullrich
*/
63 5b237745 Scott Ullrich
64 6b07c15a Matthew Grooms
##|+PRIV
65
##|*IDENT=page-system-login/logout
66 b7ccf315 Erik Fonnesbeck
##|*NAME=System: Login / Logout page / Dashboard
67
##|*DESCR=Allow access to the 'System: Login / Logout' page and Dashboard.
68 6b07c15a Matthew Grooms
##|*MATCH=index.php*
69
##|-PRIV
70
71 acc5dd59 jim-p
// Turn on buffering to speed up rendering
72 6c07db48 Phil Davis
ini_set('output_buffering', 'true');
73 acc5dd59 jim-p
74
// Start buffering with a cache size of 100000
75
ob_start(null, "1000");
76 880637d2 Scott Ullrich
77 acc5dd59 jim-p
## Load Essential Includes
78
require_once('guiconfig.inc');
79 32e834ff Ermal LUÇI
require_once('functions.inc');
80 acc5dd59 jim-p
require_once('notices.inc');
81 7c8f3711 jim-p
require_once("pkg-utils.inc");
82 acc5dd59 jim-p
83 888c3c1b Stephen Beaver
if (isset($_GET['closenotice'])) {
84
	close_notice($_GET['closenotice']);
85 005ac3ca Marcello Coutinho
	echo get_menu_messages();
86
	exit;
87
}
88
89 41b1ff89 Phil Davis
if ($g['disablecrashreporter'] != true) {
90 36365f49 Scott Ullrich
	// Check to see if we have a crash report
91 eac584f3 Scott Ullrich
	$x = 0;
92 41b1ff89 Phil Davis
	if (file_exists("/tmp/PHP_errors.log")) {
93 dc43ff1e jim-p
		$total = `/usr/bin/grep -vi warning /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
94 41b1ff89 Phil Davis
		if ($total > 0) {
95 a9ee006d Scott Ullrich
			$x++;
96 41b1ff89 Phil Davis
		}
97 a9ee006d Scott Ullrich
	}
98 60e27eb0 Stephen Beaver
99 a9ee006d Scott Ullrich
	$crash = glob("/var/crash/*");
100 36365f49 Scott Ullrich
	$skip_files = array(".", "..", "minfree", "");
101 60e27eb0 Stephen Beaver
102 41b1ff89 Phil Davis
	if (is_array($crash)) {
103
		foreach ($crash as $c) {
104
			if (!in_array(basename($c), $skip_files)) {
105 36365f49 Scott Ullrich
				$x++;
106 41b1ff89 Phil Davis
			}
107 36365f49 Scott Ullrich
		}
108 60e27eb0 Stephen Beaver
109 41b1ff89 Phil Davis
		if ($x > 0) {
110 a9ee006d Scott Ullrich
			$savemsg = "{$g['product_name']} has detected a crash report or programming bug.  Click <a href='crash_reporter.php'>here</a> for more information.";
111 41b1ff89 Phil Davis
		}
112 104faa07 Scott Ullrich
	}
113
}
114
115 acc5dd59 jim-p
##build list of widgets
116 1180e4f0 Sjon Hortensius
foreach (glob("/usr/local/www/widgets/widgets/*.widget.php") as $file)
117
{
118 41ea4cf3 Sjon Hortensius
	$name = basename($file, '.widget.php');
119
	$widgets[ $name ] = array('name' => ucwords(str_replace('_', ' ', $name)), 'display' => 'none');
120 acc5dd59 jim-p
}
121
122
##insert the system information widget as first, so as to be displayed first
123 1180e4f0 Sjon Hortensius
unset($widgets['system_information']);
124
$widgets = array_merge(array('system_information' => array('name' => 'System Information')), $widgets);
125 acc5dd59 jim-p
126
##if no config entry found, initialize config entry
127
if (!is_array($config['widgets'])) {
128
	$config['widgets'] = array();
129
}
130 d772ac32 Erik Kristensen
131 41ea4cf3 Sjon Hortensius
if ($_POST && $_POST['sequence']) {
132 60e27eb0 Stephen Beaver
133 69b397dd Sjon Hortensius
	$config['widgets']['sequence'] = rtrim($_POST['sequence'], ',');
134 8191b36e Scott Ullrich
135 1c428d53 Phil Davis
	foreach ($widgets as $widgetname => $widgetconfig) {
136
		if ($_POST[$widgetname . '-config']) {
137 1180e4f0 Sjon Hortensius
			$config['widgets'][$widgetname . '-config'] = $_POST[$name . '-config'];
138 8191b36e Scott Ullrich
		}
139
	}
140
141 1180e4f0 Sjon Hortensius
	write_config(gettext("Widget configuration has been changed."));
142 69b397dd Sjon Hortensius
	header("Location: /");
143 1180e4f0 Sjon Hortensius
	exit;
144
}
145 757733b5 Renato Botelho
146 1180e4f0 Sjon Hortensius
## Load Functions Files
147
require_once('includes/functions.inc.php');
148 d772ac32 Erik Kristensen
149 1180e4f0 Sjon Hortensius
## Check to see if we have a swap space,
150
## if true, display, if false, hide it ...
151 1c428d53 Phil Davis
if (file_exists("/usr/sbin/swapinfo")) {
152 1180e4f0 Sjon Hortensius
	$swapinfo = `/usr/sbin/swapinfo`;
153 1c428d53 Phil Davis
	if (stristr($swapinfo, '%') == true) $showswap=true;
154 1180e4f0 Sjon Hortensius
}
155
156
## User recently restored his config.
157
## If packages are installed lets resync
158 1c428d53 Phil Davis
if (file_exists('/conf/needs_package_sync')) {
159
	if ($config['installedpackages'] <> '' && is_array($config['installedpackages']['package'])) {
160 2344bed4 Renato Botelho
		if ($g['platform'] == $g['product_name'] || $g['platform'] == "nanobsd") {
161 1180e4f0 Sjon Hortensius
			## If the user has logged into webGUI quickly while the system is booting then do not redirect them to
162
			## the package reinstall page. That is about to be done by the boot script anyway.
163 31f03b6c Sjon Hortensius
			## The code in head.inc will put up a notice to the user.
164 1180e4f0 Sjon Hortensius
			if (!platform_booting()) {
165
				header('Location: pkg_mgr_install.php?mode=reinstallall');
166
				exit;
167 6cc843c3 Scott Ullrich
			}
168 1df0159c Erik Kristensen
		}
169 1180e4f0 Sjon Hortensius
	} else {
170
		conf_mount_rw();
171
		@unlink('/conf/needs_package_sync');
172
		conf_mount_ro();
173 1df0159c Erik Kristensen
	}
174 1180e4f0 Sjon Hortensius
}
175 8fecad11 Scott Ullrich
176 1180e4f0 Sjon Hortensius
## If it is the first time webConfigurator has been
177
## accessed since initial install show this stuff.
178 1c428d53 Phil Davis
if (file_exists('/conf/trigger_initial_wizard')) {
179 1180e4f0 Sjon Hortensius
?>
180
<!DOCTYPE html>
181
<html lang="en">
182 702b324e Scott Ullrich
<head>
183 1180e4f0 Sjon Hortensius
	<link rel="stylesheet" href="/bootstrap/css/pfSense.css" />
184 5bca8df4 Stephen Beaver
	<title><?=$g['product_name']?>.localdomain - <?=$g['product_name']?> first time setup</title>
185 1180e4f0 Sjon Hortensius
	<meta http-equiv="refresh" content="1;url=wizard.php?xml=setup_wizard.xml" />
186
</head>
187
<body id="loading-wizard" class="no-menu">
188
	<div id="jumbotron">
189
		<div class="container">
190 c7d61071 Sander van Leeuwen
			<div class="col-sm-offset-3 col-sm-6 col-xs-12">
191 40547fe4 Stephen Beaver
				<font color="white">
192
				<p><h3><?=sprintf(gettext("Welcome to %s!\n"), $g['product_name'])?></h3></p>
193 c7d61071 Sander van Leeuwen
				<p><?=gettext("One moment while we start the initial setup wizard.")?></p>
194
				<p><?=gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.")?></p>
195 1c428d53 Phil Davis
				<p><?=sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."), $g['product_name'])?></p>
196 40547fe4 Stephen Beaver
				</font>
197 c7d61071 Sander van Leeuwen
			</div>
198 1180e4f0 Sjon Hortensius
		</div>
199
	</div>
200
</body>
201
</html>
202
<?php
203
	exit;
204
}
205 bf787c0a Scott Ullrich
206 1180e4f0 Sjon Hortensius
## Find out whether there's hardware encryption or not
207
unset($hwcrypto);
208
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
209
if ($fd) {
210
	while (!feof($fd)) {
211
		$dmesgl = fgets($fd);
212
		if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
213
			or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
214
			or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
215
			or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
216
			or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
217
			or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
218
			or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
219
			$hwcrypto = $matches[1];
220
			break;
221 5b237745 Scott Ullrich
		}
222
	}
223 1180e4f0 Sjon Hortensius
	fclose($fd);
224
}
225 45ee90ed Matthew Grooms
226 7abf7db5 Scott Dale
##build widget saved list information
227 019a94df Scott Dale
if ($config['widgets'] && $config['widgets']['sequence'] != "") {
228
	$pconfig['sequence'] = $config['widgets']['sequence'];
229 1180e4f0 Sjon Hortensius
	$widgetsfromconfig = array();
230 757733b5 Renato Botelho
231 1180e4f0 Sjon Hortensius
	foreach (explode(',', $pconfig['sequence']) as $line)
232
	{
233
		list($file, $col, $display) = explode(':', $line);
234
235
		// be backwards compatible
236
		$offset = strpos($file, '-container');
237
		if (false !== $offset)
238
			$file = substr($file, 0, $offset);
239
240
		$widgetsfromconfig[ $file ] = array(
241
			'name' => ucwords(str_replace('_', ' ', $file)),
242
			'col' => $col,
243
			'display' => $display,
244
		);
245 1db766df Scott Dale
	}
246 757733b5 Renato Botelho
247 5c7657d6 Renato Botelho
	// add widgets that may not be in the saved configuration, in case they are to be displayed later
248 69b397dd Sjon Hortensius
	$widgets = $widgetsfromconfig + $widgets;
249 757733b5 Renato Botelho
250 019a94df Scott Dale
	##find custom configurations of a particular widget and load its info to $pconfig
251 1c428d53 Phil Davis
	foreach ($widgets as $widgetname => $widgetconfig) {
252
		if ($config['widgets'][$name . '-config']) {
253 1180e4f0 Sjon Hortensius
			$pconfig[$name . '-config'] = $config['widgets'][$name . '-config'];
254 757733b5 Renato Botelho
		}
255
	}
256 3e4e94ce Scott Dale
}
257
258 019a94df Scott Dale
##build list of php include files
259 8b06c9ff Scott Dale
$phpincludefiles = array();
260
$directory = "/usr/local/www/widgets/include/";
261 6c07db48 Phil Davis
$dirhandle = opendir($directory);
262 bf5ad142 Scott Dale
$filename = "";
263 60e27eb0 Stephen Beaver
264 bf5ad142 Scott Dale
while (false !== ($filename = readdir($dirhandle))) {
265
	$phpincludefiles[] = $filename;
266
}
267 60e27eb0 Stephen Beaver
268 41b1ff89 Phil Davis
foreach ($phpincludefiles as $includename) {
269
	if (!stristr($includename, ".inc")) {
270 757733b5 Renato Botelho
		continue;
271 41b1ff89 Phil Davis
	}
272 e8bd1464 Renato Botelho
	if (file_exists($directory . $includename)) {
273
		include($directory . $includename);
274
	}
275 bf5ad142 Scott Dale
}
276 81db9b7b Scott Dale
277 1db766df Scott Dale
## Set Page Title and Include Header
278 a6e0e07b Scott Ullrich
$pgtitle = array(gettext("Status: Dashboard"));
279 1db766df Scott Dale
include("head.inc");
280 f6f6947e Scott Ullrich
281 41b1ff89 Phil Davis
if ($savemsg) {
282 757733b5 Renato Botelho
	print_info_box($savemsg);
283 41b1ff89 Phil Davis
}
284 fca795f8 Scott Ullrich
285 810a11bc Scott Ullrich
pfSense_handle_custom_code("/usr/local/pkg/dashboard/pre_dashboard");
286 c69c58e2 Vinicius Coque
287 0682e26b Colin Smith
?>
288 1180e4f0 Sjon Hortensius
289 166b0099 Stephen Beaver
<div class="panel panel-default" id="widget-available">
290
	<div class="panel-heading"><?=gettext("Available Widgets"); ?>
291
		<span class="icons">
292 02597252 Stephen Beaver
			<a data-toggle="collapse" href="#widget-available .panel-body" name="widgets-available">
293 166b0099 Stephen Beaver
				<i class="icon-white icon-plus-sign"></i>
294
			</a>
295
		</span>
296
	</div>
297
	<div class="panel-body collapse out">
298 9239f765 Jared Dillard
		<div class="content">
299
			<div class="row">
300 60e27eb0 Stephen Beaver
<?php
301
foreach ($widgets as $widgetname => $widgetconfig):
302
	if ($widgetconfig['display'] == 'none'):
303
?>
304
		<div class="col-sm-3"><a href="#" name="btnadd-<?=$widgetname?>"><i class="icon icon-plus"></i> <?=$widgetconfig['name']?></a></div>
305 a2faa388 Sander van Leeuwen
	<?php endif; ?>
306
<?php endforeach; ?>
307 9239f765 Jared Dillard
			</div>
308
		</div>
309 1db766df Scott Dale
	</div>
310
</div>
311
312 7d5b007c Sjon Hortensius
<div class="modal fade">
313 a2faa388 Sander van Leeuwen
	<div class="modal-dialog">
314
		<div class="modal-content">
315
			<div class="modal-header">
316
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
317
				<h4 class="modal-title"><?=gettext("Welcome to the Dashboard page"); ?>!</h4>
318
			</div>
319
			<div class="modal-body">
320
				<p>
321
					<?=gettext("This page allows you to customize the information you want to be displayed!");?>
322 60e27eb0 Stephen Beaver
					<?=gettext("To get started click the ");?> FIXME <?=gettext(" icon to add widgets.");?><br />
323 a2faa388 Sander van Leeuwen
					<br />
324
					<?=gettext("You can move any widget around by clicking and dragging the title.");?>
325
				</p>
326
			</div>
327
			<div class="modal-footer">
328
				<button type="button" class="btn btn-default btn-primary" data-dismiss="modal">Close</button>
329
			</div>
330
		</div>
331 7d5b007c Sjon Hortensius
	</div>
332
</div>
333 d72fc17b Scott Dale
334 a2faa388 Sander van Leeuwen
<div class="hidden" id="widgetSequence">
335 60e27eb0 Stephen Beaver
	<form action="/" method="post" id="widgetSequence" name="widgetForm">
336 41ea4cf3 Sjon Hortensius
		<input type="hidden" name="sequence" value="" />
337
338 60e27eb0 Stephen Beaver
		<button type="submit" id="btnstore" class="btn btn-primary">Store widget configuration</button>
339 41ea4cf3 Sjon Hortensius
	</form>
340
</div>
341
342 1180e4f0 Sjon Hortensius
<?php
343 41ea4cf3 Sjon Hortensius
$widgetColumns = array();
344
foreach ($widgets as $widgetname => $widgetconfig)
345
{
346
	if ($widgetconfig['display'] == 'none')
347
		continue;
348
349 e8bd1464 Renato Botelho
	if (!file_exists('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php')) {
350
		continue;
351
	}
352
353 41ea4cf3 Sjon Hortensius
	if (!isset($widgetColumns[ $widgetconfig['col'] ]))
354
		$widgetColumns[ $widgetconfig['col'] ] = array();
355
356
	$widgetColumns[ $widgetconfig['col'] ][ $widgetname ] = $widgetconfig;
357
}
358 1180e4f0 Sjon Hortensius
?>
359 41ea4cf3 Sjon Hortensius
360 a2faa388 Sander van Leeuwen
<div class="row">
361 41ea4cf3 Sjon Hortensius
<?php foreach ($widgetColumns as $column => $columnWidgets):?>
362 a2faa388 Sander van Leeuwen
	<div class="col-md-6" id="widgets-<?=$column?>">
363
<?php foreach ($columnWidgets as $widgetname => $widgetconfig):?>
364 41ea4cf3 Sjon Hortensius
		<div class="panel panel-default" id="widget-<?=$widgetname?>">
365 1180e4f0 Sjon Hortensius
			<div class="panel-heading">
366
				<?=$widgetconfig['name']?>
367 80169aa8 Sjon Hortensius
				<span class="icons">
368
					<a data-toggle="collapse" href="#widget-<?=$widgetname?> .panel-footer" class="config hidden">
369 40c55526 Jared Dillard
						<i class="icon-white icon-wrench"></i>
370 80169aa8 Sjon Hortensius
					</a>
371 41ea4cf3 Sjon Hortensius
					<a data-toggle="collapse" href="#widget-<?=$widgetname?> .panel-body">
372 80169aa8 Sjon Hortensius
						<!--  actual icon is determined in css based on state of body -->
373 40c55526 Jared Dillard
						<i class="icon-white icon-plus-sign"></i>
374 80169aa8 Sjon Hortensius
					</a>
375
					<a data-toggle="close" href="#widget-<?=$widgetname?>">
376 40c55526 Jared Dillard
						<i class="icon-white icon-remove-sign"></i>
377 7d5b007c Sjon Hortensius
					</a>
378 1180e4f0 Sjon Hortensius
				</span>
379 1db766df Scott Dale
			</div>
380 41ea4cf3 Sjon Hortensius
			<div class="panel-body collapse<?=($widgetconfig['display']=='close' ? '' : ' in')?>">
381 1180e4f0 Sjon Hortensius
				<?php include('/usr/local/www/widgets/widgets/'. $widgetname.'.widget.php'); ?>
382 1db766df Scott Dale
			</div>
383 8b06c9ff Scott Dale
		</div>
384 41ea4cf3 Sjon Hortensius
<?php endforeach; ?>
385 a2faa388 Sander van Leeuwen
	</div>
386
<?php endforeach; ?>
387
</div>
388 561d55ff Erik Kristensen
389 dc58b7b3 Sjon Hortensius
<script>
390 60e27eb0 Stephen Beaver
function updateWidgets(newWidget)
391 7f8f8808 Sjon Hortensius
{
392
	var sequence = '';
393
394
	$('.container .col-md-6').each(function(idx, col){
395
		$('.panel', col).each(function(idx, widget){
396
			var isOpen = $('.panel-body', widget).hasClass('in');
397
398
			sequence += widget.id.split('-')[1] +':'+ col.id.split('-')[1] +':'+ (isOpen ? 'open' : 'close') +',';
399
		});
400
	});
401
402 60e27eb0 Stephen Beaver
	if (typeof newWidget !== 'undefined')
403
		sequence += newWidget + ':' + 'col2:close';
404
405 7f8f8808 Sjon Hortensius
	$('#widgetSequence').removeClass('hidden');
406
	$('input[name=sequence]', $('#widgetSequence')).val(sequence);
407
}
408
409 dc58b7b3 Sjon Hortensius
events.push(function() {
410
	// Hide configuration button for panels without configuration
411
	$('.container .panel-heading a.config').each(function (idx, el){
412
		var config = $(el).parents('.panel').children('.panel-footer');
413
		if (config.length == 1)
414
			$(el).removeClass('hidden');
415
	});
416
417
	// Initial state & toggle icons of collapsed panel
418 7f8f8808 Sjon Hortensius
	$('.container .panel-heading a[data-toggle="collapse"]').each(function (idx, el){
419 40c55526 Jared Dillard
		var body = $(el).parents('.panel').children('.panel-body')
420
		var isOpen = body.hasClass('in');
421
422
		$(el).children('i').toggleClass('icon-plus-sign', !isOpen);
423
		$(el).children('i').toggleClass('icon-minus-sign', isOpen);
424 dc58b7b3 Sjon Hortensius
425 7f8f8808 Sjon Hortensius
		body.on('shown.bs.collapse', function(){
426 40c55526 Jared Dillard
			$(el).children('i').toggleClass('icon-minus-sign', true);
427
			$(el).children('i').toggleClass('icon-plus-sign', false);
428 7f8f8808 Sjon Hortensius
429 02597252 Stephen Beaver
			if($(el).closest('a').attr('name') != 'widgets-available') {
430
				updateWidgets();
431
			}
432 7f8f8808 Sjon Hortensius
		});
433
434
		body.on('hidden.bs.collapse', function(){
435 40c55526 Jared Dillard
			$(el).children('i').toggleClass('icon-minus-sign', false);
436
			$(el).children('i').toggleClass('icon-plus-sign', true);
437 7f8f8808 Sjon Hortensius
438 02597252 Stephen Beaver
			if($(el).closest('a').attr('name') != 'widgets-available') {
439
				updateWidgets();
440
			}
441 7f8f8808 Sjon Hortensius
		});
442 dc58b7b3 Sjon Hortensius
	});
443
444
	// Make panels destroyable
445 7f8f8808 Sjon Hortensius
	$('.container .panel-heading a[data-toggle="close"]').each(function (idx, el){
446 dc58b7b3 Sjon Hortensius
		$(el).on('click', function(e){
447 7f8f8808 Sjon Hortensius
			$(el).parents('.panel').remove();
448
			updateWidgets();
449 dc58b7b3 Sjon Hortensius
		})
450
	});
451
452
	// Make panels sortable
453
	$('.container .col-md-6').sortable({
454
		handle: '.panel-heading',
455
		cursor: 'grabbing',
456
		connectWith: '.container .col-md-6',
457 7f8f8808 Sjon Hortensius
		update: updateWidgets
458 dc58b7b3 Sjon Hortensius
	});
459 60e27eb0 Stephen Beaver
460
	// On clicking a widget to install . .
461
	$('[name^=btnadd-]').click(function(event) {
462 19076df1 Stephen Beaver
		// Extract the widget name from the button name that got us here
463 60e27eb0 Stephen Beaver
		var widgetToAdd = this.name.replace('btnadd-', '');
464
465
		// Set its display type to 'close'
466
		<?php $widgets[widgetToAdd]['display'] = 'close'; ?>
467
468
		// Add it to the list of displayed widgets
469
		updateWidgets(widgetToAdd);
470
471 19076df1 Stephen Beaver
		// We don't want to see the "Store" button because we are doing that automatically
472 60e27eb0 Stephen Beaver
		$('#btnstore').hide();
473
474
		// Submit the form save/display all selected widgets
475
		$('[name=widgetForm]').submit();
476
	});
477
478 dc58b7b3 Sjon Hortensius
});
479
</script>
480 41ea4cf3 Sjon Hortensius
<?php
481 1180e4f0 Sjon Hortensius
//build list of javascript include files
482
foreach (glob('widgets/javascript/*.js') as $file)
483
	echo '<script src="'.$file.'"></script>';
484 927ea6e1 jim-p
485 1c428d53 Phil Davis
include("foot.inc");