1
// Copyright 2016 - 2020 The aurora Authors. All rights reserved. Use of this
2
// source code is governed by a MIT license that can be found in the LICENSE
3
// file.
4
//
5
// The aurora is a web-based beanstalkd queue server console written in Go
6
// and works on macOS, Linux and Windows machines. Main idea behind using Go
7
// for backend development is to utilize ability of the compiler to produce
8
// zero-dependency binaries for multiple platforms. aurora was created as an
9
// attempt to build very simple and portable application to work with local or
10
// remote beanstalkd server.
11

12
package main
13

14
import (
15
	"html"
16
	"strings"
17

18
	"github.com/xuri/aurora/beanstalk"
19
)
20

21
// modalAddSample render add sample popup window.
22
func modalAddSample(server string, tube string) string {
23 10
	var err error
24 10
	var tubeList, buf strings.Builder
25 10
	var bstkConn *beanstalk.Conn
26 10
	if bstkConn, err = beanstalk.Dial("tcp", server); err != nil {
27 10
		return ``
28
	}
29 10
	tubes, _ := bstkConn.ListTubes()
30
	for _, v := range tubes {
31 10
		var checked string
32 10
		if v == tube {
33 10
			checked = `checked="checked"`
34
		}
35 10
		tubeList.WriteString(`<div class="form-group"><div class="checkbox"><label><input type="checkbox" name="tubes[`)
36 10
		tubeList.WriteString(v)
37 10
		tubeList.WriteString(`]" value="1" `)
38 10
		tubeList.WriteString(checked)
39 10
		tubeList.WriteString(`>`)
40 10
		tubeList.WriteString(html.EscapeString(v))
41 10
		tubeList.WriteString(`</label></div></div>`)
42
	}
43 10
	buf.WriteString(`<div id="modalAddSample" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addsamples-label" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4 id="addsamples-label" class="modal-title">Add to samples</h4></div><div class="modal-body"><input type="hidden" name="tube" value="`)
44 10
	buf.WriteString(tube)
45 10
	buf.WriteString(`"/><fieldset><div class="alert alert-danger" id="sampleSaveAlert" style="display: none;"><button type="button" class="close" onclick="$('#sampleSaveAlert').fadeOut('fast');">×</button><span><strong>Error!</strong> Required fields are marked *</span></div><input type="hidden" name="addsamplejobid" id="addsamplejobid"><div class="form-group"><label for="addsamplename" title="You can highlight text inside the job, then hit the Add button, it will be automatically populated here."><b>Name *</b><i>(highlighted text is auto populated)</i></label><input class="form-control focused" id="addsamplename" name="addsamplename" type="text" value="" autocomplete="off"></div></fieldset><div><label class="control-label"><b>Available on tubes *</b></label>`)
46 10
	buf.WriteString(tubeList.String())
47 10
	buf.WriteString(`</div></div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Close</button><a href="#" class="btn btn-success" id="sampleSave">Save</a></div></div></div></div>`)
48 10
	return buf.String()
49
}

Read our documentation on viewing source code .

Loading