Vfs Mime
<et2-vfs-mime> | Et2VfsMime
When to use it
<et2-vfs-mime> shows the icon for a file in EGroupware’s virtual filesystem - the little
page-, folder- or filetype-symbol at the start of a row in the filemanager, in a link list, or beside an
attachment.
It is more than a picture. The icon is chosen from the file’s mime type, image and PDF files get a real thumbnail of their content rather than a generic symbol, a symlink gets a small link overlay, and clicking it opens the file: in the expose gallery if it is something that can be shown there, in the configured editor if it is an editable document.
Use <et2-image> if all you want is a fixed icon, and
<et2-vfs-name> if you want the file’s name as well.
The examples on this page are deliberately not live. The icons and thumbnails come from
api/thumbnail.php, which reads the file out of the VFS - this documentation site has no
server to ask, so a preview here would render an empty box. Everything below describes the behaviour
against a running EGroupware.
Examples
In a filemanager-style row
The value is the row itself. Nothing has to be spelled out: the widget picks mime,
path, mode and download_url out of it.
<et2-vfs-mime id="${row}[mime]"/>
The value
Set as a whole object, the keys the widget reads are:
| key | what it does |
|---|---|
mime |
chooses the icon, and decides whether the file can be exposed or edited |
path |
the VFS path - used for the thumbnail, and shown as PDF File style label |
mode |
the unix mode; the symlink bit adds the link overlay |
download_url |
where the full file is fetched from when it is opened |
mtime |
passed to the thumbnail so a changed file is not served from cache |
src |
an explicit icon, overriding the mime lookup |
this.et2.getWidgetById("icon").value = {
mime: "application/pdf",
path: "/home/demo/report.pdf",
download_url: "/webdav.php/home/demo/report.pdf",
mode: 0o100644
};
Just a mime type
A bare string containing a / is treated as a mime type. You get the right icon, but no
thumbnail and nothing to open, because there is no file behind it.
this.et2.getWidgetById("icon").value = "application/pdf";
Directories
A directory - mime type httpd/unix-directory - gets the folder icon and is deliberately
not exposable. Opening a folder is a navigation, which the action system handles, not something the
gallery should try to display.
ODF thumbnails
For OpenDocument text, presentation, spreadsheet and chart files the widget binds a tooltip showing a large version of the thumbnail, so hovering a row previews the document without opening it.
Properties
| Name | Description | Reflects | Type | Default |
|---|---|---|---|---|
mime
|
Mime type we’re displaying |
|
string
|
""
|
symlink
|
Mark the file as a link |
|
boolean
|
false
|
value
|
Allow to pass all data as object with attributes “mime”, “path”, “download_url” and “mode” | - | - |
Learn more about attributes and properties.
Inherited properties (31)
Image
| Name | Description |
|---|---|
accesskey |
Accesskey provides a hint for generating a keyboard shortcut for the current element. The attribute value must consist of a single printable character. |
actions |
Set Actions on the widget Each action is defined as an object: move: { type: “drop”, acceptedTypes: “mail”, icon: “move”, caption: “Move to” onExecute: javascript:mail_move” } This will turn the widget into a drop target for “mail” drag types. When “mail” drag types are dropped, the global function mail_move(egwAction action, egwActionObject sender) will be called. The ID of the dragged “mail” will be in sender.id, some information about the sender will be in sender.context. The etemplate2 widget involved can typically be found in action.parent.data.widget, so your handler can operate in the widget context easily. The location varies depending on your action though. It might be action.parent.parent.data.widget To customise how the actions are handled for a particular widget, override _link_actions(). It handles the more widget-specific parts. |
align |
Used by Et2Box to determine alignment. Allowed values are left, right |
class |
CSS Class. This class is applied to the outside, on the web component itself. Due to how WebComponents work, this might not change anything inside the component. |
data |
Set the dataset from a CSV |
defaultSrc |
Default image Image to use if src is not found |
deferredProperties |
Any attribute that refers to row content cannot be resolved immediately, but some like booleans cannot stay a string because it’s a boolean attribute. We store them for later, and parse when they’re fully in their row. If you are creating a widget that can go in a nextmatch row, and it has boolean attributes that can change for each row, add those attributes into deferredProperties |
disabled |
Defines whether this widget is visibly disabled. The widget is still visible, but clearly cannot be interacted with. Widgets disabled in the template will not return a value to the application code, even if re-enabled via javascript before submitting. To allow a disabled widget to be re-enabled and return a value, disable via javascript in the app’s et2_ready() instead of an attribute in the template file. |
dom_id |
Get the actual DOM ID, which has been prefixed to make sure it’s unique. |
extraLinkPopup |
Popup widthxheight, if popup should be used, eg. 640x480 |
extraLinkTarget |
Link target Link target descriptor |
full |
Take every column of a layout, the same as span="all". Boolean rather than a bare
marker so it can be driven from content the way the rest of the template can -
full="@is_wide" resolves through the array manager like any other boolean attribute.
That does mean it needs a value: write full="true", since an empty
full="" resolves to false and removes the attribute again. Reflects for the same
reason grow does.
|
grow |
How much of a layout’s leftover space this widget should take. Only means anything inside a
container that has a layout (see Et2LayoutController): a bare grow or
grow="1" takes an equal share of whatever the non-growing children left over,
grow="2" takes twice what a grow="1" sibling does. It has to reflect.
The layout stylesheet matches the [grow] attribute - CSS cannot see a property - and
transformAttributes() only calls setAttribute() for an attribute the element already carries or a
property declared as reflecting. Widgets built from a .xet are created with
document.createElement() and handed their attributes as an object, so they carry none at that
point: without this declaration grow="1" lands as an inert JS property and nothing in
the layout ever matches it.
|
height |
Height of image: - either number of px (e.g. 32) or - string incl. CSS unit (e.g. “32px”) or - even CSS functions like e.g. “calc(1rem + 2px)” |
hidden |
The widget is not visible. As far as the user is concerned, the widget does not exist. Widgets hidden with an attribute in the template may not be created in the DOM, and will not return a value. Widgets can be hidden after creation, and they may return a value if hidden this way. |
href |
Link Target Link URL, empty if you don’t wan’t to display a link. |
id |
Get the ID of the widget |
inline |
Inline the svg image if possible only works if there is a valid svg behind the source and it is inside our server root |
label |
The label of the widget This is usually displayed in some way. It’s also important for accessability. This is defined in the parent somewhere, and re-defining it causes labels to disappear |
noLang |
Disable any translations for the widget |
parentId |
Parent is different than what is specified in the template / hierarchy. Widget ID of another node to insert this node into instead of the normal location |
span |
How many of a layout’s columns this widget should take.
span="all" is every column wherever the widget landed, span="end" /
span="*" is from its own column to the end of its line. Only means anything inside a
container that has a layout, and only for the column layouts -
stack gives every child the full width anyway. The same name is also read straight
off the XML node by the legacy <grid> widget, for the unrelated job of counting
table cells to merge; that path never looks at the widget, so declaring it here does not disturb
it. Reflecting it does mean a legacy grid’s span="all" cells now carry the attribute
too, which matches nothing outside a layout. Reflects for the same reason grow does.
|
src |
Image Displayed image |
statustext |
Tooltip which is shown for this element on hover |
styles |
WebComponent * |
width |
Width of image: - either number of px (e.g. 32) or - string incl. CSS unit (e.g. “32px”) or - even CSS functions like e.g. “calc(1rem + 2px)” |
options |
Get property-values as object |
supportedWidgetClasses |
et2_widget compatability |
ExposeMixin
| Name | Description |
|---|---|
exposeValue |
Used to determine if this widget is exposable. Images always are, even if we don’t actually know the mime type. |
mediaContentFunction |
Function to extract an image list “Normally” we’ll try to pull a list of images from the nextmatch or show just the current widget, but if you know better you can provide a method to get the list. |
LitElement
| Name | Description |
|---|---|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Inherited methods (24)
Image
| Name | Description |
|---|---|
checkCreateNamespace() |
Checks whether a namespace exists for this element in the content array. If yes, an own perspective of the content array is created. If not, the parent content manager is used. Constructor attributes are passed in case a child needs to make decisions |
clone() |
Creates a copy of this widget. |
createElementFromNode() |
Create a et2_widget from an XML node. First the type and attributes are read from the node. Then the readonly & modifications arrays are checked for changes specific to the loaded data. Then the appropriate constructor is called. After the constructor returns, the widget has a chance to further initialize itself from the XML node when the widget’s loadFromXML() method is called with the node. |
getArrayMgr() |
Returns the array manager object for the given part |
getArrayMgrs() |
Returns an associative array containing the top-most array managers. |
getChildren() |
Get child widgets Use |
getDetachedAttributes() |
Code for implementing et2_IDetachedDOM Individual widgets are detected and handled by the grid, but the interface is needed for this to happen |
getInstanceManager() |
Returns the instance manager |
getPath() |
Returns the path into the data array. By default, array manager takes care of this, but some extensions need to override this |
getRoot() |
Returns the base widget Usually this is the same as getInstanceManager().widgetContainer |
loadFromXML() |
Loads the widget tree from an XML node |
loadingFinished() |
Needed for legacy compatability. |
parseXMLAttrs() |
The parseXMLAttrs function takes an XML DOM attributes object and adds the given attributes to the _target associative array. This function also parses the legacyOptions. N.B. This is only used for legacy widgets. WebComponents use transformAttributes() and do their own handling of attributes. |
set_label() |
NOT the setter, since we cannot add to the DOM before connectedCallback() TODO: This is not best practice. Should just set property, DOM modification should be done in render https://lit-element.polymer-project.org/guide/templates#design-a-performant-template |
setArrayMgr() |
Sets the array manager for the given part |
setArrayMgrs() |
Sets all array manager objects - this function can be used to set the root array managers of the container object. |
setInstanceManager() |
Set the instance manager Normally this is not needed as it’s set on the top-level container, and we just return that reference |
_handleClick() |
Override et2-image click-handler, to not call egw.open_link with href= |
destroy() |
et2_widget compatability |
set_class() |
Set the widget class |
set_disabled() |
Wrapper on this.disabled because legacy had it. |
set_statustext() |
supports legacy set_statustext |
ExposeMixin
| Name | Description |
|---|---|
getMedia() |
Function to get media content to feed the expose |
isExposable() |
Overridden here because while some files cannot actually be put in the gallery, we still want to handle them in some way. Some files we’ll open directly on click |