Skip to content

Commit

Permalink
cssing
Browse files Browse the repository at this point in the history
  • Loading branch information
kflemin committed Apr 29, 2024
1 parent 059a028 commit 323b4b5
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 88 deletions.
12 changes: 11 additions & 1 deletion seed/static/seed/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@
"POST_GEOCODING_COUNTS": "Updated counts after geocoding",
"PROPERTY_MATCHING_FIELDS_REQUIREMENT": "At least one of the following Property fields is required",
"PUBLIC": "PUBLIC",
"PUBLIC_JSON": "Your public JSON feed URL is",
"PUBLIC_HTML": "Your public HTML URL is",
"PUBLIC_SHARE": "If the Public Feed functionality is enabled, this page can be used to configure what data is shared externally with the public-at-large.",
"Pair Properties to Tax Lots": "Pair Properties to Tax Lots",
"Pair Tax Lots to Properties": "Pair Tax Lots to Properties",
Expand Down Expand Up @@ -955,6 +957,13 @@
"SF_UPDATE_MINUTE_TEXT": "Enter the minute after the hour when the update should be run daily (0-59)",
"SF_VIOLATION_LABEL_TEXT": "Label used to designate that a SEED property has a violation. Example: 'Violation - Insufficient Data'",
"SHARE DATA WITH": "SHARE DATA WITH",
"SHARING_CYCLES": "Comma separated list of cycle ids. Results include inventory from the listed cycles. Default is all cycles.",
"SHARING_LABELS": "Comma-separated list of case-sensitive label names. Results will include inventory that has any of the listed labels. Default is all inventory.",
"SHARING_PAGE": "Number of the page of results to return. Default is 1.",
"SHARING_PER_PAGE": "Number of results per page. Default is 100.",
"SHARING_PROPERTIES": "Boolean True/False to return inventory of type 'Property'. Default is True.",
"SHARING_TAXLOTS": "Boolean True/False to return inventory of type 'Tax Lot'. Default is True.",
"SHARING_QUERY_PARAMS": "Query parameters can be added to the URL to filter the returned data",
"SHOWING_AVAILABLE_MATCHES": "Showing {start} to {end} of {total} available matches",
"SHOWING_FILTERED_PROPERTIES": "Showing {start} to {end} of {total} (filtered) properties",
"SHOWING_FILTERED_TAXLOTS": "Showing {start} to {end} of {total} (filtered) tax lots",
Expand Down Expand Up @@ -1165,6 +1174,7 @@
"UPLOAD_SENSORS_BUTTON": "Upload Sensors",
"UPLOAD_SENSOR_BUTTON": "Upload Sensor",
"UPLOAD_SENSOR_READINGS_BUTTON": "Upload Sensor Readings",
"URL_OPTIONS": "URL Options",
"USING_DEFAULT_UNITS_WARNING": "For columns with unit settings, default units will be used for conversions.",
"Units": "Units",
"Unknown": "Unknown",
Expand Down Expand Up @@ -1363,4 +1373,4 @@
"users": "users",
"white": "white",
"your data set name": "your data set name"
}
}
12 changes: 11 additions & 1 deletion seed/static/seed/locales/fr_CA.json
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@
"POST_GEOCODING_COUNTS": "Nombre mis à jour après le géocodage",
"PROPERTY_MATCHING_FIELDS_REQUIREMENT": "Au moins un des champs de propriété suivants est requis",
"PUBLIC": "PUBLIC",
"PUBLIC_JSON": "L'URL de votre flux JSON public est",
"PUBLIC_HTML": "Votre URL HTML publique est",
"PUBLIC_SHARE": "Si la fonctionnalité Flux public est activée, cette page peut être utilisée pour configurer les données partagées en externe avec le grand public.",
"Pair Properties to Tax Lots": "Associer des propriétés à des lots d'impôt",
"Pair Tax Lots to Properties": "Associer les lots d'impôt aux propriétés",
Expand Down Expand Up @@ -955,6 +957,13 @@
"SF_UPDATE_MINUTE_TEXT": "Selectionez à quelle minute après l'heure devrait s'effectuer la mise à jour quotidienne (0-59)",
"SF_VIOLATION_LABEL_TEXT": "Étiquette qui signale qu'une propriété a une violation. Example: 'Violation - Données Insufficientes'",
"SHARE DATA WITH": "PARTAGE DE DONNÉES AVEC",
"SHARING_CYCLES": "Liste d’identifiants de cycle séparés par des virgules. Les résultats incluent l’inventaire des cycles répertoriés. La valeur par défaut est tous les cycles.",
"SHARING_LABELS": "Liste de noms d'étiquettes sensibles à la casse, séparés par des virgules. Les résultats incluront l'inventaire portant l'une des étiquettes répertoriées. La valeur par défaut est tout l'inventaire.",
"SHARING_PAGE": "Numéro de la page de résultats à retourner. La valeur par défaut est 1.",
"SHARING_PER_PAGE": "Nombre de résultats par page. La valeur par défaut est 100.",
"SHARING_PROPERTIES": "Booléen True/False pour renvoyer un inventaire de type « Propriété ». La valeur par défaut est True.",
"SHARING_TAXLOTS": "Booléen True/False pour renvoyer un inventaire de type « Lot fiscal ». La valeur par défaut est True.",
"SHARING_QUERY_PARAMS": "Des paramètres de requête peuvent être ajoutés à l'URL pour filtrer les données renvoyées",
"SHOWING_AVAILABLE_MATCHES": "Affichage des {start} à {end} de {total} correspondances disponibles ",
"SHOWING_FILTERED_PROPERTIES": "Affichage {start} à {end} des {total} propriétés en tout (filtrées)",
"SHOWING_FILTERED_TAXLOTS": "Affichage {start} à {end} des {total} lots d'impôt en tout (filtrées)",
Expand Down Expand Up @@ -1165,6 +1174,7 @@
"UPLOAD_SENSORS_BUTTON": "Télécharger des capteurs",
"UPLOAD_SENSOR_BUTTON": "Télécharger le capteur",
"UPLOAD_SENSOR_READINGS_BUTTON": "Télécharger les relevés de capteur",
"URL_OPTIONS": "Options d'URL",
"USING_DEFAULT_UNITS_WARNING": "Pour les colonnes avec des paramètres d'unité, les unités par défaut seront utilisées pour les conversions.",
"Units": "Unités",
"Unknown": "Inconnue",
Expand Down Expand Up @@ -1363,4 +1373,4 @@
"users": "utilisateurs",
"white": "blanc",
"your data set name": "votre nom du jeu de données"
}
}
118 changes: 66 additions & 52 deletions seed/static/seed/partials/organization_sharing.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1>{$:: org.name $}</h1>
<div class="section_action_container left wider-diff">
<h2><i class="fa-solid fa-share-from-square"></i> {$:: 'Public Disclosure - Sharing Your Data' | translate $}</h2>
</div>
<div class="section_action_container right section_action_btn">
<div class="section_action_container right section_action_btn" ng-if="org.public_feed_enabled">
<button type="button" class="pull-right btn btn-primary" ng-click="save_settings()">{$:: 'Save Changes' | translate $} <i class="fa-solid fa-check" ng-show="settings_updated"></i></button>
</div>
</div>
Expand All @@ -33,63 +33,77 @@ <h2><i class="fa-solid fa-share-from-square"></i> {$:: 'Public Disclosure - Shar
<a ui-sref="organization_settings(::{organization_id: org.id})">{$:: 'Organization Settings' | translate $}</a>
<span translate>to enable or disable Public Feed functionality</span>
</p>
<p ng-if="org.public_feed_enabled"><span translate>You public feed URL is</span>: <strong> {$:: base_url $}/api/v3/public/organizations/{$:: org.id $}/feed.json</strong></p>
<h3 translate>Selecting Fields to Share</h3>
<p translate>PUBLIC_SHARE</p>
<div class="table_list_container has_borders">
<table class="table has_no_btm_margin table-striped table_highlight_first">
<thead>
<tr>
<th class="condensed_head" style="width: 150px" translate>SHARE</th>
<th translate>Table Name</th>
<th translate>Field Name</th>
</tr>
<tr class="sub_head">
<th class="sub_head check is_aligned_center condensed_head">
<input type="checkbox" ng-model="controls.public_select_all" ng-change="select_all_clicked('public')" />
</th>
<th class="sub_head" style="width: 235px">
<input
type="text"
class="form-control input-sm"
ng-model="filter_params.table_name"
placeholder="{$:: 'Search table name' | translate $}"
ng-class="{active: filter_params.table_name.length > 0}"
/>
</th>
<th class="sub_head">
<input
type="text"
class="form-control input-sm"
ng-model="filter_params.display_name"
placeholder="{$:: 'Search field name' | translate $}"
ng-class="{active: filter_params.display_name.length > 0}"
/>
</th>
</tr>
</thead>
</table>
<div class="vert_table_scroll_container">
<table class="table table-striped table_scroll">
<tbody>
<tr ng-repeat="field in fields | filter:filter_params:strict">
<td class="check is_aligned_center" style="width: 150px">
<input type="checkbox" ng-model="field.public_checked" />
</td>
<td style="width: 235px">
<span>{$:: field.table_name | translate $}</span>
</td>
<td>
<span>{$:: field.display_name | translate $}</span>
</td>
<div ng-if="org.public_feed_enabled">
<p><span translate>PUBLIC_JSON</span>: <strong> {$:: base_url $}/api/v3/public/organizations/{$:: org.id $}/feed.json</strong></p>
<p><span translate>PUBLIC_HTML</span>: <strong> {$:: base_url $}/api/v3/public/organizations/{$:: org.id $}/feed.html</strong></p>
<h3 translate>URL_OPTIONS</h3>
<p translate>SHARING_QUERY_PARAMS</p>
<ul>
<li><strong>page</strong>&mdash;<span translate>SHARING_PAGE</span></li>
<li><strong>per_page</strong>&mdash;<span translate>SHARING_PER_PAGE</span></li>
<li><strong>properties</strong>&mdash;<span translate>SHARING_PROPERTIES</span></li>
<li><strong>taxlots</strong>&mdash;<span translate>SHARING_TAXLOTS</span></li>
<li><strong>cycles</strong>&mdash;<span translate>SHARING_CYCLES</span></li>
<li><strong>labels</strong>&mdash;<span translate>SHARING_LABELS</span></li>
</ul>
<p><strong>Example:</strong> {$:: base_url $}/api/v3/public/organizations/{$:: org.id $}/feed.json?properties=True&taxlots=False&per_page=25&cycles=12,13</p>
<h3 translate>Selecting Fields to Share</h3>
<p translate>PUBLIC_SHARE</p>
<div class="table_list_container has_borders">
<table class="table has_no_btm_margin table-striped table_highlight_first">
<thead>
<tr>
<th class="condensed_head" style="width: 150px" translate>SHARE</th>
<th translate>Table Name</th>
<th translate>Field Name</th>
</tr>
</tbody>
<tr class="sub_head">
<th class="sub_head check is_aligned_center condensed_head">
<input type="checkbox" ng-model="controls.public_select_all" ng-change="select_all_clicked('public')" />
</th>
<th class="sub_head" style="width: 235px">
<input
type="text"
class="form-control input-sm"
ng-model="filter_params.table_name"
placeholder="{$:: 'Search table name' | translate $}"
ng-class="{active: filter_params.table_name.length > 0}"
/>
</th>
<th class="sub_head">
<input
type="text"
class="form-control input-sm"
ng-model="filter_params.display_name"
placeholder="{$:: 'Search field name' | translate $}"
ng-class="{active: filter_params.display_name.length > 0}"
/>
</th>
</tr>
</thead>
</table>
<div class="vert_table_scroll_container">
<table class="table table-striped table_scroll">
<tbody>
<tr ng-repeat="field in fields | filter:filter_params:strict">
<td class="check is_aligned_center" style="width: 150px">
<input type="checkbox" ng-model="field.public_checked" />
</td>
<td style="width: 235px">
<span>{$:: field.table_name | translate $}</span>
</td>
<td>
<span>{$:: field.display_name | translate $}</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="section_content_container pad-top-10">
<div class="section_content with_padding">
<div class="section_content with_padding" ng-if="org.public_feed_enabled">
<button type="button" class="pull-right btn btn-primary" ng-click="save_settings()">{$:: 'Save Changes' | translate $} <i class="fa-solid fa-check" ng-show="settings_updated"></i></button>
</div>
</div>
Expand Down
103 changes: 77 additions & 26 deletions seed/utils/public.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from urllib.parse import urlencode

import pint
Expand Down Expand Up @@ -69,7 +70,7 @@ def public_feed(org, request, html_view=False):


def _add_states_to_data(base_url, state_class, view_string, page, per_page, labels, cycles, org, html_view=False):
states = state_class.objects.filter(**{f"{view_string}__cycle__in": cycles}).order_by("-updated")
states = state_class.objects.filter(**{f"{view_string}__cycle__in": cycles, "organization": org}).order_by("-updated")

if labels is not None and org.public_feed_labels:
states = states.filter(**{f"{view_string}__labels__name__in": labels})
Expand All @@ -92,19 +93,6 @@ def _add_states_to_data(base_url, state_class, view_string, page, per_page, labe
view = getattr(state, f"{view_string}_set").first()

state_data = {"id": view.id}
if html_view:
state_data["cycle_id"] = view.cycle.id
state_data["cycle_name"] = view.cycle.name
else:
state_data["cycle"] = {"id": view.cycle.id, "name": view.cycle.name}
if org.public_feed_labels:
state_data["labels"] = ", ".join(view.labels.all().values_list("name", flat=True))
state_data.update(
{
"updated": state.updated,
"created": state.created,
}
)

for name, extra_data in public_columns:
if name in ["updated", "created"]:
Expand All @@ -116,9 +104,23 @@ def _add_states_to_data(base_url, state_class, view_string, page, per_page, labe
if isinstance(value, pint.Quantity):
# convert pint to string with units (json cannot display exponents)
value = f"{value.m} {value.u}"
if isinstance(value, datetime.datetime):
# convert datetime to readable format
value = value.strftime("%Y/%m/%d, %H:%M:%S")

state_data[name] = value

# add the "automatically" added content to the end of the data
if html_view:
state_data["cycle"] = f"{view.cycle.name} ({view.cycle.id})"
else:
state_data["cycle"] = {"id": view.cycle.id, "name": view.cycle.name}
if org.public_feed_labels:
state_data["labels"] = ", ".join(view.labels.all().values_list("name", flat=True))
state_data.update(
{"updated": state.updated.strftime("%Y/%m/%d, %H:%M:%S"), "created": state.created.strftime("%Y/%m/%d, %H:%M:%S")}
)

json_link = f'{base_url}api/v3/{"properties" if type(state) == PropertyState else "taxlots"}/{view.id}/?organization_id={view.cycle.organization.id}'
html_link = f'{base_url}app/#/{"properties" if type(state) == PropertyState else "taxlots"}/{view.id}'
if not html_view:
Expand All @@ -140,16 +142,20 @@ def _get_int(value, default):
return default


def dict_to_table(data, title):
def dict_to_table(data, title, params):
if not len(data):
return f"<div class='title'>{title}: None</div>"

html = f"<div class='title'>{title}</div>\n<table>\n"
return f"<h2>{title}: None</h2>"
cnt = 0
if title == "Properties":
cnt = params["property_count"]
else:
cnt = params["taxlot_count"]
html = f"<h2>{title}: {cnt}</h2>\n<table>\n"
headers = data[0].keys()
header_row = "<tr>" + "".join(f"<th>{header}</th>" for header in headers) + "</tr>\n"
header_row = "<tr>" + "".join(f"<th>{header.replace('_', ' ').title()}</th>" for header in headers) + "</tr>\n"
html += header_row
for datum in data:
row = "<tr>" + "".join(f"<td>{datum[header]}</td>" for header in headers) + "<tr/>\n"
row = "<tr>" + "".join(f"<td>{datum[header]}</td>" for header in headers) + "</tr>"
html += row
html += "</table>"

Expand Down Expand Up @@ -186,7 +192,7 @@ def page_navigation_link(base_url, pagination, query_params, next_page):

PUBLIC_HTML_HEADER = """
<div class="logo_container">
<a class="logo" href="/">
<a id="logo-link" class="logo" href="/">
<div class="logo_text">
<span class="logo_text_seed">Seed</span>
<span class="logo_text_platform">Platform™</span>
Expand All @@ -197,14 +203,17 @@ def page_navigation_link(base_url, pagination, query_params, next_page):

PUBLIC_HTML_STYLE = """
body {
font-family: 'PT Sans Narrow', 'Helvetica Neue', helvetica, arial, sans-serif;
font-family: 'PT Sans', 'Helvetica Neue', helvetica, arial, sans-serif;
font-weight: normal;
margin: 0;
}
#logo-link {
text-decoration: none;
}
.logo_container {
display: flex;
height: 50px;
background: #dcdcdc;
border-bottom: 1px solid #dcdcdc;
.logo {
display: flex;
Expand All @@ -226,6 +235,34 @@ def page_navigation_link(base_url, pagination, query_params, next_page):
}
}
}
.page_title {
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
text-overflow: ellipsis;
padding: 10px 0px;
border-bottom: 1px solid #dcdcdc;
h1 {
font-size: 18px;
font-weight: bold;
margin: 0;
white-space: nowrap;
}
}
h2 {
font-size: 18px;
font-weight: bold;
margin: 5px 20px 5px 20px;
}
.page-num {
margin: 5px 0px;
}
.nav-links {
margin: 5px; 0px; 5px; 5px;
}
.content {
width: 100vw;
overflow: scroll;
Expand All @@ -234,17 +271,31 @@ def page_navigation_link(base_url, pagination, query_params, next_page):
margin-left: 20px;
}
table, th, td {
border: 1px solid black;
border: 1px solid #dcdcdc;
border-collapse: collapse;
padding: 0 8px;
widthL 100%;
padding: 6px 10px 5px;
width: 80%;
}
table {
display: table;
border-spacing: 0;
margin: 20px;
tr:nth-child(odd) {
background-color: #eee;
}
}
tr {
display: table-row;
background-color: #fff;
}
th, td {
white-space: nowrap;
color: #222;
font-size: 13px;
}
.table-controls {
margin: 20px;
display: flex;
Expand Down

0 comments on commit 323b4b5

Please sign in to comment.