Merge branch 'add_enabled_to_storage'

pull/2881/head
Isaac Connor 2020-03-05 15:48:43 -05:00
commit f003daa791
8 changed files with 47 additions and 31 deletions

View File

@ -733,13 +733,14 @@ CREATE TABLE `Storage` (
`Scheme` enum('Deep','Medium','Shallow') NOT NULL default 'Medium',
`ServerId` int(10) unsigned,
`DoDelete` BOOLEAN NOT NULL DEFAULT true,
`Enabled` BOOLEAN NOT NULL DEFAULT true,
PRIMARY KEY (`Id`)
) ENGINE=@ZM_MYSQL_ENGINE@;
--
-- Create a default storage location
--
insert into Storage VALUES (NULL, '@ZM_DIR_EVENTS@', 'Default', 'local', NULL, NULL, 'Medium', 0, true );
insert into Storage VALUES (NULL, '@ZM_DIR_EVENTS@', 'Default', 'local', NULL, NULL, 'Medium', 0, true, true );
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

12
db/zm_update-1.35.1.sql Normal file
View File

@ -0,0 +1,12 @@
SET @s = (SELECT IF(
(SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE()
AND table_name = 'Storage'
AND column_name = 'Enabled'
) > 0,
"SELECT 'Column Enabled already exists in Storage'",
"ALTER TABLE `Storage` ADD `Enabled` BOOLEAN NOT NULL default true AFTER `DoDelete`"
));
PREPARE stmt FROM @s;
EXECUTE stmt;

View File

