Skip to content

Commit 3324623

Browse files
author
SM_SAYEED
committed
upload_box fix for drive link
1 parent f4e6b6f commit 3324623

File tree

1 file changed

+74
-96
lines changed

1 file changed

+74
-96
lines changed

templates/property_detail.html

Lines changed: 74 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -4,158 +4,136 @@
44
<title>{{ pretty_title }} - {{ tab.title() }} | Patterns Matter</title>
55
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
66
<style>
7-
.container { max-width:1200px;margin:2em auto;padding:2em;background:#363636;border-radius:18px;box-shadow:0 2px 16px #2224; }
8-
.upload-block { margin-top: 2em; background:#363636; border-radius:10px; padding:1.5em; }
9-
.upload-block h3 { color:#f08903; margin-top:0; }
10-
.msg { color:#e67e22; font-weight:bold; margin-bottom:1em; }
11-
.data-table-wrap { overflow-x:auto; margin-top:2em; }
12-
.data-table { width:100%; border-collapse:collapse; table-layout:fixed; background:#363636; }
13-
.data-table th, .data-table td { border:1px solid #444; padding:.7em 1em; text-align:left; word-break:break-word; vertical-align:middle; }
14-
.data-table th { background:#282; color:#fff; }
15-
.data-table input[type="text"] { max-width:170px; background:#222; color:#fff; border:1px solid #888; border-radius:6px; padding:.2em .7em; }
16-
.data-table button, .data-table .delete-btn { min-width:55px; padding:.3em 1em; }
17-
.data-table .delete-btn { background:#d33; color:#fff; border:none; border-radius:6px; font-weight:bold; margin-left:.7em; cursor:pointer; }
18-
.data-table .delete-btn:hover { background:#a22; }
19-
.pill { display:inline-block; padding:.15em .55em; border-radius:10px; font-size:.85em; }
20-
.pill.drive { background:#204f2a; color:#caffda; }
21-
.pill.local { background:#444; color:#eee; }
22-
.return-home { display:inline-block; margin-top:2em; background:#2a6; color:#fff; border-radius:6px; padding:.6em 1.7em; text-decoration:none; font-weight:bold; }
23-
.return-home:hover { background:#225c44; }
24-
@media (max-width: 900px) { .container{padding:.7em} .data-table{font-size:.97em} }
25-
.small { font-size:.9em; color:#bcd; }
7+
.container { max-width: 1200px; margin: 2em auto; padding: 2em; background: #363636; border-radius: 18px; box-shadow: 0 2px 16px #2224; }
8+
.upload-block { margin-top: 2em; background: #363636; border-radius: 10px; padding: 1.5em; }
9+
.upload-block h3 { color: #f08903; margin-top: 0; }
10+
.msg { color: #e67e22; font-weight: bold; margin-bottom: 1em; }
11+
.data-table-wrap { overflow-x: auto; margin-top: 2em; }
12+
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; background: #363636; }
13+
.data-table th, .data-table td { border: 1px solid #444; padding: 0.7em 1em; text-align: left; word-break: break-word; vertical-align: middle; }
14+
.data-table th { background: #282; color: #fff; }
15+
.data-table input[type="text"] { max-width: 170px; background: #222; color: #fff; border: 1px solid #888; border-radius: 6px; padding: 0.2em 0.7em; }
16+
.data-table button, .data-table .delete-btn { min-width: 55px; padding: 0.3em 1em; }
17+
.data-table .delete-btn { background: #d33; color: #fff; border: none; border-radius: 6px; font-weight: bold; margin-left: 0.7em; cursor: pointer; }
18+
.data-table .delete-btn:hover { background: #a22; }
19+
.return-home { display: inline-block; margin-top: 2em; background: #2a6; color: #fff; border-radius: 6px; padding: 0.6em 1.7em; text-decoration: none; font-weight: bold; }
20+
.return-home:hover { background: #225c44; }
21+
@media (max-width: 900px) { .container { padding: 0.7em; } .data-table { font-size: 0.97em; } }
2622
</style>
2723
</head>
2824
<body>
2925
<div class="container">
30-
<div class="admin-link" style="text-align:right; margin-bottom:1em;">
31-
{% if admin %}<a href="{{ url_for('logout') }}">Logout</a>{% else %}<a href="{{ url_for('login') }}">Admin Login</a>{% endif %}
26+
<!-- Login/Logout button -->
27+
<div class="admin-link" style="text-align: right; margin-bottom: 1em;">
28+
{% if session.admin %}
29+
<a href="{{ url_for('logout') }}">Logout</a>
30+
{% else %}
31+
<a href="{{ url_for('login') }}">Admin Login</a>
32+
{% endif %}
3233
</div>
3334

3435
<h1>{{ pretty_title }}: {{ tab.title() }}</h1>
3536

36-
<!-- Tabs -->
37-
<div style="margin-bottom:1.5em;">
37+
<!-- Tab Navigation -->
38+
<div style="margin-bottom: 1.5em;">
3839
<a href="{{ url_for('property_detail', property_name=property_name, tab='dataset') }}"
39-
style="padding:.6em 1.5em;border-radius:6px;text-decoration:none;font-weight:bold;
40-
background:{% if tab == 'dataset' %}#2a6{% else %}#363636{% endif %};color:#fff;margin-right:1em;">Dataset</a>
40+
style="padding: 0.6em 1.5em; border-radius: 6px; text-decoration: none; font-weight: bold;
41+
background: {% if tab == 'dataset' %}#2a6{% else %}#363636{% endif %}; color: #fff; margin-right: 1em;">
42+
Dataset
43+
</a>
4144
<a href="{{ url_for('property_detail', property_name=property_name, tab='results') }}"
42-
style="padding:.6em 1.5em;border-radius:6px;text-decoration:none;font-weight:bold;
43-
background:{% if tab == 'results' %}#2a6{% else %}#363636{% endif %};color:#fff;">Results</a>
45+
style="padding: 0.6em 1.5em; border-radius: 6px; text-decoration: none; font-weight: bold;
46+
background: {% if tab == 'results' %}#2a6{% else %}#363636{% endif %}; color: #fff;">
47+
Results
48+
</a>
4449
</div>
4550

46-
<!-- Admin-only: Drive Upload Form -->
47-
{% if admin %}
51+
<!-- Admin upload form -->
52+
{% if session.admin %}
4853
<div class="upload-block">
49-
<h3>Add a {{ pretty_title }} {{ tab.title() }} from Google Drive</h3>
50-
{% if upload_message %}<div class="msg">{{ upload_message }}</div>{% endif %}
51-
<form method="post">
52-
<div class="small">Paste a Drive share link or file ID. Provide a short label to show publicly.</div>
53-
<div style="margin-top:.7em;">
54-
<input type="text" name="drive_link" placeholder="Drive link or file ID" style="width:360px" required>
55-
<input type="text" name="label" placeholder="Public label (e.g., Featurized_Band_Gap_Data.csv)" style="width:360px" required>
56-
</div>
57-
{% if tab == 'dataset' %}
58-
<div style="margin-top:.7em;">
59-
<input type="text" name="row_source" placeholder="Source (optional)" style="width:360px">
60-
</div>
61-
{% endif %}
62-
<div style="margin-top:.7em;">
63-
<input type="text" name="row_description" placeholder="Description (optional)" style="width:720px">
64-
</div>
65-
<div style="margin-top:1em;">
66-
<button type="submit" name="add_drive" value="1">Add</button>
67-
</div>
54+
<h3>Upload a {{ pretty_title }} {{ tab.title() }} {% if tab == 'dataset' %}(CSV or NPY){% else %}(JPG, PNG, GIF, PDF, DOCX){% endif %}</h3>
55+
{% if upload_message %}
56+
<div class="msg">{{ upload_message }}</div>
57+
{% endif %}
58+
<form method="post" enctype="multipart/form-data">
59+
<input type="file" name="file" required>
60+
<input type="submit" value="Upload">
6861
</form>
6962
</div>
7063
{% endif %}
7164

72-
{% if edit_message %}<div class="msg">{{ edit_message }}</div>{% endif %}
65+
{% if edit_message %}
66+
<div class="msg">{{ edit_message }}</div>
67+
{% endif %}
7368

74-
<!-- Public table -->
69+
<!-- Uploaded files table -->
7570
<div class="data-table-wrap">
7671
<table class="data-table">
7772
<tr>
7873
<th>Filename</th>
7974
{% if tab == 'dataset' %}<th>Source</th>{% endif %}
8075
<th>Description</th>
8176
<th>Uploaded At</th>
82-
<th>Storage</th>
8377
<th>Operation</th>
8478
</tr>
85-
86-
{% for row in uploads %}
79+
{% for fname, source, description, uploaded_at in uploads %}
8780
<tr>
88-
<td>{{ row.filename }}</td>
89-
81+
<td>{{ fname }}</td>
9082
{% if tab == 'dataset' %}
91-
<td>
92-
{% if admin %}
93-
<form method="post" style="display:inline;">
94-
<input type="hidden" name="row_filename" value="{{ row.filename }}">
95-
<input type="text" name="row_source" value="{{ row.source or '' }}" size="18">
96-
{% else %}
97-
{{ row.source or '' }}
98-
{% endif %}
99-
</td>
83+
<td>
84+
{% if session.admin %}
85+
<form method="post" style="display:inline;">
86+
<input type="hidden" name="row_filename" value="{{ fname }}">
87+
<input type="text" name="row_source" value="{{ source or '' }}" size="18">
88+
{% else %}
89+
{{ source or '' }}
90+
{% endif %}
91+
</td>
10092
{% endif %}
101-
10293
<td>
103-
{% if admin %}
94+
{% if session.admin %}
10495
{% if tab == 'dataset' %}
105-
<input type="text" name="row_description" value="{{ row.description or '' }}" size="22">
96+
<input type="text" name="row_description" value="{{ description or '' }}" size="22">
10697
<button type="submit" name="edit_row" value="1" style="margin-left:6px;">Save</button>
10798
</form>
10899
{% else %}
109100
<form method="post" style="display:inline;">
110-
<input type="hidden" name="row_filename" value="{{ row.filename }}">
111-
<input type="text" name="row_description" value="{{ row.description or '' }}" size="22">
101+
<input type="hidden" name="row_filename" value="{{ fname }}">
102+
<input type="text" name="row_description" value="{{ description or '' }}" size="22">
112103
<button type="submit" name="edit_row" value="1" style="margin-left:6px;">Save</button>
113104
</form>
114105
{% endif %}
115106
{% else %}
116-
{{ row.description or '' }}
107+
{{ description or '' }}
117108
{% endif %}
118109
</td>
119-
120-
<td>{{ row.uploaded_at.split('T')[0] if row.uploaded_at else '' }}</td>
121-
122-
<td>
123-
<span class="pill {{ row.storage }}">{{ row.storage|title }}</span>
124-
</td>
125-
110+
<td>{{ uploaded_at.split('T')[0] if uploaded_at else '' }}</td>
126111
<td>
127-
{% if row.storage == 'drive' %}
128-
<a href="{{ row.preview_url }}" target="_blank">View</a>
129-
{% if row.download_url %} | <a href="{{ row.download_url }}" target="_blank">Download</a>{% endif %}
130-
{% else %}
131-
{% if tab == 'dataset' and (row.filename.endswith('.csv') or row.filename.endswith('.npy')) %}
132-
<a href="{{ url_for('view_table', filename=property_name + '/' + tab + '/' + row.filename) }}" target="_blank">View</a>
133-
{% elif tab == 'results' %}
134-
<a href="{{ url_for('view_result_file', property_name=property_name, tab=tab, filename=row.filename) }}" target="_blank">View</a>
135-
{% endif %}
136-
| <a href="{{ url_for('uploaded_file', filename=property_name + '/' + tab + '/' + row.filename) }}" download>Download</a>
112+
{% if tab == 'dataset' and (fname.endswith('.csv') or fname.endswith('.npy')) %}
113+
<a href="{{ url_for('view_table', filename=property_name + '/' + tab + '/' + fname) }}" target="_blank">View</a>
114+
{% elif tab == 'results' %}
115+
<a href="{{ url_for('view_result_file', property_name=property_name, tab=tab, filename=fname) }}" target="_blank">View</a>
137116
{% endif %}
117+
<a href="{{ url_for('uploaded_file', filename=property_name + '/' + tab + '/' + fname) }}" download>Download</a>
138118

139-
{% if admin %}
140-
<form action="{{ url_for('delete_dataset_file', property_name=property_name, tab=tab, filename=row.filename) }}"
141-
method="post" style="display:inline;" onsubmit="return confirm('Delete this entry?');">
142-
<button type="submit" class="delete-btn">Delete</button>
143-
</form>
119+
{% if session.admin %}
120+
<form action="{{ url_for('delete_dataset_file', property_name=property_name, tab=tab, filename=fname) }}" method="post" style="display:inline;" onsubmit="return confirm('Delete this file?');">
121+
<button type="submit" class="delete-btn">Delete</button>
122+
</form>
144123
{% endif %}
145124
</td>
146125
</tr>
147126
{% endfor %}
148-
149127
{% if uploads|length == 0 %}
150128
<tr>
151-
<td colspan="{% if tab == 'dataset' %}6{% else %}5{% endif %}">No files uploaded yet for this {{ tab }}.</td>
129+
<td colspan="{% if tab == 'dataset' %}5{% else %}4{% endif %}">No files uploaded yet for this {{ tab }}.</td>
152130
</tr>
153131
{% endif %}
154132
</table>
155133
</div>
156134

157135
<a class="return-home" href="{{ url_for('public_home') }}">Return to Home</a>
158-
<a class="return-home" href="{{ url_for('materials_portal') }}" style="margin-left:1.5em;">Back to Materials Database</a>
136+
<a class="return-home" href="{{ url_for('materials_portal') }}" style="margin-left: 1.5em;">Back to Materials Database</a>
159137
</div>
160138
</body>
161-
</html>
139+
</html>

0 commit comments

Comments
 (0)