updated qrz
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Paul 2020-05-23 13:38:20 +02:00
parent 4239c1dbb1
commit 8fb2302089
7 changed files with 1756 additions and 8 deletions

View File

@ -76,7 +76,11 @@ func Run(c echo.Context, config config.Config) (res QrzDatatableOutput, err erro
err = rows.MapScan(results)
colslice, _ := rows.Columns()
for _, column := range colslice {
line = append(line, fmt.Sprintf("%s", results[column]))
if results[column] == nil {
line = append(line, "")
} else {
line = append(line, fmt.Sprintf("%s", results[column]))
}
}
res.Data = append(res.Data, line)
count++
@ -207,15 +211,20 @@ func SetSearchStatement(config config.Config, qrzdt QrzDatatableInput) (searchst
// RunCSVExport runs the main loop
func RunCSVExport(c echo.Context, config config.Config) (data []byte, mime string, err error) {
mime = "text/csv"
rows, err := config.Db.Queryx(fmt.Sprintf(config.DbStatements.ExportCSV, config.DbTable))
rows, err := config.Db.Queryx(config.DbStatements.ExportCSV)
var res []string
res = append(res, "QRZ,Name,City,Dept,Country")
for rows.Next() {
var l []string
results := make(map[string]interface{})
err = rows.MapScan(results)
colslice, _ := rows.Columns()
for _, column := range colslice {
l = append(l, fmt.Sprintf("%s", results[column]))
if results[column] == nil {
l = append(l, "")
} else {
l = append(l, fmt.Sprintf("%s", results[column]))
}
}
line := strings.Join(l, ",")
res = append(res, line)

1715
static/js/axios.js Normal file

File diff suppressed because it is too large Load Diff

14
static/js/functions.js Normal file
View File

@ -0,0 +1,14 @@
function export_frs() {
var w = window.location.href = "/export_frs.csv";
}
new Vue({
el: '#countries',
data: {
selected: "France",
options: [{
text: 'France',
value: 'france'
}, ]
}
})

View File

@ -1,3 +0,0 @@
function export_frs() {
var w = window.location.href = "/export_frs.csv";
}

6
static/js/vue.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -9,8 +9,10 @@
<script type="text/javascript" src="static/js/jquery.js"></script>
<script type="text/javascript" src="static/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="static/js/main_table.js"></script>
<script type="text/javascript" src="static/js/main.js"></script>
<script type="text/javascript" src="static/js/axios.min.js"></script>
<script type="text/javascript" src="static/js/vue.min.js"></script>
<script type="text/javascript" src="static/js/datatable.js"></script>
<script type="text/javascript" src="static/js/functions.js"></script>
</head>
<body>
@ -33,6 +35,11 @@
</table>
</div>
<div>
<!--<select id="countries" v-model="selected">
<option v-for="option in options" v-bind:value="option.value">
{{ "{{ option.text }}" }}
</option>
</select>-->
<input type="button" value="Export CSV" onclick="export_frs()">
</div>
</body>