Commit 3f67f34d by Tấn Trần Thanh

done for search month, year, team and export data to csv

parent 0dc84db9
Pipeline #1566 canceled with stages
in 0 seconds
- if result[0].size > 0
table[border="1"]
tr.header_table--visible
th.green[colspan="8"] Task information
th.blue[colspan="6"] Overall
th.purple[colspan="7"] Estimation detail *final version
th.gray[colspan="7"] Actual time detail
th.yellow[colspan="4"] Bugs
th.pink[colspan="8"] Github
tr.header_table--visible
- thead.each_with_index do |head, index|
- if (0..7).include?(index)
th.green = head
- elsif (8..10).include?(index)
th.red = head
- elsif (11..13).include?(index)
th.blue = head
- elsif (14..20).include?(index)
th.purple = head
- elsif (21..27).include?(index)
th.gray = head
- elsif (28..31).include?(index)
th.yellow = head
- else
th.pink = head
- result[0].each_with_index do |_root_id, index|
tr
- (0..(thead.length - 1)).each do |i|
- if i == 0
td.sidebar_visible = result[0][index]
- else
td = result[i][index]
- else
h1 There is no data for the 'workflow report' table.
\ No newline at end of file
= stylesheet_link_tag 'style', plugin: 'workflow_report'
= javascript_include_tag(:application, :plugin => 'workflow_report')
.table-container
table[border="1"]
tr
- @thead.each do |head|
th = head
- @result[0].each_with_index do |_root_id, index|
tr
- (0..(@thead.length - 1)).each do |i|
td = @result[i][index]
fieldset.box.tabular
legend
| EXPORT WORKFLOW
= form_tag do
= select_tag :month ,options_for_select(1..12, Time.now.month),{ prompt: "Select month" }
= select_tag :year ,options_for_select((Time.now.year - 5)..(Time.now.year + 1), Time.now.year),{ prompt: "Select year" }
= select_tag :team, options_for_select(@team_options), { prompt: "Select team" }
= submit_tag 'export', id: 'export'
button.export-button Download .CSV
#data_workflow
window.addEventListener('load', function () {
$('#export').click(function (event) {
event.preventDefault()
const month = $('#month').val()
const year = $('#year').val()
const team = $('#team').val()
if (year === '' || month === '' || team === '') {
alert('Please complete all the necessary fields.')
} else {
$.ajax({
url: 'workflow_report/export',
type: 'GET',
data: {month: month, year: year, team: team},
success: function (response) {
$('#data_workflow').html(response)
},
error: function (error) {
console.log(error)
},
})
}
})
const download = function (data) {
const blob = new Blob([data], {type: 'text/csv'});
const url = window.URL.createObjectURL(blob)
const a = document.createElement('a')
a.setAttribute('href', url)
a.setAttribute('download', "download.csv");
a.click()
}
$(".export-button").on("click", function () {
exportToCSV();
});
function exportToCSV() {
const table = $("table");
const rows = table.find("tr");
let csv = [];
rows.each(function (index) {
const cols = $(this).find("td, th");
let rowText = [];
let currentColspan = 1;
cols.each(function () {
const text_report = $(this).text();
if ($(this).attr("colspan")) {
currentColspan = parseInt($(this).attr("colspan"), 10);
}
if (currentColspan > 1) {
for (let i = 0; i < currentColspan; i++) {
i === 0 ? rowText.push(text_report) : rowText.push('')
}
} else {
text_report.includes(',') ? rowText.push(`"${text_report}"`) : rowText.push(text_report);
}
currentColspan = Math.max(1, currentColspan - 1);
});
csv.push(rowText.join(","));
});
const csvContent = csv.join("\n");
download(csvContent);
}
});
.table-container {
overflow-x: auto;
#data_workflow {
overflow: auto;
height: 100vh;
}
table {
display: inline-block;
table-layout: fixed;
border-collapse: collapse;
}
.header_table--visible {
position: sticky;
top: 0;
z-index: 2;
}
.sidebar_visible {
position: sticky;
background: #dacbcb;
left: 0;
z-index: 1;
}
.green {
background-color: #92ce92;
}
.red {
background-color: #e38585;
}
.blue {
background-color: #b2b2f0;
}
.purple {
background-color: #f7adf7;
}
.gray {
background-color: #e6e4e4;
}
.yellow {
background-color: #eaeab0;
}
.pink {
background-color: pink;
}
#date_from, #date_to, #team, #export {
margin-right: 24px;
}
\ No newline at end of file
......@@ -2,3 +2,5 @@
# See: http://guides.rubyonrails.org/routing.html
get 'workflow_report', to: 'workflow_report#index'
get 'workflow_report/export', to: 'workflow_report#export'
get '/download_csv', to: 'workflow_report#export_csv'
github_token: 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
teams:
- Kyujin:
- 9
- 142
- 88
- Sumai:
- 17
- 29
- 31
- 131
- 140
- Kuruma:
- 139
- 138
- 94
- 90
- 93
- 120
- 128
- 147
- 121
- 116
- LS:
- 134
- PS:
- 145
- 141
- 144
- 151
- Sanko:
- 91
- 149
- CORDA:
- 92
- 112
- APW-Travelist-Air:
- 133
- APW-Travelist-Hotel:
- 148
- APW-Voyager:
- 146
- APW-SUB:
- 137
......@@ -11,5 +11,7 @@ Redmine::Plugin.register :workflow_report do
version '0.0.1'
url 'http://example.com/path/to/plugin'
author_url 'http://example.com/about'
configfile = File.join(File.dirname(__FILE__), 'config', 'settings.yml')
$workflow_report_config = YAML::load_file(configfile)
menu :top_menu, :workflow_report, { controller: 'workflow_report', action: 'index' }, caption: 'Workflow Report'
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment