Kagura.js

Kagura.js is a javascript file which is the driving force of the example javascript web page, which you can use as a basis for your reporting front end. Or you can write something yourself. Or go half way and use the kagura.js javascript file and hire a web designer to make a nicer front end for you your site.

Kagura JS, uses classes-as-tags and hidden elements to control the look and feel of the website. 

Using

The usage is fairly simple. Include kagura JS. Ensure that all the tags are matched as required, and that you are calling the functions you care about.

Usage overview

To use kagura you call functions. There are no automatically registered events or anything of that nature. You have full control and are required to build that up yourself. Most calls result in a ajax call, and there will be a delay before the action occurs.

Some of the typical calls: 

FunctionAction

loginSpin()

loginUnspin()

Starts and stops the spinner.

doLogin()

Attempts a login. Gets username from #loginEmail and gets password from #loginPassword. If successful calls "gotoMain()" Otherwise loginUnspin() and alerts the user to the error
exportReport(fileType, all)Starts a download of the report int he desired format
runReport()Runs the report

Some of the typical classes/tags you will be using:

Tag / style classDescription
#reportErrorsThe location to insert run errors onto a page
#reportPageNumberThe location to output the report page number
#loginEmailThe input used to get the username / email.
#loginPasswordThe input used to get the password.

#reportTableHeader

The table column. Contains one hidden column which is used a template for the other columns
#reportTableBodyThe table body. Contains 1 hidden row with a hidden cell for inserting rows & column values

Basically you get your web developer to put these where appropriate on their design, and then you can test the design by calling the appropriate functions and watching the results change.

Function details

FunctionCalled byAction

loginSpin()

loginUnspin()

UserStarts and stops the spinner.
setToken(token)Kagura.jsStores the token a a cookie
gotoMain()User, Kagura.jsChanges the URL to go to "main.jsp"

doLogin()

UserAttempts a login. Gets username from #loginEmail and gets password from #loginPassword. If successful calls "gotoMain()" Otherwise loginUnspin() and alerts the user to the error
loadReportListSimple()User, onLoadSimple list of reports. Calls loadReportListData()

loadReportListDetailed()

User, onLoadLoads the report content list, as a detailed list with parameter values and more. With data when it gets it back calls: loadReportListData
loadReportListData()Kagura.js

Once you obtain the list of reports, this function populates the UI with the correct data. It looks for #reportDropdownList, removes all non-hidden child nodes from it. Clones the hidden node. And populates the data into it as appropriate.

resetDisplay()User, Kagura.js

Hides all categories, such as the main view, contact us view, about view and report view.

resetReportConfig()User, Kagura.jsResets report table data & columns, and parameter side bar.
resetReportBody()Kagura.jsResets report table data
resetReport()Kagura.js, UserResets report table data & columns.
addColumns(columns)Kagura.jsAdds a column
buildReportParameters(msg, inputParamFieldTemplate)Kagura.jsFrom the report data structure builds up the parameter input. Mostly pre-written components which are inserted.
processReportExtrasKagura.jsHandles special extraOptions on the report.
loadReport(reportId)UserLoads a report by the ID. Calls callKagura()
loadReport(reportId, andRun)UserLoads a report by the ID, Optionally allows it to run the report in the same call.
displayMain()UserDisplay the main section , after resetting the view.
displayContactUs()UserDisplays the contact us section, after resetting the view.
displayAboutUs()UserDisplays the about us section, after resetting the view.
exportReport(fileType, all)UserStarts a download of the report int he desired format
buildRequestParameters()Kagura.jsCompiles a JSON string of the report parameters, then URI encodes it.
rerunReport()Kagura.js

Reruns the report, resetting the page number.

reportErrors(msg)User, Kagura.js

Writes a bootstrap alert for errors returned in the message.

populateReportRows(msg)Kagura.jsPopulates the table.
fixReportColumns(msg) Kagura.jsUpdates column with new column details if changed.
runReport()UserRuns the report.
callKagura(reportId, method, url, contentType)Kagura.jsAjax call to restful services, then executes the appopriate functions based on the structure of the response.
prevPage()UserDecrements the page number then runs the report again
nextPage()UserIncrements the page number then runs the report again
logout()UserLogouts, removes token, and resets page.
ajaxFail(jqXHR, textStatus, errorThrown)Kagura.jsReports ajax failures to the user. Used in AJAX calls.

Selector details

Tag / style classDescription
#signinSectionLogin section. Used to disable region and enable a spinner
#reportDropdownListThe drop down where the report list is placed.

#kaguraMain
#kaguraContactUs
#kaguraAbout
#reportMain

The main sections of the page to tab between.

#reportTableHeader

The table column. Contains one hidden column which is used a template for the other columns
#reportTableBodyThe table body. Contains 1 hidden row with a hidden cell for inserting rows & column values
#paramPanelThe parameter panel. Hidden if there aren't any contents.
#inputParamFieldTemplateA template input field. For placement mostly.
#reportTitleThe report title location. Writes here when the title changes
#reportDescriptionThe report description location. Writes the description here if there is any.
#reportImageThe report image tag. Configures it to show an image if there is one
.alertAn alert location.
#reportErrorsThe location to insert run errors onto a page
#reportPageNumberThe location to output the report page number
#loginEmailThe input used to get the username / email.
#loginPasswordThe input used to get the password.