This blog article will illustrate how the Image Sizes APIs concerning event and speaker images are integrated in Open Event Frontend, which allows for dynamic configurations of storing speaker and event images. The primary end points of Open Event API with which we are concerned with for fetching the event and speaker image sizes are
GET /v1/event-image-sizes
And
GET /v1/speaker-image-sizes
These endpoints are accessible only to a user with has administrator privileges as the customisation of image sizes is possible only on the admin dashboard. The image sizes are independent in regards to relationships and don’t have any related fields.
The model for the admin image settings route is defined as follows:
The form which allows user to select image sizes, is in a separate component, and initially both the speaker and event image sizes are passed onto the component as a part of the entire model, so they can be separated later as per the requirement.
Most of the fields specify the units in which the numerical input concerning the image dimensions will be interpreted by the server and standard min and max validations are applied to the fields to ensure genuine and legitimate values can pass through the frontend.
{{ui-checkbox label=(t ‘Standard aspect ratio is 13:5. Tick to maintain aspect ratio.’) class=’checkbox’ name=’large_ratio’ checked=image.eventImageSize.fullAspect onChange=(action (mut image.eventImageSize.fullAspect))}}
{{t ‘Standard Size of the available area is 1300px X 500px’}}
<p>{{t ‘Found in :’}}</p>
{{t ‘Background Header Image in Public Event Page’}}
</div>
Furthermore, to ensure a user does not accidentally change the values inside the form, an action is triggered while transitioning away from the route which rollbacks any unsaved changes to the image sizes.
This blog article will describe how the users view user route is created in Open Event Frontend, which allows the admin to view a user whenever view action button in the user table is clicked.
The primary end point of Open Event API with which we are concerned with for fetching the the users details is
GET /v1/users/{user_id}
The complete user information on the view route is displayed, which includes the name, email, details about the user. All these are the attributes of the model user. Thus the model for the route is defined as follows:
The view route is located at app/admin/users/<user_id> and the parent route, app/users has another sub route within it called list. The list route shows all, active, deleted users. This list has a column of action buttons.
This list can only be accessed by the admin. Whenever the view button in the Actions column is clicked the admin gets redirected to the view users route.
The view route shows the following information about the user: Name, Family name, Email, Image of the user, Details of the user. Thus the admin can view all the users registered in the application.
This blog article will illustrate how the admin statistics API for events and sessions is integrated and how the values of different types of sessions and events is added to the admin dashboard in Open Event Frontend.
The primary end point of Open Event API with which we are concerned with for fetching the statistics are
The route file helps to fetch the total count of each type of session and event through the queries written in the code. queryRecord is used instead of query because a single record is expected to be returned by the API. The view route is /admin.
The model needs to extend the base model class and all the attributes of the model will be number since the all the data obtained via these models from the API will be numerical statistics.
Once we retrieve the values of the attributes from the queries written in the route file we display the values of pending, rejected, accepted sessions and published, draft, past events.
This blog article will illustrate how the creation of the view route for sessions is done and how the sessions API is integrated with it on Open Event Frontend, which allows for the sessions and their associated data to be displayed. Also, it illustrates how the template for my-sessions is modified to make it possible to reuse it for the view route with desired changes.
The primary end point of Open Event API with which we are concerned with for fetching the the session details is
GET /v1/sessions/{session_identifier}
For displaying the complete session information on the view route, the session type, speakers and session track are also required. All of these extra attributes have a relationship with a given session and hence can be fetched in a single query. Thus the model for the route is defined as follows:
The view route is located at app/routes/my-sessions/view and the parent route, app/routes/my-sessions has another sub route within it called list. The list route shows upcoming and past sessions to the user based on the params passed to it. Thus a navigation is required to alternate between those two routes. However, this navigation should not be present in the view route. Thus the template my-sessions.hbs is modified as follows:
Based on the state property of the session, the label displaying the status is appropriately coloured wherein green, yellow and red colours denote accepted, pending and rejected sessions respectively. Since most of the fields of the session model are optional in nature, all of the them are subjected to conditional checks for existence.
Open Event Frontend allows the organizer of an event to customise the sessions and speakers form using the custom form API. While creating the event the organiser can select the form fields which he wants to place in the sessions and speakers form. This blog will illustrate how a form to edit the details of a speaker is created. Only those fields are included which were included by the person who created the event during the sessions and speakers creation section.
The first step is to retrieve the fields of the form. Each event has custom form fields which can be enabled on the sessions-speakers page, where the organiser can include/exclude the fields for speakers & session forms.
A query is written in the javascript file of the route admin/speakers/edit to retrieve the required details and create a form. The second query helps to determine the speaker id and include the model of speaker and the attribute values of the speaker with that specific id.
In the frontend we call the form of session and speakers. With the speaker-id being passed from the route, a form is created with the values entered by the user during the speaker creation and the other attributes marked included in the session-speakers wizard.
This blog article will illustrate how to edit a Session in Open Event Frontend, for which a nested route /sessions/edit/<session_id> had to be created. Further an Edit Session Form was created on that route to use the patch end-point of the sessions API of Open Event API.
To get started with it, we simply use the ember CLI to generate the routes
$ ember generate route events/view/sessions/edit
Now router.js file is changed to add the session_id. The router.js file should be looking like this now.
This means that our routes and sub routes are in place. We are using ember CLI to generate these routes, that means, the template files for them generate automatically. Now these routes exist and we need to write the data in the templates of these routes which will get displayed to the end user.
The routes are nested, the content of the parent route can be made available to all the children routes via the outlet in ember js.
Next, we go to the template file of sessions/edit route which is at templates/events/view/sessions/edit.hbs which displays an Edit Session form.
<form class=”ui form {{if isLoading ‘loading’}}” {{action ‘submit’ on=’submit’}}>
After the editing of different attributes is done Save Session button is clicked for which the action is defined in the controller /controllers/events/view/sessions/edit.js. The patch endpoint was called and the details of the attributes changes were saved.
This blog article will illustrate how the Speakers API is integrated in Open Event Frontend, which allows for the speakers and their associated data to be displayed in the speakers table. Also, it illustrates how the basic semantic UI table is converted into an ember model table to accommodate the fetched data from the API. Our discussion primarily will involve the app/routes/events/view/speakers route to illustrate the process.
The primary end point of Open Event API with which we are concerned with for fetching the the speaker details is:
GET /v1/events/{event_identifier}/speakers
First we need to formulate the filters options while making the API call. There are several tabs present which display all the sessions in a particular state i.e. pending, rejected, accepted and all. Thus the formulated filter options stored in the variable filterOptions are as follows:
let filterOptions =[];
if(params.speakers_sessions_state ==='pending'){
filterOptions =[{
name : 'state',
op : 'eq',
val : 'pending'}];
}elseif(params.speakers_sessions_state ==='accepted'){
filterOptions =[{
name : 'state',
op : 'eq',
val : 'accepted'}];
}elseif(params.speakers_sessions_state ==='rejected'){
filterOptions =[{
name : 'state',
op : 'eq',
val : 'rejected'}];
}else{
filterOptions =[];
}
Next we need to formulate the required query to actually make the API call. It is important to note here that there is a column for sessions of the speaker in the speaker table. Sessions are a related field for a user and hence we will make use of the include clause while generating the query, Similarly we will make use of the filter clause to pass on the filter options we generated above in filterOptions.
Since the speakers are being fetched for a particular event, and we are in that event’s dashboard, the speakers in question have a hasMany relationship with the aforementioned event. Thus we can make use of the model already fetched in the view route. So the final query call will be as follows:
The page[size] option in the query is for implementing pagination, it ensures that at max 10 speakers are returned at once.
Next, we need to convert the existing table to an ember model table. For this the first step is to delete the entire original table along with the dummy data in it. The events-table ember table component will be re-used to form the base structure of the table as follows:
Final steps of conversion table to ember table involve defining the columns of the table. They will be defined in the usual manner, with mandatory title and name attributes. In case the display requirements of the data are in mere simple text, calling a template for displaying the text is not required, however for more complex natured values in the columns, it is advisable to make use of the component, and the technical logic can be handled in the component template itself. For instance, one such field on the speakers table is sessions which are related records and were included especially in the query call. They are not directly accessible by their field names. Thus they must be referred as a child of the record object.
{{#each record.sessions as |session|}}{{session.title}}{{/each}}
Similarly the template for the actions column will have to be created as it requires complex logic to implement actions on those buttons. After defining all the columns in the controller, the final columns are as follows:
columns: [{
propertyName : 'name',
title : 'Name'},
{
propertyName : 'email',
title : 'Email'},
{
propertyName : 'mobile',
title : 'Phone'},
{
propertyName : 'sessions',
title : 'Submitted Sessions',
template : 'components/ui-table/cell/events/view/speakers/cell-simple-sessions',
disableSorting : true},
{
propertyName : '',
title : 'Actions',
template : 'components/ui-table/cell/events/view/speakers/cell-buttons'}]
After performing all these steps, the static table which was holding dummy data has been converted into an ember table and thus features like inbuilt pagination, searching etc. can be used.
This blog article will illustrate how the various social links are specified in the the footer of Open Event Frontend, using the settings API. Open Event Frontend, offers high flexibility to the admins regarding the settings of the App, and hence the media links are not hard coded, and can be changed easily via the admin settings panel.
The primary end point of Open Event API with which we are concerned with for fetching the settings for the app is
GET /v1/settings
The model for settings has the following fields which concern the social links.
Now it is required for us to fetch the data from the API, by making the corresponding call to the API. Since the footer is present in every single page of the app, it is necessary that we make the call from the application route itself. Hence we add the following to the application route modal.
Next we need to iterate over these social links, and add them to the footer as per their availability.So we will do so by first passing the model to the footer component, and then iterating over it in footer.hbs
And thus we have passed the socialLinks portion of the model, under the alias socialLinks.Next, we iterate over them and each time check, if the link exists before rendering it.
Thus all the links in the app are easily manageable, from the admin settings menu, without the need of hard coding them. This approach also, makes it easy to preserve the configuration in a central location.
This blog article will illustrate how the various tickets are stored and displayed in order the event organiser decides on Open Event Frontend and also, how they are kept in sync with the backend.
First we will take a look at how the user is able to control the order of the tickets using the ticket widget.
{{#each tickets as |ticket index|}}
{{widgets/forms/ticket-input ticket=ticket
timezone=data.event.timezone
canMoveUp=(not-eq index0)
canMoveDown=(not-eq ticket.position (decdata.event.tickets.length))
moveTicketUp=(action 'moveTicket' ticket 'up')
moveTicketDown=(action 'moveTicket' ticket 'down')
removeTicket=(confirm 'Are you sure you wish to delete this
ticket ?' (action 'removeTicket' ticket))}}
{{/each}}
The canMoveUp and canMoveDown are dynamic properties and are dependent upon the current positions of the tickets in the tickets array. These properties define whether the up or down arraow or both should be visible alongside the ticket to trigger the moveTicket action.
There is an attribute called position in the ticket model which is responsible for storing the position of the ticket on the backend. Hence it is necessary that the list of the ticket available should always be ordered by position. However, it should be kept in mind, that even if the position attribute of the tickers is changed, it will not actually change the indices of the ticket records in the array fetched from the API. And since we want the ticker order in sync with the backend, i.e. user shouldn’t have to refresh to see the changes in ticket order, we are going to return the tickets via a computed function which sorts them in the required order.
The sortBy method ensures that the tickets are always ordered and this computed property thus watches the position of each of the tickets to look out for any changes. Now we can finally define the moveTicket action to enable modification of position for tickets.
The moveTicket action takes two arguments, ticket and direction. It temporarily stores the position of the current ticket and the position of the ticket which needs to be swapped with the current ticket.Based on the direction the positions are swapped. Since the position of each of the tickets is being watched by the tickets computed array, the change in order becomes apparent immediately.
Now when the User will trigger the save request, the positions of each of the tickets will be updated via a PATCH or POST (if the ticket is new) request.
Also, the positions of all the tickets maybe affected while adding a new ticket or deleting an existing one. In case of a new ticket, the position of the new ticket should be initialised while creating it and it should be below all the other tickets.
This blog article will illustrate how the roles are created via the external model on the admin permissions page in Open Event Frontend, using the roles API. Our discussion primarily will involve the admin/permissions/index route to illustrate the process.The primary end point of Open Event API with which we are concerned with for fetching the permissions for a user is
POST /v1/roles
First we need to create a model for the user-permissions, which will have the fields corresponding to the api, so we proceed with the ember CLI command:
ember g model role
Next we define the model according to the requirements. The model needs to extend the base model class, and has only two fields one for the title and one for the actual name of the role.
import attr from 'ember-data/attr';
import ModelBase from 'open-event-frontend/models/base';
export default ModelBase.extend({
name: attr('string'),
titleName : attr('string')
});
Next we need to modify the existing modal to incorporate the API and creation of roles in it. It is very important to note here that using createRecord as the model will result in a major flaw. If createRecord is used and the user tries to create multiple roles, other than the first POST request all the subsequent requests will be PATCH requests and will keep on modifying the same role. To avoid this, a new record needs to be created every time the user clicks on Add Role. We slightly modify the modal component call to pass in the name and titleName to it.
Upon entering the details of the roles and successful validation of the form, if the user clicks the Add Role button of the modal, the action addSystemRole will be triggered. We will write the entire logic for the same in the respective controller of the route.
addSystemRole() {
this.set('isLoading', true);
this.get('store').createRecord('role', {
name : this.get('name'),
titleName : this.get('titleName')
}).save()
.then(() => {
this.set('isLoading', false);
this.notify.success(this.l10n.t('User permissions have
been saved successfully.'));
this.set('isAddSystemRoleModalOpen', false);
this.setProperties({
name : null,
roleTitleName : null
});
})
.catch(()=> {
this.set('isLoading', false);
this.notify.error(this.l10n.t('An unexpected error has occurred.
User permissions not saved.'));
});
},
At first the isLoading property is made true.This adds the semantic UI class loading to the the form, and so the form goes in the loading state, Next, a record is created of the type role and it’s properties are made equal to the corresponding values entered by the user.
Then save() is called, which subsequently makes a POST request to the server. If the request is successful the modal is closed by setting the isAddSystemRoleModalOpen property to false. Also, the fields of the modal are cleared for a better user experience in case multiple roles need to be added one after the other.
In cases when there is an error during the processing of the request the catch() block executes. And the modal is not closed. Neither are the fields cleared.
You must be logged in to post a comment.