2016-08-24 08:12:20 +01:00
|
|
|
source: Developing/Style-Guidelines.md
|
2015-05-05 22:17:22 +01:00
|
|
|
# Style guidelines
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
This document is here to help style standards for contributions towards LibreNMS. These aren't strict rules but it is in
|
2015-05-05 22:17:22 +01:00
|
|
|
the users interest that a consistent well thought out Web UI is available.
|
|
|
|
|
|
|
|
### Responsiveness
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
The Web UI is designed to be mobile friendly and for the most part is and works well. It's worth spending sometime to
|
2016-01-30 22:37:28 -05:00
|
|
|
read through the [Bootstrap website](http://getbootstrap.com/css/#grid) to learn more about how to keep things responsive.
|
2015-05-05 22:17:22 +01:00
|
|
|
|
|
|
|
### Navigation bar
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
- Always pick the best location for new links to go, think about where users would expect the link to be located and name
|
2015-05-05 22:17:22 +01:00
|
|
|
it so that it's obvious what it does.
|
|
|
|
|
|
|
|
- Ensure sub sections within the Navigation are separated correctly using `<li role="presentation" class="divider"></li>`.
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
- Only use [Font Awesome icons](http://fontawesome.io/icons/) within the Navigation. It speeds up page load times quite
|
2015-05-05 22:17:22 +01:00
|
|
|
considerably.
|
|
|
|
|
|
|
|
### Buttons
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
Try to keep buttons colored to reflect the action they will take. Buttons are set using Bootstrap classes. The size of
|
2015-05-05 22:17:22 +01:00
|
|
|
the buttons will depend on the area of the website being used but btn-sm is probably the most common.
|
|
|
|
|
|
|
|
- Delete / Remove buttons: btn btn-danger
|
|
|
|
|
|
|
|
- Edit / Update buttons: btn btn-primary
|
|
|
|
|
|
|
|
- Add / Create buttons: btn btn-success
|
|
|
|
|
|
|
|
### Tables
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
Unless the table being used will only ever display a handful of items - yeah that's what we all said, then you need to
|
|
|
|
write your table using [JQuery Bootgrid](http://www.jquery-bootgrid.com/). This shouldn't take that much more code to
|
|
|
|
do this but provides so much flexibility along with stopping the need for retrieving all the data from SQL in the first
|
2015-05-05 22:17:22 +01:00
|
|
|
place.
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
As an example pull request, see [PR 706](https://github.com/librenms/librenms/pull/706/files) to get an idea of what
|
2015-05-22 13:38:52 +01:00
|
|
|
it's like to convert an existing pure html table to Bootgrid.
|
|
|
|
|
|
|
|
### Datetime format
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
When displaying datetimes, please ensure you use the format YYYY-MM-DD mm:hh:ss where possible, you shouldn't change the
|
2015-05-22 13:38:52 +01:00
|
|
|
order of this as it will be confusing to users. Cutting it short to just display YYYY-MM-DD mm:hh is fine :).
|
|
|
|
|
2016-01-30 21:06:58 -05:00
|
|
|
To keep things consistent we have the following variables which should be used rather than to format dates yourself.
|
2015-05-22 13:38:52 +01:00
|
|
|
This has the added benefit that users can customise the format:
|
|
|
|
|
|
|
|
```php
|
|
|
|
# Date format for PHP date()s
|
|
|
|
$config['dateformat']['long'] = "r"; # RFC2822 style
|
|
|
|
$config['dateformat']['compact'] = "Y-m-d H:i:s";
|
2015-05-22 14:07:38 +01:00
|
|
|
$config['dateformat']['byminute'] = "Y-m-d H:i";
|
2015-05-22 13:38:52 +01:00
|
|
|
$config['dateformat']['time'] = "H:i:s";
|
|
|
|
|
|
|
|
# Date format for MySQL DATE_FORMAT
|
|
|
|
$config['dateformat']['mysql']['compact'] = "%Y-%m-%d %H:%i:%s";
|
|
|
|
$config['dateformat']['mysql']['date'] = "%Y-%m-%d";
|
|
|
|
$config['dateformat']['mysql']['time'] = "%H:%i:%s";
|
|
|
|
```
|