Closed paulwollner closed 11 years ago
Patch below addresses this feature
diff -Nu rack2/install.sql rack1/install.sql
--- rack2/install.sql 2013-04-16 10:14:44.205831000 +0200
+++ rack1/install.sql 2013-04-16 10:14:39.410680000 +0200
@@ -4,6 +4,7 @@
name
varchar(64) NOT NULL,
description
varchar(255) NOT NULL,
size
int(10) NOT NULL COMMENT 'How many U are in this rack',
numbering
enum('DESC','ASC') NOT NULL DEFAULT 'DESC' COMMENT 'Direction of rack numbering',
location_id
int(10) NOT NULL COMMENT 'location of rack',
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Stores info about physical racks';
diff -Nu rack2/rack_maint.inc.php rack1/rack_maint.inc.php
--- rack2/rack_maint.inc.php 2013-04-16 10:14:44.217816000 +0200
+++ rack1/rack_maint.inc.php 2013-04-16 10:14:39.428663000 +0200
@@ -293,7 +293,7 @@
global $conf, $self, $onadb;
// Version - UPDATE on every edit!
$version = '1.10';
printmsg("DEBUG => rack_add({$options}) called", 3);
@@ -317,6 +317,7 @@ size=INT Size of rack in units description=STRING Description location=STRING|id Location of rack
numbering=STRING Numbering direction of rack
EOM @@ -362,7 +363,12 @@ $options['location'] = $loc['id']; }
'numbering' => $options['numbering'],
'name' => $options['name']
)
); @@ -395,7 +402,7 @@
// Else start an output message
@@ -597,7 +604,7 @@ $options['alt_name'] = ''; }
// Add the rack record list($status, $rows) = db_insert_record( $onadb, 'rack_assignments', @@ -674,7 +681,7 @@ printmsg("DEBUG => rack_modify({$options}) called", 3);
// Version - UPDATE on every edit!
$version = '1.10';
// Parse incoming options string to an array $options = parse_options($options); @@ -686,7 +693,8 @@ ($options['set_name'] or $options['set_description'] or $options['set_location'] or
set_numbering=STRING Numbering direction of rack
EOM )); @@ -782,6 +791,12 @@ if ($loc['id'] != $orig_rack['location_id']) $SET['location_id'] = $loc['id']; }
if ($options['set_numbering'] != $orig_rack['numbering']) $SET['numbering'] = $options['set_numbering']; + // Check permissions if (!auth('advanced')) { $self['error'] = "Permission denied!"; @@ -807,6 +822,7 @@
$log_msg = "INFO => Rack UPDATED:{$new_rack['id']}: "; $more="";
$selected = '';
if ($numbering == $rack['numbering']) { $selected = 'SELECTED'; }
@@ -1356,6 +1379,19 @@
<tr>
@@ -2164,11 +2201,18 @@
}
// Get info about front/back assignments
list($status, $frows, $assignment_front) = db_get_record($onadb, 'rack_assignments', array('rack_id' => $record['id'],'position' => $i,'mounted_from' => 1));
list($status, $brows, $assignment_back) = db_get_record($onadb, 'rack_assignments', array('rack_id' => $record['id'],'position' => $i,'mounted_from' => 2));
@@ -2399,7 +2443,7 @@
$fsize_counter--;
$bsize_counter--;
diff -Nu rack2/upgrade-1.0-1.1.sql rack1/upgrade-1.0-1.1.sql
--- rack2/upgrade-1.0-1.1.sql 1970-01-01 02:00:00.000000000 +0200
+++ rack1/upgrade-1.0-1.1.sql 2013-04-16 10:14:39.415676000 +0200
@@ -0,0 +1,2 @@
+
+ALTER TABLE racks
ADD numbering
ENUM( 'DESC', 'ASC' ) NOT NULL DEFAULT 'DESC' COMMENT 'Direction of rack numbering';
Thank you for the patch! Unfortunately, GitHub parsed it for you... I was able to manually unparse most of it, but some of the embedded HTML markup got more munged than I could unmunge.. :( I think if you put 3 back quotes (```) at the top & bottom of your patch/post, GH will display it as-is. Also, do you need to update the $version in plugin_info.php as well? Brian
FYI.. The patch does seem to do the job.. I'm trying to get it rolled back into the codebase for the rack_maint plugin:
https://github.com/opennetadmin/rack_maint
Keep an eye out there. Thanks much @paulwollner for your work on this!
I'm closing this issue. Its also similar to issue opennetadmin/rack_maint#1 in the rack_maint project. I've merged these updates into that repository.
When using the rack-maint plugin, the racks are always numbered from from top to bottom.
It would be nice to have the ability to set the ordering on a per rack basis