controllers

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: LGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AssetsUtils contains the list of scss utilities that must be compiled first
	AssetsUtils = []string{
		"/static/web/lib/bootstrap/scss/_functions.scss",
		"/static/web/lib/bootstrap/scss/_mixins.scss",
		"/static/web/src/scss/bs_mixins_overrides.scss",
		"/static/web/src/scss/utils.scss",
	}
	// AssetsPrimaryVariables contains the list of scss files defining primary variables
	AssetsPrimaryVariables = []string{
		"/static/web/src/scss/primary_variables.scss",
	}
	// AssetsSecondaryVariables contains the list of scss files defining secondary variables
	AssetsSecondaryVariables = []string{
		"/static/web/src/scss/secondary_variables.scss",
	}
	// AssetsBootstrapVariables contains the list of scss files with bootstrap variables
	AssetsBootstrapVariables = []string{
		"/static/web/lib/bootstrap/scss/_variables.scss",
	}
	// AssetsBackendHelper contains the list of scss files that need to override Bootstrap variables in backend
	AssetsBackendHelper = []string{
		"/static/web/src/scss/bootstrap_overridden.scss",
	}
	// AssetsFrontendHelper contains the list of scss files that need to override Bootstrap variables in frontend
	AssetsFrontendHelper = []string{
		"/static/web/src/scss/bootstrap_overridden.scss",
	}
	// AssetsBootstrap contains the list of scss files that import boostrap
	AssetsBootstrap = []string{
		"/static/web/src/scss/import_bootstrap.scss",
		"/static/web/src/scss/bootstrap_review.scss",
	}
	// CommonScss is the list of Scss assets to import by the web client
	// that are common to the frontend and the backend. All Scss assets are
	// cat'ed together in the given order before being compiled.
	//
	// Assets utils will be inserted before this list
	CommonScss = []string{
		"/static/web/lib/tempusdominus/tempusdominus.scss",
		"/static/web/src/scss/fonts.scss",
		"/static/web/src/scss/ui.scss",
		"/static/web/src/scss/ui_extra.scss",
		"/static/web/src/scss/navbar.scss",
		"/static/web/src/scss/mimetypes.scss",
		"/static/web/src/scss/modal.scss",
		"/static/web/src/scss/animation.scss",
		"/static/web/src/scss/rainbow.scss",
		"/static/web/src/scss/datepicker.scss",
		"/static/web/src/scss/daterangepicker.scss",
		"/static/web/src/scss/banner.scss",
		"/static/web/src/scss/colorpicker.scss",
		"/static/web/src/scss/translation_dialog.scss",
		"/static/web/src/scss/keyboard.scss",
		"/static/web/src/scss/name_and_signature.scss",
		"/static/web/src/scss/web.zoomodoo.scss",
		"/static/web/src/scss/fontawesome_overridden.scss",
	}
	// BackendScss is the list of Scss assets to import by the web client
	// that are specific to the backend. All scss assets are
	// cat'ed together in the given order before being compiled.
	//
	// Assets utils will be inserted before this list
	BackendScss = []string{
		"/static/web/src/scss/webclient_extra.scss",
		"/static/web/src/scss/webclient_layout.scss",
		"/static/web/src/scss/webclient.scss",
		"/static/web/src/scss/domain_selector.scss",
		"/static/web/src/scss/model_field_selector.scss",
		"/static/web/src/scss/progress_bar.scss",
		"/static/web/src/scss/dropdown.scss",
		"/static/web/src/scss/dropdown_extra.scss",
		"/static/web/src/scss/tooltip.scss",
		"/static/web/src/scss/switch_company_menu.scss",
		"/static/web/src/scss/debug_manager.scss",
		"/static/web/src/scss/control_panel.scss",
		"/static/web/src/scss/fields.scss",
		"/static/web/src/scss/fields_extra.scss",
		"/static/web/src/scss/views.scss",
		"/static/web/src/scss/pivot_view.scss",
		"/static/web/src/scss/graph_view.scss",
		"/static/web/src/scss/form_view.scss",
		"/static/web/src/scss/form_view_extra.scss",
		"/static/web/src/scss/list_view.scss",
		"/static/web/src/scss/list_view_extra.scss",
		"/static/web/src/scss/kanban_dashboard.scss",
		"/static/web/src/scss/kanban_examples_dialog.scss",
		"/static/web/src/scss/kanban_column_progressbar.scss",
		"/static/web/src/scss/kanban_view.scss",
		"/static/web/src/scss/kanban_view_mobile.scss",
		"/static/web/src/scss/web_calendar.scss",
		"/static/web/src/scss/web_calendar_mobile.scss",
		"/static/web/src/scss/search_view.scss",
		"/static/web/src/scss/search_panel.scss",
		"/static/web/src/scss/search_view_mobile.scss",
		"/static/web/src/scss/dropdown_menu.scss",
		"/static/web/src/scss/search_view_extra.scss",
		"/static/web/src/scss/data_export.scss",
		"/static/web/src/scss/attachment_preview.scss",
		"/static/web/src/scss/notification.scss",
		"/static/web/src/scss/base_document_layout.scss",
		"/static/web/src/scss/ribbon.scss",
		"/static/web/src/scss/base_settings.scss",
		"/static/web/src/scss/report_backend.scss",
		"/static/web/src/scss/web_responsive.scss",
		"/static/web/src/scss/style.scss",
		"/static/web/src/scss/sidebar.scss",
	}
	// FrontendScss is the list of Less assets to import by the web client
	// that are specific to the frontend. All scss assets are
	// cat'ed together in the given order before being compiled.
	//
	// Assets utils will be inserted before this list
	FrontendScss = []string{
		"/static/web/src/scss/lazyloader.scss",
		"/static/web/src/scss/navbar_mobile.scss",
		"/static/web/src/scss/notification.scss",
	}
	// FrontendContext is the base context to update when rendering
	// a frontend HTML template.
	FrontendContext = hweb.Context{
		"commonCompiledCSS":   commonCSSRoute,
		"frontendCompiledCSS": frontendCSSRoute,
	}
)
View Source
var (

	// TypeSubstitutions maps interface types to appropriate concrete types to unmarshal into.
	//
	// All types that implement the interface type will use the given concrete type.
	TypeSubstitutions = map[reflect.Type]reflect.Type{
		reflect.TypeOf((*models.RecordData)(nil)).Elem(): reflect.TypeOf(models.FieldMap{}),
	}
	// TypePostProcess maps interface types to a function to apply after unmarshalling.
	TypePostProcess = map[reflect.Type]interface{}{
		reflect.TypeOf((*models.RecordData)(nil)).Elem(): func(rs models.RecordSet, arg models.FieldMap) interface{} {
			return makeModelData(rs, arg).Wrap()
		},
	}
)
View Source
var MethodAdapters = map[string]methodAdapter{
	"Create":     createAdapter,
	"Write":      writeAdapter,
	"Onchange":   onchangeAdapter,
	"Read":       readAdapter,
	"SearchRead": searchReadAdapter,
	"FieldsGet":  fieldsGetAdapter,
	"NameGet":    nameGetAdapter,
}

