Written by Sai Sarath Chandra, Alibaba Billow Tech Share author. Tech Share is Alibaba Cloud’s allurement affairs to animate the administration of abstruse ability and best practices aural the billow community.
In our previous article, we discussed in detail about:
We additionally briefly talked about how Electron handles a simple use case.
In this article, we will set up an Electron-based project, creating a user interface (UI) alongside Electron functionalities. We will additionally go into detail as we actualize the functionality which forms the architectonics blocks for any Electron application.
We will be appliance the Boomerang UI Kit, which is congenital on the Bootstrap Framework. Bootstrap provides nice and customizable components, which can be acclimated in almost any web development project. The acumen I accept the Boomerang UI Kit is added of a claimed choice. You can accept any added framework to assignment with this tutorial as we are added absorption alone on the ElectronJS functionalities rather than the front-end frameworks.
Let’s alpha with the basal adaptation of the Electron Template. This is the GitHub articulation of the arrangement angled from the Official Electron Repository. If you would like to experiment, again go advanced and carbon the cipher by visiting this link.
Below is the book anatomy you should see afterwards cloning the code.
Let’s allocution briefly about what anniversary book is amenable for.
.gitignoreMany accept taken this book for granted, but the absolute purpose of the book is to avoid the files while committing/pushing the cipher to the git repository. This will accomplish abiding accidental files are not pushed into the repository.
LICENSE.mdThis outlines the Licensing anatomy of the cipher you are absolution as an accessible source. Accomplish abiding you assay all the licenses and aces what apparel you best.
This is the advanced folio you see back the athenaeum is opened. The markdown is a appropriate architectonics of autograph the affidavit which is actual accessible with abundant formatting options to accomplish the agreeable readable.
Index.htmlThe book area we should accumulate our presentation logic. All the UI architectonics with HTML and CSS should go here. It ability appear we advance altered files or a distinct HTML folio for the accomplished appliance based on the UI architectonics you follow. There are additionally a brace of changes you charge to accomplish to accomplish abiding your tag works, which we will altercate shortly.
main.jsThis is the affection of the Electron application, this consists of the complete advice from the IPCMain action to the IPCRenderer process. We will see in detail how it works back we altercate the code. This book is amenable for all Inter-Process Communication.
Package.jsonThis book will be accustomed to you if you accept acquaintance with Node.js; it’s aloof a book with a account of dependencies for assembly and development. The agnate can additionally be begin in Java in the anatomy of pom.xml.
Renderer.jsThis is the renderer allotment of the Inter-Process Communication. Note that you can accept assorted renderer.js files but it’s not appropriate to accept assorted main.js files, as it actual difficult to advance and chase the alternation of events.
We are creating the Invoicing Appliance based on Electron. We alpha by creating the UI for the application
I chose the Boomerang UI Kit. This is created on top of the Bootstrap framework which provides an easy way to advance acknowledging and admirable User Interfaces. There are so abounding pre-defined cipher snippets which can advice you get started.
The accomplished cipher atom I appearance you today is taken from the repo below:
Clone the code, and you should acquisition “Electron_Invoice” and “Invoice_Backend.” Electron_Invoice consists of the accomplished front-end cipher we are discussing in this article.
We are bond theme.css, which contains all the appropriate CSS constructs for administration the elements of the basal Bootstrap framework. Bond CSS is straightforward.
If we cross to the end of the </body> tag you will acquisition several scripts. One of which is the following:
Here we are injecting renderer.js. In renderer.js, you can admission complete DOM and npm (Node Package Manager) modules.
This is the best important allotment of cipher you charge to accept as this hinders the dependencies to accommodate properly. Note that afore you alpha abacus any .js dependencies, we charge to add the calligraphy aloft the animadversion “starting calligraphy dependencies.” If not, modules like jQuery and added libraries will not be available.
In Electron, all the libraries should be accessible as modules. By anchor the imports amid the scripts of “Starting and Ending calligraphy dependencies,” all are alien auspiciously and fabricated available.
The imports we are appliance include:
jQuery, Popper, Bootstrap – for Boomerang UI interdependencies as the UI Kit is congenital on top of that.
Font Alarming – for absolutely scalable icons chip as font.
Page plugins – These are acclimated to create an added functionality to the absolute elements we are appliance as allotment of our HTML.
ChartJS – We are appliance ChartJS for assuming the analytic assay in a graphical form. This library is open-source and it provides a lot of archive which are accessible to customize.
Mustache.js – We acclimated Mustache to actualize HTML dynamically at runtime with ease. This library abundantly simplifies the assignment of breeding activating HTML and replacing the ethics appliance a list.
Before I altercate any added cipher snippets, let’s see how our end artefact will look.
These are the two screens we are designing now:
The aloft UI allotment is accomplished appliance the afterward code:
We chase the distinct folio UI architectonics wherein we will actualize the accomplished folio at already in a distinct HTML book and we appearance what is needed.
In the <ul> with the id myTab we’ll authority the complete account of tabs – both New Balance and Dashboard. But don’t avoid the classes activated to the HTML tags, they’re necessary; otherwise, the tabs ability not accept the aforementioned presentation format.
The added <div>s with tab-pane hold the agreeable accompanying to both New Balance and Dashboard.
This is one of the basic that we acclimated in the form, the figure will be created the tag and they are accessible with chantry alarming which we added earlier.
This accurate allotment of cipher creates the table attack and set of inputs forth with the button adjoin it.
The blooming button creates an access with the Item capacity provided, again you can see the afterward entry:
The agenda ascribe with the Item Capacity are created with the afterward code:
This arrangement is generated dynamically and added to the beneath table at runtime appliance the beneath function:
Upon clicking, addItemCard() will be invoked and the abstracts is pushed intoitemsObj (which will be acclimated after to advance abstracts to the server). It additionally creates the agenda arrangement appliance the Mustache library and appends it to the table.
ResetWe accept the “Reset” button which resets the complete abstracts in the anatomy to like a new Balance form.
SubmitThis is one added functionality area we will accomplish an API alarm which takes affliction of inserting the abstracts to the database.
This is the POST alarm to the above-mentioned URI, which is operating in the ECS Instance and takes affliction of inserting abstracts into the MongoDB instance. We will altercate added about the backend soon.
Dashboard The dashboard is fabricated of the beneath components
The aloft basic is created appliance the afterward code:
The aloft cipher creates the Agenda with the icons, header, and button forth with the contempo active time from MongoDB.
We accept additionally acclimated the Chart.js for the graphical representation of the sales with the corresponding dates. You can see that in the calligraphy area beneath the tag for reference. It should be actual obvious.
We will altercate the functionality we accept acclimated to back abstracts and assay it in the code:
We will be discussing the how we created the backend casework acclimated for this appliance and what operations we can accomplish with our application. If you haven’t apprehend about the allowances of Electron, again you should absolutely assay out the antecedent commodity from this tutorial series.
Html Code For Invoice Template Here’s What Industry Insiders Say About Html Code For Invoice Template – html code for invoice template
| Delightful to be able to my own blog, within this time period We’ll provide you with concerning keyword. And today, here is the primary picture: