How To Install Zimlets In Zimbra
Calculation attachments from a Zimlet
This article explains how to write a Zimlet that allows a user to attach files from a tertiary party service. This way users tin can adhere files from whatsoever service y'all wish to integrate directly from Zimbra. If you lot are new to Zimlets please accept a look at the previous article at https://github.com/Zimbra/zm-zimlet-guide.
Prerequisites
To follow the steps in this commodity you demand a Zimbra test server. You volition need to accept Zimbra 9 Network Edition. You can gear up this up in a Virtual Automobile in the cloud or yous tin install it on your local computer inside VirtualBox/KVM/Parallels etc. If you decide to set it up on your local computer you need at to the lowest degree an i5 with 16GB of RAM and a SSD. Your test server needs to be accessible over SSH. Instructions on how to gear up your Zimbra server: https://weblog.zimbra.com/2018/01/install-zimbra-collaboration-8-8-ubuntu-16-04-lts/ make sure to install the latest patches. You can find instructions on how to install patches at https://wiki.zimbra.com/wiki/Zimbra_Releases
Deploy the Zimlet Sideloader
You demand to deploy and enable the Zimlet Sideloader on your development server. You lot only have to practice this footstep once.
yum install zimbra-zimlet-sideloader apt install zimbra-zimlet-sideloader su - zimbra zmmailboxdctl restart
Verify that the Sideloader Zimlet is available and enabled for your Zimbra Class of Service (CoS) by logging into the Admin UI -> Domicile -> Configure -> Form of Service.
Verify that the Sideloader Zimlet is available and enabled for your Zimbra and account past logging into the Admin UI -> Home -> Manage -> Accounts.
Installing Zimlet CLI
You can develop Zimbra Zimlets on whatever OS supported past NodeJS (https://nodejs.org/en/download/). This commodity will include Linux commands you can run on CentOS/Fedora/Redhat and Ubuntu. If you run on a different OS reading these commands should help you understand what you must practise to get started.
Zimbra provides a tool called Zimlet CLI that is based on Webpack. It is used for building/packaging your Zimlet and for working with Zimlet templates. Install it on your local estimator:
Every bit root:
yum install nodejs apt install nodejs npm install -g @zimbra/zimlet-cli
Downloading and running the Attacher Zimlet
Create a folder on your local computer to shop the Attacher Zimlet:
mkdir ~/zimbra_course_pt4 cd ~/zimbra_course_pt4 git clone https://github.com/Zimbra/zimbra-zimlet-attacher cd zimbra-zimlet-attacher npm install zimlet watch
The output of this control should be:
Compiled successfully! You can view the application in browser. Local: https://localhost:8081/alphabetize.js On Your Network: https://192.168.one.100:8081/index.js
Visit https://localhost:8081/alphabetize.js in your browser and accept the cocky-signed certificate. The index.js is a packed version of the Attacher Zimlet
. More information about the zimlet command, npm and using SSL certificates can exist found in https://github.com/Zimbra/zm-zimlet-guide.
Sideload the Attacher Zimlet
Log on to your Zimbra evolution server and make sure that you are seeing the modern UI. Then append /sdk/zimlets
to the URL.
Sideload the Attacher Zimlet past clicking Load Zimlet. The Zimlet is at present added to the Zimbra UI in real-fourth dimension. No reload is necessary.
Click the paper clip icon. Then click Attach Zimlet Test to practice a demo attachment.
Zimbra.png is added as an example to the electronic mail.
Visual Studio Code
Open the binder ~/zimbra_course_pt4/zimbra-zimlet-attacher
in Visual Studio lawmaking to accept a expect at the code in the Attacher Zimlet. More than information on this tin can be institute at: https://github.com/Zimbra/zm-zimlet-guide.
How to implement the attacher
First step is to implement the Zimlet slot compose-zipper-action-carte du jour
. This is done in
- ~/zimbra_course_pt4/zimbra-zimlet-attacher/src/index.js
//Load components from Zimbra import { createElement } from "preact" ; //Load the createMore part from our Zimlet component import createAttacher from "./components/create-attacher" ; export default function Zimlet ( context ) { //Get the 'plugins' object from context and define it in the current scope const { plugins } = context ; const exports = { } ; exports . init = function init ( ) { const attacher = createAttacher ( context ) ; plugins . register ( 'slot::etch-attachment-action-bill of fare' , attacher ) ; } ; return exports ; }
The usual wrapper component is used to pass on the context to a class component:
- ~/zimbra_course_pt4/zimbra-zimlet-attacher/src/components/create-attacher/index.js
import { createElement } from 'preact' ; import Attacher from '../attacher' ; consign default part createAttacher ( context ) { return props => ( < Attacher {...props } > { {context} } < / Attacher > ) ; }
These steps are explained in more detail in https://github.com/Zimbra/zm-zimlet-guide. Now take a look at
- ~/zimbra_course_pt4/zimbra-zimlet-attacher/src/components/attacher/index.js
import { createElement , Component , render } from 'preact' ; import { ActionMenuItem } from '@zimbra-client/components' ; import fashion from './mode' ; export default class Attacher extends Component { constructor ( props ) { super ( props ) ; this . zimletContext = props . children . context ; this . props . onAttachmentOptionSelection ( this . chooseLinksFromService ) ; } ; //onAttachmentOptionSelection is passed from the Zimlet Slot and allows to add together an result handler onAttachFilesFromService = ( ) => this . props . onAttachmentOptionSelection ( this . chooseFilesFromService ) ; chooseFilesFromService = ( editor ) => { this . downloadAndAttachFile ( "/skins/_base/logos/AppBanner.png" , editor ) ; } downloadAndAttachFile = ( path , editor ) => { var request = new XMLHttpRequest ( ) ; request . open ( 'Go' , path ) ; request . responseType = "blob" ; request . onreadystatechange = function ( e ) { if ( asking . readyState == 4 ) { if ( request . status == 200 ) { // Blob and File are defined per window; We need compatibility with the parent Blob for attachments allow file = new window . parent . File ( [ request . response ] , "Zimbra.png" , { type: request . response . type } ) ; editor . addAttachments ( [ file ] , false ) ; } else { alert ( 'whoops some fault occurred' ) ; } } } . bind ( this ) ; request . ship ( ) ; } render ( ) { const childIcon = ( < span class = { mode . appIcon } > < / bridge > ) ; return ( < ActionMenuItem icon = { childIcon } onClick = { this . onAttachFilesFromService } >Attach Zimlet Test< / ActionMenuItem > ) ; } }
The Attacher
component returns an ActionMenuItem
that will call onAttachFilesFromService
in one case it is clicked. The ActionMenuItem is what the user sees in the carte in the UI.
It is important to understand that the compose-zipper-activity-menu
Zimlet slot passes on to our Zimlet the onAttachmentOptionSelection
prop. We utilize this prop to set an event handler for the attaching. This piece of code tells Zimbra to call our method chooseFilesFromService
once the carte du jour is clicked.
this . props . onAttachmentOptionSelection ( this . chooseFilesFromService ) ;
chooseFilesFromService
then receives the editor
component that is the Zimbra email composer. You can then apply that editor
to add attachments to the email. You lot tin can add as attachment using:
editor . addAttachments ( [ file ] , imitation ) ;
or adhere inline using:
editor . embedImages ( [ file ] , false ) ;
The commencement is an array filled with attachments in Javascript blob'south, if you lot only have i attachment to upload you have to enclose it in an array. The 2nd argument is a boolean. When true it will ask Zimbra to enforce the maximum file size of the attachment.
Source: https://github.com/Zimbra/zimbra-zimlet-attacher
Posted by: wilsonfroce1940.blogspot.com
0 Response to "How To Install Zimlets In Zimbra"
Post a Comment