forms

package
v0.0.0-...-5f8c1fa Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllRolesList = []*ListOption{
	{constants.RoleInstAdmin, "Institutional Admin", false},
	{constants.RoleInstUser, "Institutional User", false},
	{constants.RoleSysAdmin, "APTrust System Administrator", false},
}

AllRolesList is a list of assignable user roles. Hard-coded instead of using Options() function for formatting reasons and because we don't want to include the "none" role.

View Source
var BagItProfileIdentifiers = []*ListOption{
	{constants.DefaultProfileIdentifier, "APTrust", false},
	{constants.BTRProfileIdentifier, "BTR", false},
}
View Source
var DepositChartMetrics = []*ListOption{
	{"object_count", "Object Count", false},
	{"file_count", "File Count", false},
	{"total_bytes", "Total Bytes", false},
	{"total_gb", "Total Gigabytes", false},
	{"total_tb", "Total Terabytes", false},
}

DepositChartMetrics come from names of pgmodels.DepositStats properties

View Source
var InstRolesList = []*ListOption{
	{constants.RoleInstAdmin, "Institutional Admin", false},
	{constants.RoleInstUser, "Institutional User", false},
}

InstRolesList is a list of user roles for institutions.

View Source
var InstTypeList = []*ListOption{
	{constants.InstTypeMember, "Member", false},
	{constants.InstTypeSubscriber, "Associate", false},
}
View Source
var Months = []string{
	"",
	"January",
	"February",
	"March",
	"April",
	"May",
	"June",
	"July",
	"August",
	"September",
	"October",
	"November",
	"December",
}
View Source
var ObjectStateList = []*ListOption{
	{constants.StateActive, "Active", false},
	{constants.StateDeleted, "Deleted", false},
}
View Source
var StorageOptionList = []*ListOption{
	{constants.StorageOptionGlacierDeepOH, "Glacier Deep - Ohio", false},
	{constants.StorageOptionGlacierDeepOR, "Glacier Deep - Oregon", false},
	{constants.StorageOptionGlacierDeepVA, "Glacier Deep - Virginia", false},
	{constants.StorageOptionGlacierOH, "Glacier - Ohio", false},
	{constants.StorageOptionGlacierOR, "Glacier - Oregon", false},
	{constants.StorageOptionGlacierVA, "Glacier - Virginia", false},
	{constants.StorageOptionStandard, "Standard", false},
	{constants.StorageOptionWasabiOR, "Wasabi - Oregon", false},
	{constants.StorageOptionWasabiVA, "Wasabi - Virginia", false},
}
View Source
var TwoFactorMethodList = []*ListOption{
	{constants.TwoFactorNone, "None (Turn Off Two-Factor Authentication)", false},
	{constants.TwoFactorAuthy, "Authy OneTouch", false},
	{constants.TwoFactorSMS, "Text Message", false},
}
View Source
var YesNoList = []*ListOption{
	{"true", "Yes", false},
	{"false", "No", false},
}

Functions

This section is empty.

Types

type AlertFilterForm

type AlertFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

AlertFilterForm is the form that displays filtering options for the alert list page.

func (*AlertFilterForm) SetValues

