From e489173e7ccbe7593e263b705c7937ff5be62b10 Mon Sep 17 00:00:00 2001 From: Andrea Lepori Date: Thu, 23 Feb 2023 13:04:50 +0100 Subject: add prototype for table of users --- server/templates/server/user_list_table.html | 98 ++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 server/templates/server/user_list_table.html (limited to 'server/templates') diff --git a/server/templates/server/user_list_table.html b/server/templates/server/user_list_table.html new file mode 100644 index 0000000..ede8d9d --- /dev/null +++ b/server/templates/server/user_list_table.html @@ -0,0 +1,98 @@ +{% extends 'registration/base_admin.html' %} + +{% block title %}Admin - Lista Utenti{% endblock %} + +{% block breadcrumb %} + Admin + Lista Utenti +{% endblock %} +{% block toolbar %} + +{% endblock %} + +{% block content %} + + +
+{% endblock %} + +{% block script %} + $(document).ready(function(){ + $('#modal1').modal(); + }); + + var tabledata = [ + {% for user in users %} + { + username: "{{user.user.username}}", + name: "{{user.user.first_name}}", + last_name: "{{user.user.last_name}}", + email: "{{user.user.email}}", + }, + {% endfor %} + ]; + + var columns = []; + + var col_categories = [ + {field: "base", name: "Informazioni base", cols: + [ + {title: "Username", field: "username"}, + {title: "Nome", field: "name"}, + {title: "Cognome", field: "last_name"}, + {title: "Email", field: "email", visible: false}, + ] + }, + ] + + var col_select = document.getElementById("column-select"); + for (var j = 0; j < col_categories.length; j++) { + col_select.innerHTML += '
'; + var all_visible = true; + for (var i = 0; i < col_categories[j].cols.length; i++) { + columns.push(col_categories[j].cols[i]); + if (columns[i].visible == false) { + col_select.innerHTML += '
'; + all_visible = false; + } else { + col_select.innerHTML += '
'; + } + } + + var cat_elem = document.getElementById("category_"+col_categories[j].field); + + if (all_visible) { + cat_elem.checked = true; + } + } + + //initialize table + var table = new Tabulator("#example-table", { + responsiveLayout:true, + data:tabledata, + columns:columns, + }); + + function update_cols() { + for (var i = 0; i < columns.length; i++) { + if (document.getElementById("filter_"+columns[i].field).checked) { + table.showColumn(columns[i].field); + } else { + table.hideColumn(columns[i].field); + } + } + } +{% endblock %} \ No newline at end of file -- cgit v1.2.1