ui

package
v0.0.0-...-bf2171b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2015 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Errors
	BAD_REQUEST = "Sorry, that is an invalid request"
	BAD_POST    = "Sorry, we cannot respond to that request. Please try again."

	// Info messages
	EMAIL_SENT = "The selected items have been sent to your email address"

	// urls
	HOME_URL    = "/scanned/"
	ACCOUNT_URL = "/account/"
)

Variables

View Source
var (
	ACCOUNT_EDIT_TEMPLATE_FILES = []string{"account.html", "head.html", "navigation_tabs.html", "modal.html", "scripts.html"}
	ACCOUNT_EDIT_TEMPLATES      *template.Template
)
View Source
var (
	TEMPLATE_LIST = func(templatesFolder string, templateFiles []string) []string {
		t := make([]string, 0)
		for _, f := range templateFiles {
			t = append(t, path.Join(templatesFolder, f))
		}
		return t
	}

	UNSUPPORTED_TEMPLATE_FILE = "browser_not_supported.html"

	ITEM_LIST_TEMPLATE_FILES = []string{"items.html", "head.html", "navigation_tabs.html", "actions.html", "modal.html", "scripts.html"}
	ITEM_EDIT_TEMPLATE_FILES = []string{"define_item.html", "head.html", "scripts.html"}

	ITEM_LIST_TEMPLATES *template.Template
	ITEM_EDIT_TEMPLATES *template.Template

	TEMPLATES_INITIALIZED = false
)

Functions

func ConfirmServerAccount

func ConfirmServerAccount(r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{}) string

ConfirmServerAccount responds to the ajax request from the client to lookup and return the status of the given account

func DeleteItems

func DeleteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})

DeleteItems accepts a form post of one or more Item.Id values, and attempts to remove them from the client db. Unless it hits a critical error, it returns home, to the list of scanned items

func EditAccount

func EditAccount(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})

EditAccount presents the form for editing Account information (in response to a GET request) and handles to add/updates (in response to a POST request)

func EmailItems

func EmailItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})

EmailItems handles the client form post, to send a list of the selected items via email to the given user

func FavoriteItems

func FavoriteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})

FavoriteItems accepts a form post of one or more Item.Id values, and attempts to change their status in the client db to 'favorite'

func FavoritedItems

func FavoritedItems(w http.ResponseWriter, r *http.Request, db database.ConnCoordinates, opts ...interface{})

FavoritedItems returns all the products scanned and favorited by this Account

func InitializeTemplates

func InitializeTemplates(folder string)

InitializeTemplates confirms the given folder string leads to the html template files, otherwise templates.Must() will complain

func InputUnknownItem

func InputUnknownItem(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})

InputUnknownItem handles the form for user contributions of unknown barcode scans: a GET presents the form, and a POST responds to the user-contributed input

func MakeHTMLHandler

func MakeHTMLHandler(fn func(http.ResponseWriter, *http.Request, database.ConnCoordinates, ...interface{}), db database.ConnCoordinates, opts ...interface{}) http.HandlerFunc

Respond to requests using HTML templates and the standard Content-Type (i.e., "text/html")

func MakeHandler

func MakeHandler(fn func(*http.Request, database.ConnCoordinates, ...interface{}) string, db database.ConnCoordinates, mediaType string, opts ...interface{}) http.HandlerFunc

Respond to requests that are not "text/html" Content-Types (e.g., for ajax calls)

func Redirect

func Redirect(target string) http.HandlerFunc

Use this to redirect one request to another target (string)

func RemoveSingleItem

func RemoveSingleItem(r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{}) string

RemoveSingleItem looks up the single item represented by the itemId form post variable, and attempts to delete it, if it exists. The reply is a jsonified string, passed back to MakeHandler() to be coupled with the right mime type

func ScannedItems

func ScannedItems(w http.ResponseWriter, r *http.Request, db database.ConnCoordinates, opts ...interface{})

ScannedItems returns all the products scanned, favorited or not, barcode lookup successful or not

func ShutdownClientHandler

func ShutdownClientHandler() http.HandlerFunc

Issue the shutdown and write back the system command output

func UnfavoriteItems

func UnfavoriteItems(w http.ResponseWriter, r *http.Request, dbCoords database.ConnCoordinates, opts ...interface{})

UnfavoriteItems accepts a form post of one or more Item.Id values, and attempts to change their status in the client db to not 'favorite'

func UnsupportedBrowserHandler

func UnsupportedBrowserHandler(templatesFolder string) http.HandlerFunc

Show the static template for unsupported browsers

Types

type AccountForm

type AccountForm struct {
	Title        string
	ActiveTab    *ActiveTab
	Account      *database.Account
	CancelUrl    string
	FormError    string
	Unregistered bool
}

type Action

type Action struct {
	Icon   string
	Link   string
	Action string
}

type ActiveTab

type ActiveTab struct {
	Scanned   bool
	Favorites bool
	Account   bool
	ShowTabs  bool
}

HTML template structs

type AjaxAck

type AjaxAck struct {
	Message string `json:"msg"`
	Error   string `json:"err,omitempty"`
}

JSON response struct

type ItemForm

type ItemForm struct {
	Title        string
	Item         *database.Item
	CancelUrl    string
	FormError    string
	FormMessage  string
	Unregistered bool
}

type ItemsPage

type ItemsPage struct {
	Title       string
	ActiveTab   *ActiveTab
	Actions     []*Action
	Items       []*database.Item
	Account     *database.Account
	Scanned     bool
	PageMessage string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL