From 10aca2929976a3ea35b2ef8a877756ef72c9d3da Mon Sep 17 00:00:00 2001 From: Felipe Bormann Date: Tue, 30 May 2017 20:22:30 -0300 Subject: [PATCH] finished pagination of table and added table header, still missing translation and styling to do --- dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/general.sassc | Bin 39457 -> 0 bytes dashboards/static/dashboards/css/general.css | 37 ++++++++++++++++++++++++++++--------- dashboards/static/dashboards/css/general.css.map | 2 +- dashboards/static/dashboards/css/general.sass | 20 ++++++++++++++++++++ dashboards/static/dashboards/js/jquery.table.hpaging.min.js | 21 +++++++++++++++++++++ dashboards/static/dashboards/js/logbehavior.js | 12 +++++++++++- dashboards/views.py | 2 +- 7 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 dashboards/static/dashboards/js/jquery.table.hpaging.min.js diff --git a/dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/general.sassc b/dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/general.sassc index 32e6ba8..4e9f622 100644 Binary files a/dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/general.sassc and b/dashboards/static/dashboards/.sass-cache/d1f4112ca6d0e14bdf64d22b0b14a2322f24cc83/general.sassc differ diff --git a/dashboards/static/dashboards/css/general.css b/dashboards/static/dashboards/css/general.css index aba8749..5d34b9f 100644 --- a/dashboards/static/dashboards/css/general.css +++ b/dashboards/static/dashboards/css/general.css @@ -137,14 +137,33 @@ li.selected { #period-selector { display: flex; } -#log-table tr { - height: 25px; } - #log-table tr:nth-child(odd) { - background-color: #bdbdbd; } - #log-table tr:nth-child(even) { - background-color: white; } - #log-table tr td { - margin-right: 1%; - padding-right: 1%; } +#log-table { + width: 100%; + border: 1px solid #bdbdbd; } + #log-table tr { + height: 25px; } + #log-table tr:nth-child(odd) { + background-color: #bdbdbd; } + #log-table tr:nth-child(even) { + background-color: white; } + #log-table tr td { + margin-right: 1%; + padding-right: 1%; } + +#log-count { + text-align: center; } + +.pagination { + display: inline-block; } + .pagination a { + color: black; + float: left; + padding: 8px 16px; + text-decoration: none; } + .pagination a.active { + background-color: #4CAF50; + color: white; } + .pagination a:hover:not(.active) { + background-color: #ddd; } /*# sourceMappingURL=general.css.map */ diff --git a/dashboards/static/dashboards/css/general.css.map b/dashboards/static/dashboards/css/general.css.map index 4d06f24..87cd739 100644 --- a/dashboards/static/dashboards/css/general.css.map +++ b/dashboards/static/dashboards/css/general.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAEA,YAAY;EACR,MAAM,EAAE,iBAAiB;EACzB,aAAa,EAAE,IAAI;EACnB,OAAO,EAAE,IAAI;EACb,QAAQ,EAAE,IAAI;EACd,KAAK,EAAE,IAAI;EACX,gBAAgB,EAAE,OAAO;;AAE7B,sBAAsB;EAClB,MAAM,EAAE,GAAG;EACX,OAAO,EAAE,KAAK;EACd,yBAAE;IACE,KAAK,EAdC,OAAO;EAgBjB,yBAAE;IACE,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,GAAG;IACV,aAAa,EAAE,GAAG;IAElB,2BAAC;MACG,KAAK,EAAE,IAAI;;AAGvB,aAAa;EACT,YAAY,EAAE,EAAE;EAChB,KAAK,EAAE,KAAK;EACZ,SAAS,EAAE,IAAI;EACf,gBAAgB,EAAE,OAAO;EACzB,KAAK,EAAE,IAAI;EACX,UAAU,EAAE,MAAM;EAClB,aAAa,EAAE,IAAI;EACnB,MAAM,EAAE,IAAI;;AAGhB,WAAW;EACP,gBAAgB,EAAE,OAAO;EACzB,KAAK,EAAE,IAAI;EACX,UAAU,EAAE,MAAM;EAClB,aAAa,EAAE,IAAI;;AAIvB,sBAAsB;EAClB,UAAU,EAAE,2CAA2C;EACvD,MAAM,EAAE,IAAI;EACZ,aAAa,EAAE,IAAI;EACnB,KAAK,EAAE,OAAO;EACd,WAAW,EAAE,GA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X,OAAO,EAAE,QAAQ;IACjB,eAAe,EAAE,IAAI;EAEzB,oBAAQ;IACJ,gBAAgB,EAAE,OAAO;IACzB,KAAK,EAAE,KAAK;EAEhB,gCAAoB;IAChB,gBAAgB,EAAE,IAAI", "sources": ["general.sass"], "names": [], "file": "general.css" diff --git a/dashboards/static/dashboards/css/general.sass b/dashboards/static/dashboards/css/general.sass index e157ef8..7aee78f 100644 --- a/dashboards/static/dashboards/css/general.sass +++ b/dashboards/static/dashboards/css/general.sass @@ -162,6 +162,8 @@ li.selected $colors: gray, white #log-table + width: 100% + border: 1px solid #bdbdbd tr height: 25px &:nth-child(odd) @@ -172,3 +174,21 @@ $colors: gray, white td margin-right: 1% padding-right: 1% + +#log-count + text-align: center + +.pagination + display: inline-block + a + color: black + float: left + padding: 8px 16px + text-decoration: none + + a.active + background-color: #4CAF50 + color: white + + a:hover:not(.active) + background-color: #ddd diff --git a/dashboards/static/dashboards/js/jquery.table.hpaging.min.js b/dashboards/static/dashboards/js/jquery.table.hpaging.min.js new file mode 100644 index 0000000..e99678b --- /dev/null +++ b/dashboards/static/dashboards/js/jquery.table.hpaging.min.js @@ -0,0 +1,21 @@ +(function (b) { + b(function () { + b.widget("blk.hpaging", { + options: { limit: 5, activePage: 1, parentID: "", navBar: null, totalPages: "" }, _create: function () { var a = this._getNavBar(); b(this.element).after(a) }, _getNavBar: function () { var a; a = b(this.element).prop("id"); this.options.parentID = a; a = b("
").addClass("pagination").data("parentID", a); this.options.navBar = a; this.setPages(this.options.activePage); return a }, clearPages: function () { + b(this.options.navBar).empty(); b("#" + this.options.parentID + " > tbody > tr").show(); + b("#" + this.options.parentID + " > tbody > tr").removeData("page"); return !0 + }, newRow: function (a) { this.setPages(); var c = b("#" + this.options.parentID + " > tbody > tr"); a = b(c).eq(a).data("page"); this.activePage(a) }, newLimit: function (a) { this.options.limit = a; this.setPages() && this.activePage(1) }, setPages: function (a) { + var c = !1; if (this.clearPages()) { + var c = this.options.limit, h = b("#" + this.options.parentID + " > tbody > tr"), f, d = h.length / c; f = d; d = d.toString().split("."); 2 == d.length && (f = parseInt(d[0]) + 1); 0 == f && (f = 1); d = + this.options.parentID; this._setPage(d, 1, "<<"); this._setPage(d, "P-1", "<"); for (var g = 0, k = c, e, l = 1; l <= f; l++)g = h.slice(g, k), e = l, b(g).removeData("page"), b(g).data("page", e), this._setPage(d, e, e), g = k, k = parseInt(k) + parseInt(c); this._setPage(d, "P+1", ">"); this._setPage(d, e, ">>"); this.options.totalPages = e; void 0 !== a && this.activePage(a); c = !0 + } return c + }, _setPage: function (a, c, h) { a = b("", { href: "#", text: h, "data-page": c }).appendTo(this.options.navBar); this._on(a, { click: "onPageClick" }) }, activePage: function (a) { + var c = + 1 * a; this.options.activePage = c; b("#" + this.options.parentID + " > tbody > tr").each(function () { b(this).data("page") == c ? b(this).show() : b(this).hide() }); this._selectActivePage() + }, _selectActivePage: function () { var a = this.options.activePage; b(this.options.navBar).find("a").each(function () { var c = b(this).text(); b(this).data("page") == a && "<<" != c && ">>" != c && (b(this).attr("class", "active"), b(this).siblings().attr("class", "")) }) }, onPageClick: function (a) { + a.preventDefault(); a = b(a.target).data("page"); "P-1" == a ? (a = this.options.activePage - + 1, 1 > a && (a = 1)) : "P+1" == a && (a = this.options.activePage + 1, a > this.options.totalPages && (a = this.options.totalPages)); this.activePage(a) + } + }) + }) +})(jQuery); \ No newline at end of file diff --git a/dashboards/static/dashboards/js/logbehavior.js b/dashboards/static/dashboards/js/logbehavior.js index 3bc8cdf..a28e314 100644 --- a/dashboards/static/dashboards/js/logbehavior.js +++ b/dashboards/static/dashboards/js/logbehavior.js @@ -29,13 +29,18 @@ var log = { render_table: function(target_id, data){ table_body = $('#' + target_id); + + content = ""; //add register count count = data.length; + $(table_body).append( "

"+count + " registros" + "

"); + //load row names at the top - + content += "" + + "" //build row html data data.forEach(function(datum){ content += "" + html_helper.row_builder(datum) + ""; @@ -44,6 +49,11 @@ var log = { content += "
Datetime Usuário Components Recurso Ação Categoria Assunto Contexto
"; $(table_body).append(content); + + $('#log-table').hpaging({ + "limit": 20, //maximum number of elements per page + }); + }, } diff --git a/dashboards/views.py b/dashboards/views.py index ca61997..3af6ca2 100644 --- a/dashboards/views.py +++ b/dashboards/views.py @@ -110,7 +110,7 @@ class LogView(LogMixin, generic.TemplateView): context = {} self.createLog(actor = self.request.user) - context['javascript_files'] = ['dashboards/js/logbehavior.js'] + context['javascript_files'] = ['dashboards/js/logbehavior.js', "dashboards/js/jquery.table.hpaging.min.js"] context['child_template'] = "dashboards/log.html" return context -- libgit2 0.21.2