@ -16,6 +16,7 @@ class Storage extends ZM_Object {
'Scheme' => 'Medium',
'ServerId' => 0,
'DoDelete' => 1,
'Enabled' => 1,
);
public static function find($parameters = array(), $options = array()) {
return ZM_Object::_find(get_class(), $parameters, $options);

View File

@ -352,7 +352,7 @@ if ( ZM_OPT_USE_AUTH and $user ) {
?>
<p class="navbar-text">
<i class="material-icons">account_circle</i>
<?php echo makePopupLink( '?view=logout', 'zmLogout', 'logout', $user['Username'], (ZM_AUTH_TYPE == "builtin") ) ?>
<?php echo makePopupLink('?view=logout', 'zmLogout', 'logout', $user['Username'], (ZM_AUTH_TYPE == 'builtin')) ?>
</p>
<?php
}
@ -396,7 +396,7 @@ if ( (!ZM_OPT_USE_AUTH) or $user ) {
?>
<li><?php echo translate('Storage') ?>:
<?php
$storage_areas = ZM\Storage::find();
$storage_areas = ZM\Storage::find(array('Enabled'=>true));
$storage_paths = null;
$storage_areas_with_no_server_id = array();
foreach ( $storage_areas as $area ) {

View File

@ -63,7 +63,7 @@ var popupSizes = {
'shutdown': {'width': 400, 'height': 400},
'state': {'width': 400, 'height': 170},
'stats': {'width': 840, 'height': 200},
'storage': {'width': 600, 'height': 405},
'storage': {'width': 600, 'height': 425},
'timeline': {'width': 760, 'height': 540},
'user': {'width': 460, 'height': 720},
'version': {'width': 360, 'height': 210},

View File

@ -63,7 +63,7 @@ var popupSizes = {
'settings': {'width': 220, 'height': 225},
'state': {'width': 370, 'height': 134},
'stats': {'width': 840, 'height': 200},
'storage': {'width': 600, 'height': 405},
'storage': {'width': 600, 'height': 425},
'timeline': {'width': 760, 'height': 540},
'user': {'width': 360, 'height': 720},
'version': {'width': 360, 'height': 140},

View File

@ -901,9 +901,12 @@ if ( $monitor->Type() == 'Local' ) {
<?php
if ( $monitor->Type() == 'Remote' ) {
?>
<tr id="RTSPDescribe"<?php if ( $monitor->Protocol()!= 'rtsp' ) { echo ' style="display:none;"'; } ?>><td><?php echo translate('RTSPDescribe') ?>&nbsp;(<?php echo makePopupLink( '?view=optionhelp&amp;option=OPTIONS_RTSPDESCRIBE', 'zmOptionHelp', 'optionhelp', '?' ) ?>) </td><td><input type="checkbox" name="newMonitor[RTSPDescribe]" value="1"<?php if ( $monitor->RTSPDescribe() ) { ?> checked="checked"<?php } ?>/></td></tr>
<tr id="RTSPDescribe"<?php if ( $monitor->Protocol()!= 'rtsp' ) { echo ' style="display:none;"'; } ?>>
<td><?php echo translate('RTSPDescribe') ?>&nbsp;(<?php echo makePopupLink( '?view=optionhelp&amp;option=OPTIONS_RTSPDESCRIBE', 'zmOptionHelp', 'optionhelp', '?' ) ?>)</td>
<td><input type="checkbox" name="newMonitor[RTSPDescribe]" value="1"<?php if ( $monitor->RTSPDescribe() ) { ?> checked="checked"<?php } ?>/></td>
</tr>
<?php
}
} # end if monitor->Type() == 'Remote'
break;
}
case 'storage' :
@ -913,7 +916,7 @@ if ( $monitor->Type() == 'Local' ) {
<td>
<?php
$storage_areas = array(0=>'Default');
foreach ( ZM\Storage::find(NULL, array('order'=>'lower(Name)')) as $Storage ) {
foreach ( ZM\Storage::find(array('Enabled'=>true), array('order'=>'lower(Name)')) as $Storage ) {
$storage_areas[$Storage->Id()] = $Storage->Name();
}
echo htmlSelect('newMonitor[StorageId]', $storage_areas, $monitor->StorageId());

View File

@ -1,7 +1,7 @@
<?php
//
// ZoneMinder web user view file, $Date$, $Revision$
// Copyright (C) 2001-2008 Philip Coombes
// ZoneMinder web user view file
// Copyright (C) 2020 ZoneMinder LLC
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -24,21 +24,13 @@ if ( !canEdit('System') ) {
}
if ( $_REQUEST['id'] ) {
if ( !($newStorage = dbFetchOne('SELECT * FROM Storage WHERE Id=?', NULL, ARRAY($_REQUEST['id'])) ) ) {
if ( !($newStorage = ZM\Storage::find_one(array('Id'=>$_REQUEST['id'])) ) ) {
$view = 'error';
return;
$newStorage['ServerId'] = '';
}
} else {
$newStorage = array();
$newStorage['Name'] = translate('NewStorage');
$newStorage['Path'] = '';
$newStorage['Type'] = 'local';
$newStorage['Url'] = '';
$newStorage['Scheme'] = 'Medium';
$newStorage['StorageId'] = '';
$newStorage['ServerId'] = '';
$newStorage['DoDelete'] = 1;
$newStorage = new Storage();
$newStorage->Name(translate('NewStorage'));
}
$type_options = array( 'local' => translate('Local'), 's3fs' => translate('s3fs') );
@ -55,12 +47,12 @@ foreach ( $servers as $S ) {
}
$focusWindow = true;
xhtmlHeaders(__FILE__, translate('Storage').' - '.$newStorage['Name']);
xhtmlHeaders(__FILE__, translate('Storage').' - '.$newStorage->Name());
?>
<body>
<div id="page">
<div id="header">
<h2><?php echo translate('Storage').' - '.$newStorage['Name'] ?></h2>
<h2><?php echo translate('Storage').' - '.$newStorage->Name() ?></h2>
</div>
<div id="content">
<form name="contentForm" method="post" action="?" class="validateFormOnSubmit">
@ -71,33 +63,40 @@ xhtmlHeaders(__FILE__, translate('Storage').' - '.$newStorage['Name']);
<tbody>
<tr>
<th scope="row"><?php echo translate('Name') ?></th>
<td><input type="text" name="newStorage[Name]" value="<?php echo $newStorage['Name'] ?>"/></td>
<td><input type="text" name="newStorage[Name]" value="<?php echo $newStorage->Name() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Path') ?></th>
<td><input type="text" name="newStorage[Path]" value="<?php echo $newStorage['Path'] ?>"/></td>
<td><input type="text" name="newStorage[Path]" value="<?php echo $newStorage->Path() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Url') ?></th>
<td><input type="text" name="newStorage[Url]" value="<?php echo $newStorage['Url'] ?>"/></td>
<td><input type="text" name="newStorage[Url]" value="<?php echo $newStorage->Url() ?>"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Server') ?></th>
<td><?php echo htmlSelect('newStorage[ServerId]', array(''=>'Remote / No Specific Server') + $ServersById, $newStorage['ServerId']); ?></td>
<td><?php echo htmlSelect('newStorage[ServerId]', array(''=>'Remote / No Specific Server') + $ServersById, $newStorage->ServerId()); ?></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Type') ?></th>
<td><?php echo htmlSelect('newStorage[Type]', $type_options, $newStorage['Type']); ?></td>
<td><?php echo htmlSelect('newStorage[Type]', $type_options, $newStorage->Type()); ?></td>
</tr>
<tr>
<th scope="row"><?php echo translate('StorageScheme') ?></th>
<td><?php echo htmlSelect('newStorage[Scheme]', $scheme_options, $newStorage['Scheme']); ?></td>
<td><?php echo htmlSelect('newStorage[Scheme]', $scheme_options, $newStorage->Scheme()); ?></td>
</tr>
<tr>
<th scope="row"><?php echo translate('StorageDoDelete') ?></th>
<td>
<input type="radio" name="newStorage[DoDelete]" value="1"<?php echo $newStorage['DoDelete'] ? 'checked="checked"' : '' ?>/>Yes
<input type="radio" name="newStorage[DoDelete]" value="0"<?php echo $newStorage['DoDelete'] ? '' : 'checked="checked"' ?>/>No
<input type="radio" name="newStorage[DoDelete]" value="1"<?php echo $newStorage->DoDelete() ? 'checked="checked"' : '' ?>/>Yes
<input type="radio" name="newStorage[DoDelete]" value="0"<?php echo $newStorage->DoDelete() ? '' : 'checked="checked"' ?>/>No
</td>
</tr>
<tr>
<th scope="row"><?php echo translate('Enabled') ?></th>
<td>
<input type="radio" name="newStorage[Enabled]" value="1"<?php echo $newStorage->Enabled() ? 'checked="checked"' : '' ?>/>Yes
<input type="radio" name="newStorage[Enabled]" value="0"<?php echo $newStorage->Enabled() ? '' : 'checked="checked"' ?>/>No
</td>
</tr>
</tbody>