func (f *AlertFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type BillingReportFilterForm

type BillingReportFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

BillingReportFilterForm is the form that displays filtering options for the billing report page.

func (*BillingReportFilterForm) SetValues

func (f *BillingReportFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type DeletionRequestFilterForm

type DeletionRequestFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

DeletionRequestFilterForm is the form that displays filtering options for the deletion request list page.

func (*DeletionRequestFilterForm) SetValues

func (f *DeletionRequestFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type DepositReportFilterForm

type DepositReportFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

DepositReportFilterForm is the form that displays filtering options for the deposit report page.

func (*DepositReportFilterForm) SetValues

func (f *DepositReportFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type Field

type Field struct {
	Name         string
	Label        string
	Placeholder  string
	Value        interface{}
	ErrMsg       string
	DisplayError bool
	Options      []*ListOption
	Attrs        map[string]string
}

type FileFilterForm

type FileFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

FileFilterForm is the form that displays filtering options for the generic file list page.

func (*FileFilterForm) SetValues

func (f *FileFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type FilterForm

type FilterForm interface {
	SetValues()
	GetFields() map[string]*Field
}

func NewAlertFilterForm

func NewAlertFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewBillingReportFilterForm

func NewBillingReportFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewDeletionRequestFilterForm

func NewDeletionRequestFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewDepositReportFilterForm

func NewDepositReportFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewFileFilterForm

func NewFileFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewInstitutionFilterForm

func NewInstitutionFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewObjectFilterForm

func NewObjectFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewPremisEventFilterForm

func NewPremisEventFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewUserFilterForm

func NewUserFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

func NewWorkItemFilterForm

func NewWorkItemFilterForm(fc *pgmodels.FilterCollection, actingUser *pgmodels.User) (FilterForm, error)

type FilterFormConstructor

type FilterFormConstructor func(*pgmodels.FilterCollection, *pgmodels.User) (FilterForm, error)

FilterFormConstructor describes the function signature for the constructors of all our filter forms. Filter forms appear on index pages, allowing users to filter lists by name, date, etc.

type Form

type Form struct {
	BaseURL  string
	Error    error
	Fields   map[string]*Field
	Model    pgmodels.Model
	Status   int
	Template string
}

func NewForm

func NewForm(model pgmodels.Model, template, baseURL string) Form

func (*Form) Action

func (f *Form) Action() string

Action returns the html form.action attribute for this form.

func (*Form) GetFields

func (f *Form) GetFields() map[string]*Field

GetFields returns a slice of all of the form's fields. This is used primarily in testing.

func (*Form) HandleError

func (f *Form) HandleError(err error)

Handle error sets the error property and http status code on error.

func (*Form) PostSaveURL

func (f *Form) PostSaveURL() string

PostSaveURL is the url to redirect to after successful save.

func (*Form) Save

func (f *Form) Save() bool

Save saves the underlying object and sets the error value and http status code as necessary.

func (*Form) SetValues

func (f *Form) SetValues()

type InstitutionFilterForm

type InstitutionFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

InstitutionFilterForm is the form that displays filtering options for the institution list page.

func (*InstitutionFilterForm) SetValues

func (f *InstitutionFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type InstitutionForm

type InstitutionForm struct {
	Form
	// contains filtered or unexported fields
}

func NewInstitutionForm

func NewInstitutionForm(institution *pgmodels.Institution) (*InstitutionForm, error)

func (*InstitutionForm) SetValues

func (f *InstitutionForm) SetValues()

setValues sets the form values to match the Institution values.

type InstitutionPreferencesForm

type InstitutionPreferencesForm struct {
	Form
}

InstitutionPreferencesForm allows institutional admins to edit a subset of their institution's info. This includes whether to require two-factor authentication and how often to run spot tests.

func NewInstitutionPreferencesForm

func NewInstitutionPreferencesForm(institution *pgmodels.Institution) (*InstitutionPreferencesForm, error)

func (*InstitutionPreferencesForm) Action

func (f *InstitutionPreferencesForm) Action() string

Action returns the html form.action attribute for this form.

func (*InstitutionPreferencesForm) SetValues

func (f *InstitutionPreferencesForm) SetValues()

setValues sets the form values to match the Institution values.

type ListOption

type ListOption struct {
	Value    string
	Text     string
	Selected bool
}

func ListDepositReportDates

func ListDepositReportDates(includeToday bool) []*ListOption

ListDepositReportDates returns a list of dates for deposit reports. Note that for each option except "Today", the label is a month and year and the value is the first day of the following month. For example, if the label is August 2022, the value is 2022-09-01. This would give you a report for deposits through the end of August, 2022. In the database, the query amounts to "all files created BEFORE 2022-09-01".

Note that past deposit stats are stored in the historical_deposit_stats table, and we store month-end reports only. Thus, ALL of the dates in that table will be first-of-month dates. Stats go back to December 2014, which was APTrust's initial launch (though the system was empty then),

If user chooses the "Today" option, the data will come from the current_deposit_stats view, which is updated hourly.

func ListInstitutions

func ListInstitutions(membersOnly bool) ([]*ListOption, error)

func ListUsers

func ListUsers(institutionID int64) ([]*ListOption, error)

func Options

func Options(items []string) []*ListOption

Options returns a list of options for the given string list. This is intended mainly to provide select list filters for the web ui for constants such as:

AccessSettings DigestAlgs EventTypes Stages Statuses StorageOptions WorkItemActions

type ObjectFilterForm

type ObjectFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

ObjectFilterForm is the form that displays filtering options for the generic file list page.

func (*ObjectFilterForm) SetValues

func (f *ObjectFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type PasswordResetForm

type PasswordResetForm struct {
	Form
}

func NewPasswordResetForm

func NewPasswordResetForm(userToEdit *pgmodels.User) *PasswordResetForm

func (*PasswordResetForm) SetValues

func (f *PasswordResetForm) SetValues()

setValues sets the form values to match the User values.

type PremisEventFilterForm

type PremisEventFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

PremisEventFilterForm is the form that displays filtering options for the PREMIS event list page.

func (*PremisEventFilterForm) SetValues

func (f *PremisEventFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type TwoFactorSetupForm

type TwoFactorSetupForm struct {
	Form
}

func NewTwoFactorSetupForm

func NewTwoFactorSetupForm(user *pgmodels.User) *TwoFactorSetupForm

func (*TwoFactorSetupForm) SetValues

func (f *TwoFactorSetupForm) SetValues()

setValues sets the form values

type UserFilterForm

type UserFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

UserFilterForm is the form that displays filtering options for the user list page.

func (*UserFilterForm) SetValues

func (f *UserFilterForm) SetValues()

setValues sets the form values to match the User values.

type UserForm

type UserForm struct {
	Form
	// contains filtered or unexported fields
}

func NewUserForm

func NewUserForm(userToEdit *pgmodels.User, actingUser *pgmodels.User) (*UserForm, error)

func (*UserForm) SetValues

func (f *UserForm) SetValues()

setValues sets the form values to match the User values.

type WorkItemFilterForm

type WorkItemFilterForm struct {
	Form
	FilterCollection *pgmodels.FilterCollection
	// contains filtered or unexported fields
}

WorkItemFilterForm is the form that displays filtering options for the work item list page.

func (*WorkItemFilterForm) SetValues

func (f *WorkItemFilterForm) SetValues()

setValues sets the form values to match the Institution values.

type WorkItemForm

type WorkItemForm struct {
	Form
}

func NewWorkItemForm

func NewWorkItemForm(workItem *pgmodels.WorkItem) *WorkItemForm

func (*WorkItemForm) SetValues

func (f *WorkItemForm) SetValues()

type WorkItemRequeueForm

type WorkItemRequeueForm struct {
	Form
	// contains filtered or unexported fields
}

func NewWorkItemRequeueForm

func NewWorkItemRequeueForm(workItem *pgmodels.WorkItem) (*WorkItemRequeueForm, error)

func (*WorkItemRequeueForm) Action

func (f *WorkItemRequeueForm) Action() string

Action returns the html form.action attribute for this form.

func (*WorkItemRequeueForm) SetValues

func (f *WorkItemRequeueForm) SetValues()

setValues sets the form values to match the WorkItem values.

Jump to

Keyboard shortcuts

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