Skip to content

Commit

Permalink
support multi friendly name on device general config (fw >= v5.12.0h) a…
Browse files Browse the repository at this point in the history
  • Loading branch information
reloxx13 committed Jul 8, 2018
1 parent 45c6bbb commit 5e4ab22
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@
- **NEW**: Disable update check option [#156](https://github.com/reloxx13/TasmoAdmin/issues/156)
- **NEW**: Add top scrollbar on device list [#170](https://github.com/reloxx13/TasmoAdmin/issues/170)
- MINOR: Rename "Show More" => "Detail View" in i18n.EN [#168](https://github.com/reloxx13/TasmoAdmin/issues/168)
- **NEW**: Support Multi Friendlyname on Device General Config Page (fw >= 5.12.0h) [Sonoff-Tasmota#3161](https://github.com/arendst/Sonoff-Tasmota/issues/3161)

## v1.3.3
- MINOR: fix for travis building
Expand Down
69 changes: 49 additions & 20 deletions tasmoadmin/pages/device_config_tabs/config_general_tab.php
@@ -1,25 +1,54 @@
<form class='center config-form' name='device_config_general' method='post'>
<input type='hidden' name='tab-index' value='0'>
<?php //@TODO: add multi firendlyname as 5.12.0h its an array! ?>
<div class="form-group">
<?php
$friendlyName = is_array( $status->Status->FriendlyName ) //array since 5.12.0h
? $status->Status->FriendlyName[ 0 ] : $status->Status->FriendlyName;
?>
<label for="FriendlyName">
<?php echo __( "CONFIG_FRIENDLYNAME", "DEVICE_CONFIG" ); ?>
</label>
<input type="text"
class="form-control"
id="FriendlyName"
name='FriendlyName'
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo $friendlyName; ?>'
>
<small id="FriendlyNameHelp" class="form-text text-muted">
<?php echo __( "CONFIG_FRIENDLYNAME_HELP", "DEVICE_CONFIG" ); ?>
</small>
</div>

<?php if( is_array( $status->Status->FriendlyName ) ): //array since >= 5.12.0h ?>
<div class="form-row mt-5">
<?php foreach( $status->Status->FriendlyName as $key => $friendlyName ): ?>
<div class="form-group col-12 col-sm-6">
<div class="form-group">
<?php

?>
<label for="FriendlyName">
<?php echo __( "CONFIG_FRIENDLYNAME", "DEVICE_CONFIG" )." (".( $key+1 ).")"; ?>
</label>
<input type="text"
class="form-control"
id="FriendlyName"
name='FriendlyName<?php echo( $key+1 ); ?>'
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo $friendlyName; ?>'
>
<small id="FriendlyNameHelp" class="form-text text-muted">
<?php echo __( "CONFIG_FRIENDLYNAME_HELP", "DEVICE_CONFIG" ); ?>
</small>
</div>
</div>
<?php endforeach; ?>
</div>

<?php else : //only one friendlyname was editable v < 5.12.0h ?>
<div class="form-group">
<?php
$friendlyName = is_array( $status->Status->FriendlyName ) //array since 5.12.0h
? $status->Status->FriendlyName[ 0 ] : $status->Status->FriendlyName;
?>
<label for="FriendlyName">
<?php echo __( "CONFIG_FRIENDLYNAME", "DEVICE_CONFIG" ); ?>
</label>
<input type="text"
class="form-control"
id="FriendlyName"
name='FriendlyName'
placeholder="<?php echo __( "PLEASE_ENTER" ); ?>"
value='<?php echo $friendlyName; ?>'
>
<small id="FriendlyNameHelp" class="form-text text-muted">
<?php echo __( "CONFIG_FRIENDLYNAME_HELP", "DEVICE_CONFIG" ); ?>
</small>
</div>
<?php endif; //END only one friendlyname was editable v < 5.12.0h ?>

<div class="form-group">
<label for="PowerOnState">
<?php echo __( "CONFIG_POWERONSTATE", "DEVICE_CONFIG" ); ?>
Expand Down

0 comments on commit 5e4ab22

Please sign in to comment.