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
// modalClearTubes render modal popup for delete job in tubes.
22
func modalClearTubes(server string) string {
23 10
	var err error
24 10
	var buf, tubeList 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
		tubeList.WriteString(`<div class="checkbox"><label class=""><input type="checkbox" name="`)
32 10
		tubeList.WriteString(v)
33 10
		tubeList.WriteString(`" value="1"><b>`)
34 10
		tubeList.WriteString(html.EscapeString(v))
35 10
		tubeList.WriteString(`</b></label></div>`)
36
	}
37 10
	buf.WriteString(`<div class="modal fade" id="clear-tubes" data-cookie="tubefilter" tabindex="-1" role="dialog" aria-labelledby="clear-tubes-label" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button><h4 class="modal-title" id="clear-tubes-label">Clear multiple tubes</h4></div><div class="modal-body"><form><fieldset><div class="form-group"><label>Tube name <small class="text-muted">(supports <a href="http://james.padolsey.com/javascript/regex-selector-for-jquery/" target="_blank">jQuery regexp</a> syntax)</small></label><div class="input-group"><input class="form-control focused" id="tubeSelector" type="text" placeholder="prefix*" value="`)
38 10
	buf.WriteString(selfConf.TubeSelector)
39 10
	buf.WriteString(`"><div class="input-group-btn"><a href="javascript:void(0);" class="btn btn-info" id="clearTubesSelect">Select</a></div></div></div></fieldset><div><strong>Tube list</strong>`)
40 10
	buf.WriteString(tubeList.String())
41 10
	buf.WriteString(`</div></form></div><div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button><a href="#" class="btn btn-success" id="clearTubes">Clear selected tubes</a><br/><br/><p class="text-muted text-right small">* Tube clear works by peeking to all jobs and deleting them in a loop.</p></div></div></div></div>`)
42 10
	return buf.String()
43
}

Read our documentation on viewing source code .

Loading