Changeset 921
- Timestamp:
- Feb 25, 2022, 9:30:55 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/UpdateTrace.php
r911 r921 2175 2175 { 2176 2176 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Remote` INT NOT NULL DEFAULT "0" AFTER `Device`;'); 2177 } 2178 2179 function UpdateTo921(UpdateManager $Manager): void 2180 { 2181 $Manager->Execute('CREATE TABLE `NetworkMac` ( 2182 `Id` int(11) NOT NULL, 2183 `MAC` varchar(17) NOT NULL 2184 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); 2185 $Manager->Execute('ALTER TABLE `NetworkMac` ADD PRIMARY KEY (`Id`), ADD KEY `MAC` (`MAC`);'); 2186 $Manager->Execute('ALTER TABLE `NetworkMac` MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT;'); 2187 2188 // Convert NetworkSignal MAC from string into reference 2189 $Manager->Execute('INSERT INTO `NetworkMac` (`MAC`) SELECT DISTINCT(`MAC`) FROM `NetworkSignal`;'); 2190 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `MACTemp` INT NOT NULL AFTER `Remote`;'); 2191 $Manager->Execute('UPDATE `NetworkSignal` SET `MACTemp` = (SELECT `Id` FROM `NetworkMac` WHERE `NetworkMac`.`MAC` = `NetworkSignal`.`MAC`);'); 2192 $Manager->Execute('ALTER TABLE `NetworkSignal` DROP `MAC`;'); 2193 $Manager->Execute('ALTER TABLE `NetworkSignal` CHANGE `MACTemp` `MAC` INT(11) NOT NULL;'); 2194 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD KEY `MAC` (`MAC`);'); 2195 $Manager->Execute('ALTER TABLE `NetworkSignal` ADD FOREIGN KEY (`MAC`) REFERENCES `NetworkMac`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 2196 2197 // IS menu item 2198 $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` , 2199 `Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES ( 2200 NULL , "", "Fyzické adresy", "1", "/is/?t=NetworkMac&a=list", NULL , NULL , NULL , "1");'); 2201 $ActionId = $Manager->Database->insert_id; 2202 $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Síť"'); 2203 if ($DbResult->num_rows > 0) 2204 { 2205 $DbRow = $DbResult->fetch_assoc(); 2206 $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ". 2207 "VALUES (NULL , 'Fyzické adresy', ".$DbRow['Id'].", '".$ActionId."', '1');"); 2208 } 2177 2209 } 2178 2210 … … 2284 2316 901 => array('Revision' => 907, 'Function' => 'UpdateTo907'), 2285 2317 907 => array('Revision' => 911, 'Function' => 'UpdateTo911'), 2318 911 => array('Revision' => 921, 'Function' => 'UpdateTo921'), 2286 2319 ); 2287 2320 } -
trunk/Application/Version.php
r920 r921 1 1 <?php 2 2 3 $Revision = 92 0; // Subversion revision4 $DatabaseRevision = 9 11; // SQL structure revision5 $ReleaseTime = strtotime('2022-02-2 3');3 $Revision = 921; // Subversion revision 4 $DatabaseRevision = 921; // SQL structure revision 5 $ReleaseTime = strtotime('2022-02-24'); -
trunk/Modules/Network/Network.php
r917 r921 120 120 NetworkDomain::GetClassName(), NetworkDomainServer::GetClassName(), NetworkDomainView::GetClassName(), 121 121 NetworkDomainItemFilter::GetClassName(), DeviceAPIType::GetClassName(), NetworkInterfaceWireless::GetClassName(), 122 NetworkInterfaceUpDown::GetClassName(), NetworkPortUpDown::GetClassName() );122 NetworkInterfaceUpDown::GetClassName(), NetworkPortUpDown::GetClassName(), NetworkMac::GetClassName()); 123 123 124 124 // TODO: Make notify time configurable … … 380 380 'Items' => array( 381 381 'Time' => array('Type' => 'DateTime', 'Caption' => 'Čas', 'Default' => ''), 382 'MAC' => array('Type' => ' MacAddress', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''),382 'MAC' => array('Type' => 'TNetworkMac', 'Caption' => 'Fyzická adresa (MAC)', 'Default' => ''), 383 383 'Interface' => array('Type' => 'TNetworkInterface', 'Caption' => 'Rozhraní', 'Default' => '', 'Null' => true), 384 384 'Value' => array('Type' => 'Integer', 'Caption' => 'Signál', 'Default' => '0', 'Suffix' => 'dBm'), … … 608 608 'Duration' => array('Type' => 'TimeDiff', 'Caption' => 'Trvání', 'Default' => '', 'ReadOnly' => true), 609 609 ), 610 )); 611 $this->System->FormManager->RegisterClass('NetworkMac', array( 612 'Title' => 'Fyzická síťová adresa', 613 'Table' => 'NetworkMac', 614 'Items' => array( 615 'MAC' => array('Type' => 'String', 'Caption' => 'Fyzická adresa', 'Default' => ''), 616 'Signal' => array('Type' => 'TNetworkSignalListMac', 'Caption' => 'Signál rozhraní', 'Default' => ''), 617 ), 618 )); 619 $this->System->FormManager->RegisterFormType('TNetworkMac', array( 620 'Type' => 'Reference', 621 'Table' => 'NetworkMac', 622 'Id' => 'Id', 623 'Name' => 'MAC', 624 'Filter' => '1', 625 )); 626 $this->System->FormManager->RegisterFormType('TNetworkSignalListMac', array( 627 'Type' => 'ManyToOne', 628 'Table' => 'NetworkSignal', 629 'Id' => 'Id', 630 'Ref' => 'Mac', 631 'Filter' => '1', 610 632 )); 611 633 $this->System->FormManager->RegisterFormType('TNetworkProtocol', array( -
trunk/Modules/Network/NetworkModels.php
r911 r921 192 192 $Desc = new ModelDesc(self::GetClassName()); 193 193 $Desc->AddDateTime('Time'); 194 $Desc->Add String('MAC');194 $Desc->AddReference('MAC', NetworkMac::GetClassName()); 195 195 $Desc->AddReference('Interface', NetworkInterface::GetClassName()); 196 196 $Desc->AddInteger('Value'); … … 342 342 } 343 343 } 344 345 class NetworkMac extends Model 346 { 347 static function GetModelDesc(): ModelDesc 348 { 349 $Desc = new ModelDesc(self::GetClassName()); 350 $Desc->AddString('MAC'); // size=17 351 return $Desc; 352 } 353 354 function GetIndex(string $MAC) 355 { 356 $DbResult = $this->Database->select('NetworkMac', 'Id', 'MAC="'.$MAC.'"'); 357 if ($DbResult->num_rows > 0) 358 { 359 $DbRow = $DbResult->fetch_assoc(); 360 return $DbRow['Id']; 361 } else 362 { 363 return $this->Database->insert('NetworkMac', array('MAC' => $MAC)); 364 } 365 } 366 } -
trunk/Modules/NetworkConfigAirOS/Generators/Signal.php
r911 r921 8 8 { 9 9 $Time = time(); 10 $NetworkMac = new NetworkMac($this->System); 10 11 11 12 // Load netwatch status from all DHCP routers … … 38 39 $RateRx = $Properties['rx']; 39 40 $RateTx = $Properties['tx']; 40 $this->Database->insert('NetworkSignal', array('MAC' => $Properties['mac'], 41 $MacRef = $NetworkMac->GetIndex($Properties['mac']); 42 $this->Database->insert('NetworkSignal', array('MAC' => $MacRef, 41 43 'Value' => $Strength, 'Remote' => $RemoteSignal, 'RateRx' => $RateRx, 'RateTx' => $RateTx, 42 44 'Time' => TimeToMysqlDateTime($Time), 'Interface' => $Interface, 'Device' => $Device['Id'])); -
trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php
r917 r921 39 39 $Read = $Routerboard->Read(false); 40 40 $Array = $Routerboard->ParseResponse($Read); 41 $NetworkMac = new NetworkMac($this->System); 41 42 foreach ($Array as $Properties) 42 43 { … … 75 76 $RateRx = $this->StripUnits($Properties['rx-rate']); 76 77 $RateTx = $this->StripUnits($Properties['tx-rate']); 78 $MacRef = $NetworkMac->GetIndex($Properties['mac-address']); 77 79 $Queries[] = 'INSERT INTO `NetworkSignal` (`MAC`, `Value`, `Remote`, `RateRx`, `RateTx`, `Time`, `Interface`, `Device`) VALUES '. 78 '( "'.$Properties['mac-address'].'", '.$Strength.', '.$RemoteSignal.', '.$RateRx.', '.$RateTx.', "'.80 '('.$MacRef.', '.$Strength.', '.$RemoteSignal.', '.$RateRx.', '.$RateTx.', "'. 79 81 TimeToMysqlDateTime($this->Time).'", '.$Interface.', '.$Device['Id'].')'; 80 82 } … … 98 100 return array(); 99 101 } 102 $NetworkMac = new NetworkMac($this->System); 100 103 foreach ($Array as $Properties) 101 104 { … … 119 122 120 123 $RateTx = $this->StripUnits($Properties['tx-phy-rate']); 124 125 $MacRef = $NetworkMac->GetIndex($Properties['remote-address']); 121 126 $Queries[] = 'INSERT INTO `NetworkSignal` (`MAC`, `Value`, `Remote`, `RateRx`, `RateTx`, `Time`, `Interface`, `Device`) VALUES '. 122 '( "'.$Properties['remote-address'].'", '.$Strength.', 0, 0, '.round($RateTx / 1000000).', "'.127 '('.$MacRef.', '.$Strength.', 0, 0, '.round($RateTx / 1000000).', "'. 123 128 TimeToMysqlDateTime($this->Time).'", '.$Interface.', '.$Device['Id'].')'; 124 129 }
Note:
See TracChangeset
for help on using the changeset viewer.