| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- $(function() {
- var dataTable = $("#projects-table").DataTable({
- dom: "tp",
- data: projectData,
- paging: false,
- order: [[1, "desc"]],
- scrollY: 250,
- columns: [
- {
- data: "id",
- orderable: false,
- render: function(data, type) {
- if(type === "display") {
- var checked = (selectedProjectIds.indexOf(data) !== -1) ? "checked" : "";
- return "<input type=\"checkbox\" name=\"exclude_project_ids[]\" value=\"" + data + "\" " + checked + " /> ";
- }
- return data;
- }
- },
- {
- data: "id",
- class: "text-right"
- },
- {
- data: "name"
- },
- {
- data: "timeOfDay"
- },
- {
- data: "testCount",
- class: "text-right"
- },
- {
- data: "reportMonth",
- class: "text-right",
- render: function(data, type, row) {
- if(type === "display" || type === "filter") {
- return data;
- }
- return row.unixReport;
- }
- }
- ]
- });
- $(document).on("click", "#projects-table tbody tr", function(event) {
- if(!event.target.type || event.target.type !== "checkbox") {
- var checkbox = $(this).find("input[type=checkbox]").get(0);
- checkbox.checked = !checkbox.checked;
- }
- });
- $("#show-projects-list-button").click(function() {
- $("#projects-table-wrapper").toggle();
- dataTable.columns.adjust();
- });
- $("input[data-date-range-radio-input]").change(function() {
- let value = $(this).val();
- if(value === "custom") {
- $("#date-range-custom-fields").slideDown("fast");
- }
- else {
- $("#date-range-custom-fields").slideUp("fast");
- }
- });
- $("#export-pptx-action").click(function() {
- exportCharts("pptx");
- return true;
- });
- $("#export-odp-action").click(function() {
- exportCharts("odp");
- return true;
- });
- $("#date-range").daterangepicker({
- locale: {
- format: "DD/MM/YYYY"
- }
- }, function(start, end) {
- var startValue = start.format('YYYY-MM-DD');
- var endValue = end.format('YYYY-MM-DD');
- $("#date-start").val(startValue);
- $("#date-end").val(endValue);
- });
- $("#exclude-projects-header-checkbox").on("change", event => {
- const checked = event.currentTarget.checked;
- $("#projects-table > tbody").find("input:checkbox").prop("checked", checked);
- });
- });
- function testsByStageFormatter(value, context) {
- let dataset = context.dataset;
- let data = dataset.data;
- let total = data.reduce((total, value) => { return total + value; });
- let percentage = Math.round((value * 10000) / total) / 100;
- let suffix = "Test";
- if(parseInt(value) !== 1) {
- suffix += "s";
- }
- let label = "Stage " + (context.dataIndex + 1) + "\n";
- label += value + " " + suffix + "\n";
- label += percentage + "%";
- return label;
- }
- function exportCharts(action) {
- let formId = "";
- if(action === "pptx") {
- formId = "form-pptx";
- }
- if(action === "odp") {
- formId = "form-odp";
- }
- let form = $("#" + formId);
- let rendered = parseInt($(form).data("rendered"));
- if(rendered === 0) {
- for(var i in Chart.instances) {
- if(!Chart.instances.hasOwnProperty(i)) continue;
- let chart = Chart.instances[i];
- let base64 = chart.toBase64Image();
- $(form).append("<input type=\"hidden\" name=\"charts_b64[]\" value=\"" + base64 + "\" />");
- }
- $(form).data("rendered", "1");
- }
- $(form).find("input[type=submit]").click();
- }
|