Noutați

Create a Currency Converter Application Quickly with Sencha Ext JS and Exchange Rates API

With the world turning into a global village for free trade, it has become vital for individuals to have avenues for converting currencies. Currencies like the United States Dollar, the Euro, and the British Pound are widely used around the world for international transactions. So, individuals and businesses keep a close eye on the exchange rates. As a developer, you can help people access exchange rates by creating a currency converter application with Sencha Ext JS and Exchange Rates API. In this post, you will find all the details. What is Exchange Rates API? Exchange Rates API is a JSON-based REST API that provides current and historical exchange rates. It supports 170 global currencies and over 14,000 exchange rate conversion pairs. It is one of the fastest and most scalable exchange rate APIs that you can find online. Why should you use Exchange Rates API? Delivers unmatched performance Offers quick data refresh rate (60 seconds) User-friendly interface Easy to integrate with web applications Offers dedicated support team for helping you implementing the API How to Create a Currency Converter Application Quickly with Sencha Ext JS and Exchange Rates API Sencha Ext JS is a powerful framework for building cross-platform web applications. By integrating Exchanges Rates API, you can develop a currency converter application easily. Take a look at the app: To build the currency converter web application shown above, you have to follow these steps: 1. First, you have to create the model for exchange rates. Go to the App folder. Then head to the model directory, create the new RateModel.js file and add these codes: Ext.define(‘HeaderLeftRight.model.RateModel’, {                 extend: ‘Ext.data.Model’,                               requires: [                     ‘Ext.data.field.String’,                     ‘Ext.data.field.Number’                 ],                               fields: [                     {                         type: ‘string’,                         name: ‘symbol’                     },                     {                         type: ‘float’,                         name: ‘rate’                     }                 ]             }); Here, you are adding two fields, called ‘symbol’ and ‘rate.’ Also, you are defining their types. 2. You have to create models for the currency symbols. Create a new file, called SymbolModel.js, inside the model folder. Then add these codes: Ext.define(‘HeaderLeftRight.model.SymbolModel’, {                 extend: ‘Ext.data.Model’,                               requires: [                     ‘Ext.data.field.String’                 ],                               fields: [                     {                         type: ‘string’,                         name: ‘symbol’                     },                     {                         type: ‘string’,                         name: ‘value’                     }                 ]             }); Here, you are defining two fields: symbol and value. 3. Next, you have to add the Views. Go to the view folder, create the MyPanelViewModel.js file and add these codes: Ext.define(‘HeaderLeftRight.view.MyPanelViewModel’, {                 extend: ‘Ext.app.ViewModel’,                 alias: ‘viewmodel.mypanel’                           }); 4. Create the MyPanelViewController.js file and insert these codes: Ext.define(‘HeaderLeftRight.view.MyPanelViewController’, {                 extend: ‘Ext.app.ViewController’,                 alias: ‘controller.mypanel’,                               setRatesComapareValue: function(baseSymbol, rate, exchangeSymbol) {                     this.resultLbl.setText(`1 ${baseSymbol} = ${rate} ${exchangeSymbol}`);                 },                               toggleSymbolGrid: function() {                     if(this.isSymbolGridShowed) {                          this.symbolGrid.hide();                          this.isSymbolGridShowed = false;                     } else {                          this.symbolGrid.show();                          this.isSymbolGridShowed = true;                     }                 },                           […]

Read More

Developer Stories: Ziad Allaghi Shares On System Of Student Registration

Since 1998, Ziad Allaghi has been developing programs with Delphi. Ziad’s (System of Student Registration) application is a showcase entry for the Delphi 26th Showcase Challenge and we talked to him about his knowledge creating programs with Delphi. You can find more information about the application over at System of Student Registration. When did you start using RAD Studio/Delphi and have long have you been using it? I started programming in the Delphi language in 1998 the third edition and then version 6, and I have become better in my programs and increase my productivity because Delphi provides an environment for generating ideas easily. What was it like building software before you had RAD Studio/Delphi? The Delphi editor provides an excellent programming environment because it depends on the Pascal language, which is a clear language with a clear code that allows you to develop more than one program at the same time with minimal code description instructions, which allows you to easily understand It with less time and effort … The latest version is very amazing at all levels Delphi 10 4. 2 How did RAD Studio/Delphi help you create your showcase application? Rapid development in this language with the availability of many resources that help in the implementation of applications on adequate operating systems and increases the demand of users and your customers for your programs Thank you Embarcadero What made RAD Studio/Delphi stand out from other options? It provides easy-to-use and effective components such as dealing with various databases and communications .. Pascal language with the Delphi editor 10.4.2 gives the programmer the complete departure in writing his programs with creativity What made you happiest about working with RAD Studio/Delphi? It gives you the possibility that you can produce a program entirely without resorting to assistant programs, such as designing branding screens, databases, and visual components What have you been able to achieve through using RAD Studio/Delphi to create your showcase application? Sharing experiences is very important and taking notes in developing a program while developing programming style and ease of implementation with the new version of Delphi 10.4.2. What are some future plans for your showcase application? Program development, especially with the new components only available in Delphi version 10.4 ControlList and compiler speed Thank you, Ziad! Click through the link below for the showcase entry of System of Student Registration. Showcase Thanks for the interview Ziad!

Read More

Quickly Convert Speech To Text With Powerful Google Artificial Intelligence APIs

What can the Google Audio Transcription API do for our applications? Google’s Audio Transcription API allows your program to use all the power of Google’s huge computing resources to accurately transcribe speech found in audio files into text. As Google’s documentation says: Transcribe your content in real time or from stored files Deliver a better user experience in products through voice commands Gain insights from customer interactions to improve your service How can we use the Audio Transcription API with Delphi? Google cloud services have been positioned as a must have computing service solution today. They allow us to easily use their perfectly-designed AI solutions to use in our applications. Not only that, prices are also reasonable and you can start with zero payment by just adding your credit card. But how about getting those amazing functions to our Delphi application? Some people would think that Delphi is not the ideal language to work with those popular cloud computing APIs. It’s not true. With the help of the huge community for Delphi, it’s simpler than you think. Google Speech to Text and Text to speech are two of those cloud computing functions that could vital for some business applications. With the help of few repositories by grijjy in GitHub, we can easily get those functionalities to our Delphi application. Actually the repository is dated from 2017 but surprisingly it works perfectly with the newer versions of Delphi without many changes to the code. How to setup Google cloud services to work with Delphi? To use Google cloud services in our Delphi project, we need credentials to allow our project to use our google cloud API account. To do that, please visit this link and create an account. https://cloud.google.com Then create a new project. Then go to API and services dashboard and create new credentials. Make sure it’s service account. Then go to the new service account and create new key in Keys tab. Please make sure the key type is P12. Now you need to convert this P12 key to PEM to use with our Delphi components. To do that, please run this command in a folder with OpenSSL binaries. Make sure to edit file names: openssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes em>openssl pkcs12 –in path.p12 –out newfile.key.pem –nocerts –nodes/em> Keep that generated pem file to use with our Speech to Text Delphi project. What are the prerequisites for creating a Delphi Audio Transcription project? Download the GrijjyFoundation repository. https://github.com/grijjy/GrijjyFoundation Download the “Nghttp2.pas” from this link and copy it to the GrijjyFoundation folder. https://github.com/grijjy/DelphiRemotePushSender/blob/master/Nghttp2.pas Download the “Google.API.pas” form this link and include it in your project folder. https://github.com/grijjy/DelphiGoogleAPI/blob/master/Google.API.pas How to setup new Delphi project to demonstrate Audio Transcription? Create a new Delphi project and add components like this. Alternatively, you can download the demo project form this link. Demo Project GrijjyFoundation has many units to support many Google Cloud services. But in this project we only need few of them. Please include only these units to your Delphi project. How to code the Delphi Audio Transcription project? Now let’s move to the coding part. We use an instance of “TgoGoogle” class to post data and get the response form the Speech to Text API. We need to set some parameters of “TgoGoogle”. TgoGoogle.OAuthScope – OAuth Scope of the […]

Read More

How to Call Google API Detect Label with Ext JS and Sencha Architect

No matter how you look at it, Detect Labels is one of the most awesome Google APIs out there. It is the gateway to a full array of information that can be added to any picture. With it, you can read tags for almost everything you see in a given image, from its location to the products and activities you see within. Is there an animal in the image? If the answer is yes, you can even tag the species. Needless to say, there is endless potential in the Detect Label API.  That’s why today we are going to create a project using Detect Labels to scan images in Sencha Architect. Starting with Sencha Architect Before you start, you are going to need to configure and open Sencha Architect on your machine. If it asks for them, install and update Sencha CMD and the Ext JS SDK as well. Creating a project Once everything is current, you can start by clicking on New Project on the Sencha Architect main screen: You will see a number of project options, for our purposes we will start with the Blank Project template. Select it  and click on Create: This creates a new blank project ready for you to start selecting and dragging things into. Creating and configuring the view The first thing you want to do is select and drag a Form Panel from the right-side tool box. Drag it into your project and give it a title in the configurations panel on the bottom right of the Sencha Architect window. Let’s name it Detect Labels: Next, you will want to add a toolbar with a button at the bottom of the form. Call the button Run. We can assign the button an action later. Now it gets interesting, let’s add some fields that we will use to dynamically change our request parameters. You can rename them as you go by double-clicking on the name field. Add fields for API URL, API Key, Max. Results, Image URL, and Response. Now, let’s transform the Max. Results field to a Number field and disable the decimal flag because there will be an integer value for it. Configuring the View Model Now that you have created your view, it is time to work on the View Model. Here we connect the fields with values from the model using bind. To do this go to the tree files on the left panel, and select MyFormViewModel. Next, in the configuration panel, find config data and click on its value. This will change it in the code. This will also open the Architect code editor. To define the data for the view model we will enter our URL and parameters to call the Detect Labels API using an Ext Ajax request. As an example, we will use the image used on the API blog post.  Don’t forget to change your Google API Key key as well! data: { apiUrl: ‘https://vision.googleapis.com/v1/images:annotate’, apiKey: ‘yourGoogleApiKey’, imageUri: ‘gs://cloud-samples-data/vision/label/setagaya.jpeg’, maxResults: 5, response: null }   Binding the fields Once you are done, it is time to connect the data to our fields. To do this, head back to your form view on the Editor tab, select each field, and find the value property on the configurations panel. Make sure the option View Model Binding is […]

Read More

Easily Automate The DigitalOcean API From Windows And Mobile

DigitalOcean offers a set of APIs that we can access to manage their products from our application.  You can create applications that act like DigitalOcean’s Droplets Control Panel. You can access DigitalOcean’s API documentation here https://developers.digitalocean.com/documentation/v2/. One reason to utilize the DigitalOcean API is to automate your cloud server management and deployment process. If you are building out separate machines for customers (using RAD Server for example) this would be a great way to automate that process. Or maybe you have a CI pipeline you’re setting up that involves automated deployment and testing of an installation process this would be a great way to automate the process through Delphi and the DigitalOcean API. How do I set up a Windows app with DigitalOcean’s API? This article is only an example of the initial steps in creating an automation application, so I only show how to set up the DigitalOcean’s Droplet. In order to create a droplet (virtual private server) the /v2/droplets endpoint exists. It can be called to create a new server for you to use. Here are the two request headers needed which include authorization. Content-Type: application/json Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582 Content–Type: application/json Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582 Here are the list of request parameters that can be set when creating a droplet. The parameters are sent via JSON in the request body. You will see these parameters used in the Object Pascal code below. Name Type name String region String size String image integer (if using an image ID), or String (if using a public image slug) ssh_keys Array backups Boolean ipv6 Boolean private_networking Boolean vpc_uuid string user_data String monitoring Boolean volumes Array tags Array And here is some example JSON of a request body: { “name”: “example.com”, “region”: “nyc3”, “size”: “s-1vcpu-1gb”, “image”: “ubuntu-16-04-x64”, “ssh_keys”: [ 107149 ], “backups”: false, “ipv6”: true, “user_data”: null, “private_networking”: null, “volumes”: null, “tags”: [ “web” ] } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 {   “name”: “example.com”,   “region”: “nyc3”,   “size”: “s-1vcpu-1gb”,   “image”: “ubuntu-16-04-x64”,   “ssh_keys”: [     107149   ],   “backups”: false,   “ipv6”: true,   “user_data”: null,   “private_networking”: null,   “volumes”: null,   “tags”: [     “web”   ] } What Does the Delphi API code look like to access DigitalOcean? We are going to use the TRESTClient TRESTRequest TRESTResponse pipeline that is built into the Delphi RTL to make it easy to handle the REST request. The library is available for all platforms that are supported by Object Pascal. The REST Library framework focuses on JSON as the representation format. REST.Client.TRESTClient is the component that actually executes a request to a service. TRESTClient manages the HTTP connection to the service, deals with HTTP headers and proxy servers, and receives the response data. Authenticators (described later) can be attached to the client for a convenient way of adding authentication to a request. The request (REST.Client.TRESTRequest) holds all parameters and settings that form the actual HTTP request to the service. When connected to a client-component, it can be executed (even at design time). One of the most important properties of the request is the ‘Resource’. This value forms the previously mentioned ‘second half’ of the full request-url and defines the actual action that is executed on the service. The request also defines the HTTP methods (‘get’, ‘post’, ‘put’, ‘delete’) that are used for its execution. The response […]

Read More

Developer Stories: Giuliano D’Oronzo Talks Through His Board Game Prime

Giuliano D’Oronzo has been programming with Delphi since 2017. His (Prime) application was one of the showcase entries of the Delphi 26th Showcase Challenge and we have also asked him further about his Delphi skills. Get more information about his board game at Prime. When did you start using RAD Studio/Delphi and have long have you been using it? I have been using Delphi since 2017, but have been programming in Pascal for over 30 years. I almost always used Embarcadero development tools (first Borland then Inprise). What was it like building software before you had RAD Studio/Delphi? Previously I developed only for the Windows platform, now thanks to Delphi I can create applications for all the major existing platforms. How did RAD Studio/Delphi help you create your showcase application? Delphi allowed me to speed up the porting process to the Android platform with minimal effort. What made RAD Studio/Delphi stand out from other options? For me the “Object Pascal” language is extremely easy to use as well as very powerful. As a result, the development speed is significantly faster than with other development tools. What made you happiest about working with RAD Studio/Delphi? Working with Delphi is a lot of fun, and it gives me a lot of satisfaction. What have you been able to achieve through using RAD Studio/Delphi to create your showcase application? I managed to get a good chess engine (adapted for my game), and a good GUI on both platforms (android and windows). What are some future plans for your showcase application? I am developing another video game soon. Thank you for your insights, Giuliano! You will find the showcase entry for his application below Showcase

Read More

How to Call Google Natural Language APIs from Sencha Ext JS Framework

Ext.define(‘GoogleNLPDemoApp.view.main.MainView’, {   xtype: ‘mainview’,   controller: ‘mainviewcontroller’,   extend: ‘Ext.Panel’,   layout: ‘vbox’,   items: [{             xtype: ‘fieldset’,             items: [                 {                    xtype: ‘textfield’,                                      label: ‘Text Content’,                                      placeholder: ‘Enter text for analysis’,                                      name: ‘textContent’,                                      // validate not empty                                      required: true,                                      reference: ‘ct’                 },                 {                     xtype: ‘button’,                                           text: ‘analyze’,                                           handler: ‘onAnalyzeClick’                 }             ]         },  {       xtype: ‘reportgrid’,       title: ‘Sentiment Analysis Report’,       bind: {                 store: ‘{nlpStore}’             }   }],   viewModel: {       stores: {           nlpStore: {               type: ‘store’,               storeId: ‘dStore’,               autoLoad: true,               fields:[{                   name: ‘content’,                   mapping: ‘text.content’               },               {                   name: ‘magnitude’,                   mapping: ‘sentiment.magnitude’               },               {                   name: ‘score’,                   mapping: ‘sentiment.score’               }               ],               proxy: {                   type: ‘memory’,                   data: null,                   reader: {                       rootProperty: ‘sentences’                   }               }           }       }   },   defaults: {       flex: 1,       margin: 16   } });

Read More

How To Build Powerful Data Visualizations Using JavaScript with D3 in Sencha Ext JS

The D3 package in Sencha Ext JS is a very popular and efficient way to visualize data. There are 2 main components to the tool — the first is D3, the powerful JavaScript library that helps you easily visualize data on the web using HTML tables or SVG. Next is Ext JS, the Sencha JavaScript framework for building interactive cross-platform applications. By using D3 with Ext JS, you can build powerful data visualizations that help organizations and individuals uncover valuable insights by seeing their data more effectively. If effective, intuitive, and easy-to-implement data visualization is what you are after, read on to learn more about how you can put Ext JS and D3 to work for you.  What is D3? First off, you ask, what is D3?  D3 stands for Data-Driven Documents. It is an open-source JavaScript library for producing dynamic, readable, and interactive data visualizations in web browsers. It uses all the modern web standards, including SVG, HTML, and CSS.  What makes it effective is that you can use D3 to bind any arbitrary data to your Document Object Model (DOM) and apply data transformations from there.  D3 is incredibly flexible. For example, you can use D3 to generate an HTML table from any array of numbers. You can also use D3 to create an interactive SVG bar chart using the same data. In short, D3 lets you present your information in a visually appealing way.  More importantly, it gives you full control over the data selection process.  Three Reasons to use D3 for data visualization There are many reasons why Sencha’s D3 is the perfect tool to visualize your data. but for now, let’s stick to these 3: It’s easy to build any kind of visualization that you want.  The D3 library lets you present your complex numbers in a way that is easy for everyone to read. You can easily generate reports, it simplifies making comparisons and allows you to present your data that makes it easier to recognize patterns. It’s simple to reuse code and add specific functions. D3 is a JavaScript library with functional styles built in.  As a result, creating attractive, powerful data visualization is a breeze. It creates memorable visualizations. Data Visualizations created with D3 stand out. Whether you are working to convince investors or present findings, nothing works better than properly transformed data to uncover valuable insights. How to Build Powerful Data Visualizations with D3 and Ext JS The Sencha D3 package is completely integrated with Ext JS. The result is powerful, easily implemented data visualizations. The D3 package supports multiple component types, including Hierarchical Components, Heatmap Components, and Custom Components. Here we will look at the details of integrating the hierarchical “Sunburst” and “Zoomable Sunburst” components in Ext JS. Sunburst  The D3 sunburst component is a dynamic and compelling way to render your hierarchical data. Like a sunburst, it visualizes tree nodes as concentric wedge sectors, with the root circle in the center. It opens outward for every level of depth in the hierarchy.  To produce the visualization shown above, you have to create the Model by using the following code: Ext.define(‘KitchenSink.model.Tree’, {    extend: ‘Ext.data.TreeModel’,     fields: [        ‘name’,        ‘path’,        ‘size’,        {            […]

Read More

Developer Stories: Oripov Murod Converses Regarding His DovtaLab2020 Application

Oripov Murod has been programming with Delphi since 2006. His application (DovtaLab2020) was submitted as an entry for the Delphi 26th Showcase Challenge and we interviewed him to know more about his application and experiences with Delphi. You can download his application over at DovtaLab2020. When did you start using RAD Studio/Delphi and have long have you been using it? I started studying from 2003 (Delphi6)  as beginner. I use Delphi seriosly from 2012 (Delphi2010). What was it like building software before you had RAD Studio/Delphi? I used FoxPro, Basic,C, Access. How did RAD Studio/Delphi help you create your showcase application? Delphi is more simple and Delphi has a lot of tools for creating any application. What made RAD Studio/Delphi stand out from other options? It seems to me that I understand delphi better than others. What made you happiest about working with RAD Studio/Delphi? I love delphi very much What have you been able to achieve through using RAD Studio/Delphi to create your showcase application? I liked this system and now i have more abilities to create a lot of apps in future. What are some future plans for your showcase application? I want to teach children to delphi to learn more myself.   Thank you, Oripov! You can find the link of his showcase entry below. Showcase

Read More