MethodAdapters is a map giving the adapter to call for each method

Functions

func ActionLoad

func ActionLoad(c *server.Context)

ActionLoad returns the action with the given id

func ActionRun

func ActionRun(c *server.Context)

ActionRun runs the given server action

func AssetsBackendCSS

func AssetsBackendCSS(c *server.Context)

AssetsBackendCSS returns the compiled CSS for the backend assets

func AssetsCommonCSS

func AssetsCommonCSS(c *server.Context)

AssetsCommonCSS returns the compiled CSS for the common assets It creates the temp file on the fly if it doesn't exist yet

func AssetsFrontendCSS

func AssetsFrontendCSS(c *server.Context)

AssetsFrontendCSS returns the compiled CSS for the frontend assets

func CSSList

func CSSList(c *server.Context)

CSSList returns the list of CSS files

func CallButton

func CallButton(c *server.Context)

CallButton executes the given method of the given model and returns the result only if it is an action

func CallKW

func CallKW(c *server.Context)

CallKW executes the given method of the given model

func ChangePassword

func ChangePassword(c *server.Context)

ChangePassword is called by the client to change the current user password

func CheckUser

func CheckUser(uid int64)

CheckUser panics if the given uid is 0 (i.e. no user is logged in).

func CompanyLogo(c *server.Context)

CompanyLogo serves the logo of the company

func Dashboard

func Dashboard(c *server.Context)

Dashboard returns the dashboard image of the company or the default one

func Execute

func Execute(uid int64, params CallParams) (res interface{}, rError error)

Execute executes a method on an object

func GetSessionInfo

func GetSessionInfo(c *server.Context)

GetSessionInfo returns the session information to the client

func Image

func Image(c *server.Context)

Image serves the image stored in the database (base64 encoded) in the given model and given field

func JSList

func JSList(c *server.Context)

JSList returns the list of JS files

func Load

func Load(c *server.Context)

Load executes a GET request and returns the values

func LoadLocale

func LoadLocale(c *server.Context)

LoadLocale returns the locale's JS file

func LoadMenus

func LoadMenus(c *server.Context)

LoadMenus returns the menus of the application as JSON

func LoginGet

func LoginGet(c *server.Context)

LoginGet is called when the client calls the login page

func LoginPost

func LoginPost(c *server.Context)

LoginPost is called when the client sends credentials from the login page

func LoginRequired

func LoginRequired(c *server.Context)

LoginRequired is a middleware that redirects to login page non logged in users.

func Logout

func Logout(c *server.Context)

Logout the current user and redirect to login page

func MenuImage(c *server.Context)

MenuImage serves the image for the given menu

func MenuLoadNeedaction(c *server.Context)

MenuLoadNeedaction serves the number of objects that need an action in the given menu IDs

func Modules

func Modules(c *server.Context)

Modules returns the list of installed modules to the client

func QWeb

func QWeb(c *server.Context)

QWeb returns a concatenation of all client qweb templates

func RegisterRoutes

func RegisterRoutes()

RegisterRoutes register all controllers for the web module. This function is called from the web PreInit function so that server.ResourceDir is set before calling this function, but controllers.Bootstrap is not, yet.

func SearchRead

func SearchRead(uid int64, params SearchReadParams) (res *webtypes.SearchReadResult, rError error)

SearchRead retrieves database records according to the filters defined in params.

func SearchReadController

func SearchReadController(c *server.Context)

SearchReadController returns Records from the database

func Translations

func Translations(c *server.Context)

Translations returns data about the current language

func VersionInfo

func VersionInfo(c *server.Context)

VersionInfo returns server version information to the client

func WebClient

func WebClient(c *server.Context)

WebClient is the controller for the application main page

Types

type CallParams

type CallParams struct {
	Model  string                     `json:"model"`
	Method string                     `json:"method"`
	Args   []json.RawMessage          `json:"args"`
	KWArgs map[string]json.RawMessage `json:"kwargs"`
}

CallParams is the arguments' struct for the Execute function. It defines a method to call on a model with the given args and keyword args.

type ChangePasswordData

type ChangePasswordData struct {
	Fields []struct {
		Name  string `json:"name"`
		Value string `json:"value"`
	} `json:"fields"`
}

ChangePasswordData is the params format passed to ChangePassword controller

type Menu struct {
	ID          int64                `json:"id"`
	XMLID       string               `json:"xmlid"`
	Name        string               `json:"name"`
	Children    []Menu               `json:"children"`
	Action      actions.ActionString `json:"action"`
	Parent      parentTuple          `json:"parent_id"`
	Sequence    uint8                `json:"sequence"`
	WebIconData string               `json:"web_icon_data"`
}

A Menu is the representation of a single menu item

type SearchReadParams

type SearchReadParams struct {
	Context types.Context  `json:"context"`
	Domain  domains.Domain `json:"domain"`
	Fields  []string       `json:"fields"`
	Limit   interface{}    `json:"limit"`
	Model   string         `json:"model"`
	Offset  int            `json:"offset"`
	Sort    string         `json:"sort"`
}

SearchReadParams is the args struct for the searchRead function.

type SessionInfo

type SessionInfo struct {
	SessionID                int64                  `json:"session_id"`
	UID                      int64                  `json:"uid"`
	UserContext              map[string]interface{} `json:"user_context"`
	DB                       string                 `json:"db"`
	UserName                 string                 `json:"username"`
	CompanyID                int64                  `json:"company_id"`
	Name                     string                 `json:"name"`
	IsSystem                 bool                   `json:"is_system"`
	IsAdmin                  bool                   `json:"is_admin"`
	PartnerDisplayName       string                 `json:"partner_display_name"`
	PartnerID                int64                  `json:"partner_id"`
	UserCompanies            UserCompanies          `json:"user_companies"`
	WebBaseURL               string                 `json:"web.base.url"`
	ShowEffect               bool                   `json:"show_effect"`
	DisplaySwitchCompanyMenu bool                   `json:"display_switch_company_menu"`
	CacheHashes              map[string]string      `json:"cache_hashes"`
}

SessionInfo gathers all information about the current session

func GetSessionInfoStruct

func GetSessionInfoStruct(sess sessions.Session) *SessionInfo

GetSessionInfoStruct returns a struct with information about the given session

type UserCompanies

type UserCompanies struct {
	CurrentCompany   webtypes.RecordIDWithName   `json:"current_company"`
	AllowedCompanies []webtypes.RecordIDWithName `json:"allowed_companies"`
}

UserCompanies for the se

Jump to

Keyboard shortcuts

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