Skip to content

Commit

Permalink
[DOCS] Fix top navbar style and order of models (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
1technophile authored Jun 14, 2023
1 parent da4dbe5 commit 3927c00
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 65 deletions.
110 changes: 55 additions & 55 deletions docs/devices/devices_template.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,61 @@
<!DOCTYPE html>
<html lang="en">

<style>
body {
font-family: Arial, sans-serif;
color: #333;
background-color: #f8f8f8;
margin: 0;
padding: 0;
}

h1,
h2 {
margin-bottom: 0.5rem;
color: #333;
}

.dataTables_filter {
margin-bottom: 20px;
}

.dataTables_length {
margin-bottom: 10px;
}

.container {
margin: auto;
padding: 2rem;
background-color: #fff;
padding-top: 50px;
}

.dataTable thead .sorting {
background-image: url('https://cdn.datatables.net/1.10.25/images/sort_both.png');
background-repeat: no-repeat;
background-position: center right;
}

.dataTables_filter input {
width: 300px;
height: 30px;
}

.dataTable thead .sorting_asc {
background-image: url('https://cdn.datatables.net/1.10.25/images/sort_asc.png');
}

.dataTable thead .sorting_desc {
background-image: url('https://cdn.datatables.net/1.10.25/images/sort_desc.png');
}

#devices td:last-child,
#devices th:last-child {
text-align: center;
}
</style>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
Expand All @@ -17,61 +72,6 @@
<meta name="msapplication-TileColor" content="#000000">

<link rel="stylesheet" href="/assets/css/0.styles.e43f3e2e.css">

<style>
body {
font-family: Arial, sans-serif;
color: #333;
background-color: #f8f8f8;
margin: 0;
padding: 0;
}

h1,
h2 {
margin-bottom: 0.5rem;
color: #333;
}

.dataTables_filter {
margin-bottom: 20px;
}

.dataTables_length {
margin-bottom: 10px;
}

.container {
margin: auto;
padding: 2rem;
background-color: #fff;
padding-top: 50px;
}

.dataTable thead .sorting {
background-image: url('https://cdn.datatables.net/1.10.25/images/sort_both.png');
background-repeat: no-repeat;
background-position: center right;
}

.dataTables_filter input {
width: 300px;
height: 30px;
}

.dataTable thead .sorting_asc {
background-image: url('https://cdn.datatables.net/1.10.25/images/sort_asc.png');
}

.dataTable thead .sorting_desc {
background-image: url('https://cdn.datatables.net/1.10.25/images/sort_desc.png');
}

#devices td:last-child,
#devices th:last-child {
text-align: center;
}
</style>
</head>

<body>
Expand Down
14 changes: 4 additions & 10 deletions docs/devices/generate_devices_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
file_app = "devices.md"
http_file_app = "https://github.com/theengs/app/raw/development/docs/prerequisites/devices.md"

# Loading of the template file with the list of attributes
logger.info('Loading template file: %s', file_init)
loader_init = ptr.MarkdownTableFileLoader(file_init)
for table_data_init in loader_init.load():
table_merge = pd.DataFrame(table_data_init.as_dataframe())

# Loading of the device files into a table
logger.info('Loading device files')
for filename in os.listdir():
f = os.path.join(filename)
Expand All @@ -32,7 +30,6 @@
except:
logger.exception('Error with file: %s', f)

# Load the app compatible devices file
logger.info('Loading app compatible devices file: %s', http_file_app)
r = requests.get(http_file_app)
with open(file_app,'wb') as f:
Expand All @@ -42,30 +39,27 @@
for table_data_app in loader_app.load():
table_app = pd.DataFrame(table_data_app.as_dataframe())

# Transpose the table and adapt indexes
logger.info('Transposing table and adapting indexes')
table_merge = table_merge.set_index('Model Id').transpose()
table_merge = table_merge.reset_index()
table_merge = table_merge.rename(columns={'index':'Model_Id'})

# Add the app compatible devices to the table
logger.info('sorting table')
table_merge.sort_values(by=['Model_Id'], inplace=True, key=lambda col: col.str.lower())

logger.info('Adding app compatible devices to the table')
table_merge = table_merge.merge(table_app, how='left',left_on='Model_Id', right_on='Model_Id')

# Add link to the file from the model Id
logger.info('Adding links to the file from the model Id')
for ind in table_merge.index:
table_merge['Model_Id'][ind] = "<a href=\"" + table_merge['Filename'][ind].replace('.md','.html') + "\">" + table_merge['Model_Id'][ind] + "</a>"

# Drop unnecessary columns for the table
logger.info('Dropping unnecessary columns and sorting the table')
logger.info('Dropping unnecessary columns')
table_merge.drop(columns=['Communication','Frequency','Encrypted','Filename','Power source'], inplace=True)
table_merge.sort_values(by=['Brand'], inplace=True, key=lambda col: col.str.lower())

logger.info('Converting table to HTML')
html_table = table_merge.to_html(table_id='devices', escape=False, border=0)

# Read the template file
logger.info('Reading template file')
with open('devices_template.html', 'r') as f:
template = f.read()
Expand Down

0 comments on commit 3927c00

Please sign in to comment.