-
-
Notifications
You must be signed in to change notification settings - Fork 7
Advanced Features
These features are considered "advanced" in the sense that they require some additional setup before they can be used.
They provide or use communication mechanisms between various parts of your app, thus leveraging quite powerful administration features.
This hidden utility sub-page has several views that provide background automated tasks: Heartbeat Monitoring, User Preferences, Account Logging, User and Public Filters and Remote SW Updates.
Heartbeat Monitoring allows your app to assess an account's presence and generate alerts or perform remote SW updates.
User Preferences provides an object to store any information about the account. It is in the form of a string representing a JSON object. There are a few already built-in, and you can also add your own.
This will provide comprehensive logging capabilities to your application. All logs are connected to an account, and can collect vast amounts of information related to the following:
- Login date/time
- IP address
- OS type/version
- Browser type/version
- APP+KTL versions
- Navigation history, including URL, searches and filters
- Typical log types as Critical, App Errors, Server Errors, Warnings, Debug and Information
- Your own app-specific logs types as well
- User activity: count of mouse clicks and keypresses
WARNING!!! This feature can use a lot of API calls in some cases. It is your responsibility to perform regular/frequent checks on your API usage. You may decide to disable some logging event to keep them within safe limits.
This is done in the ktl.log.setCfg function for general flags. You can also achieve a finer level of control using the logCategoryAllowed callback to your app, where more specific conditions can be applied.
In addition to being able to create named buttons for the User Filters that are saved in localStorage, it is possible with a bit of setup to upload your settings to Knack and download them back wherever and whenever needed. This two-way process is automatically done in the background, and can be seen as a backup method, but also to migrate them to other devices (or browsers, see note below). Note that if you migrate filters from one app to another, typically a temporary development copy, some filters may stop working due to the record IDs that have changed for connected fields. This is a normal behavior, and the only way to fix this is to redo their settings and save back to the same button name.
For those having the Public Filters role, they will be able to create a User Filter, but also to right-click on it and set it as Public. Doing this will upload the filter to the cloud and make it available to all users when they access that page and view. Only those with the Public Filters is role can drag’n drop the filter for re-ordering, rename or delete it.
Before proceeding with the Setup section that follows, it is assumed that the reader is familiar with the principles of KTL Customization found in this page: https://github.com/cortexrd/Knack-Toolkit-Library/wiki/Customizing-Features#customizing-features
Also, it is assumed that your Accounts table still has its default name. If you renamed it, you would need to use the function ktl.iFrameWnd.setCfg
to set the variable accountsObjName
accordingly.
Important!!! Throughout the following sections, whenever we mention the name of a table, a field or a view title, it must be written exactly as shown, case sensitive, spaces, punctuation, everything. It is recommended to copy/paste such text to avoid any typos.
If a setup information is omitted, it means that you shall use the default. This applies to both fields and views.
Having an invisible menu may be counterintuitive, but actually it will soon prove to be very useful. It allows hosting any utility pages that the users don't need to see, but still accessible by the developers via its direct URL, and also by the KTL to perform several background tasks.
We will now create a hidden menu that will be your default place for any future utility hidden pages.
- Add a new Dropdown Menu named Invisible Menu.
- Do not add any page yet, click Continue at bottom.
- In settings, uncheck Include this page in the Page Menu.
The iFrameWnd will soon be its first resident.
For a description of what is the iFrameWnd, see this page: https://github.com/cortexrd/Knack-Toolkit-Library/wiki/Features-Overview#iframe-window
- Create a new Login Page accessible to all users
- Page Name: iFrameWnd
- Its URL is automatically set to iframewnd
- Assign it to the Invisible Menu above
This page will be the placeholder for the next features. For now, leave it blank and we’ll get back to it later.
To activate this feature, you must set the iFrameWnd flag to true in the ktl.core.setCfg function.
If not done already, take a moment to read that page: https://github.com/cortexrd/Knack-Toolkit-Library/wiki/Customizing-Features#customizing-features
This section contains what you’ll need to do the set-up: https://github.com/cortexrd/Knack-Toolkit-Library/wiki/Customizing-Features#the-ktl-setupscallbacks
Create these roles:
- Developer
- Bulk Edit
- Bulk Delete
- Bulk Copy
- Sysop
- SW Update (to implement)
- Local Dev (to implement)
Assign them all to yourself.
See Pre-requisites above if you changed the name of the Accounts table.
- User Prefs: Paragraph Text
- SW Version: Short text.
-
UTC HB:
- Date/Time
- Date Format: mm/dd/yyyy
- Default Date: none
- Time Format: military
- Default Time: none
-
TZ:
- Number
- No decimals.
-
LOC HB:
- Type: Equation
- Equation Type: Date
- Date Type: hours
- Result Type: Date
- Equation Editor: {UTC HB}+{TZ}
- Date Format: mm/dd/yyyy
- Time Format: military.
-
Online:
- Type: Yes/No
- Default No
- Input: Checkbox
- UTC ACT: Type: Date/Time, Date Format: mm/dd/yyyy, Time Format: military.
-
LOC ACT:
- Type: Equation
- Equation Type: Date
- Date Type: hours
- Result Type: Date
- Equation Editor: {UTC ACT}+{TZ}
- Date Format: mm/dd/yyyy
- Time Format: military.
Create a table named App Settings with these fields:
-
Item:
- Rename the default first field from App Settings Name to Item
- Set it as the table’s Display Field
- Sort: Item, a to z
- Value: Paragraph Text
-
Date/Time:
- Type: Date/Time
- Date Format: mm/dd/yyyy
- Time Format: military
Create a table named User Filters with these fields:
-
Account: Connection to Accounts, all settings at default
-
Date/Time:
- Type: Date/Time
- Date Format: mm/dd/yyyy
- Default Date: Current Date
- Time Format: military
- Default Time: Current Time
- Filters Code: Paragraph Text
-
Table’s settings:
- Display Field: Account
- Sort: Account, a to z
-
Date/Time:
Delete the first default field created: User Filters Name.
- Add a Form view:
- Updates the currently logged-in account
- Title: Heartbeat
- Submit rules: auto-reload
- Confirmation message: Heartbeat sent successfully
- Fields on first line:
- SW Version
- UTC HB
- LOC HB, as read-only
- Fields on second line:
- Online
- UTC ACT
- TZ
- On a second row, add a Details view:
- For Logged-in Account
- Fields: User Prefs
- Title: Current User Prefs _ar=10
- Still on second row, at right, add a Form view:
- Updates the currently logged-in account
- Fields: User Prefs
- Title: Update User Prefs
- Submit rule: auto-reload
- On a third row, add a Grid view:
- Displays App Settings
- Title: App Settings _ar=20
- No Search
- Inline editing: On
- 10 records at a time
- No filtering
- Add all fields
- Set Value’s Shorten Text to 75 characters
- Source filter: Item starts with APP
- On fourth row, add a Grid view:
- Displays User Filters connected to the logged-in account
- Title: User Filters _ar=30
- Remove the Account column and leave only Date/Time and Filters Code
- Set Filters Code’s Truncate Text to 75 characters
- Limit number of records to 1
- No search
- Inline Editing: On
- 10 records at a time
- No filtering
- Go to User Pages (at the bottom of the Pages view) and edit the Account Settings page
- Add a menu:
- Title: My Settings
- Move it to the top of the page
- Add a link to a new page:
- Title My Preferences
- Enter it to edit that page
- Add a Form view:
- That updates the currently logged-in account
- Title: My Preferences
- Field: User Prefs
- Submit rule: auto-reload
This section will guide you through the creation of a Sysop Dashboards menu with pages that will allow viewing and managing various system-wide information.
These will be created:
- A page to view all account status like heartbeats, online, latest user activity, SW Version and User Preferences
- A page to broadcast synchronous software updates
- A page to browse through all Account Logs
- Add a new Dropdown Menu
- Leave empty for now, just click the Continue button at the bottom
- Menu name: Sysop Dashboards
- Create a new Login page accessible to Sysop role
- Title: Status Monitoring _ar=60 _ts
- Icon: eye
- Add a Grid view that displays all Accounts
- Add the narrow margins and high-density classes in the description:
_cls=[ktlNarrowMarginsPage], [ktlTarget,scene] _cls=[ktlDenseGrid],[ktlTarget, $('.kn-table')]
- Source filter: User Status is active
- Fields:
- Name
- Online
- LOC HB
- UTC HB
- UTC ACT
- LOC ACT
- SW Version
- User Prefs
- Assign the page to the Sysop Dashboards menu
This view will refresh itself every minute, so you can assess the presence, latest activity and SW Version for each account.
Note about the Online status flag:
This flag is set to Yes programmatically by the KTL, but obviously, the only way to reset it to No would be to use some kind of supervision mechanism that declares the account being offline after a specific amount of time since the last heartbeat has been received.
This being said, you have 3 options:
- Ignore the Online status if it’s not important to your organization
- You can create some (1, 2 or 3+) daily task(s) to reset it
- Leave the Status Monitoring page running 24/7 on a dedicated device, so the KTL code will take care of this in real-time using API calls. This is the best option and Cortex R&D can provide such solutions using low-cost Linux devices in Kiosk mode to do it. Please enquire for more information.
Here are the reasons why you might want to broadcast a manual software update:
- You have some new code to release
- You want to update the KTL to a newer version
- You want the users to fetch the latest Builder’s changes
- Any combination of the above
- Create a new Login page accessible to SW Update role only. Ideally, only one person should have that role to prevent clashing updates. Otherwise, it will be crucial to establish a very clear procedure and communication protocol between the involved parties.
- Title: SW Update
- Icon: bullhorn
- Add a Grid view that displays the App Settings table
- Title: SW Update
- Settings:
- No search
- Inline Edit: On
- 10 records
- No filtering
- Source filter: Item is APP_KTL_VERSIONS
- Fields:
- Item
- Value
- Date/Time
- Add an Action column
- Header: Broadcast SW Update
- Link Text: BROADCAST NOW
- Action: Update this record, Item to a field value: Item (just a dummy action)
- Confirmation msg: SW Update in progress...
- Text style: bold red with the display rule: when Item is not blank
- Assign the page to the Sysop Dashboards menu
Creating the Accounts Logs Page
- Create a new Login page accessible to Sysop role
- Add a Grid view that displays the Account Logs table
- Title: Account Logs
- Settings:
- Display Field: Account
- Sort Order: Log Nb, low to high
- Fields:
- Log Nb: Type: Auto-Increment
- Account: Type: Connection to Accounts
-
Date/Time:
- Type: Date/Time
- Date Format: mm/dd/yyyy
- Default Date: Current Date
- Time Format: military
- Default Time: Current Time
- Log Type: Type: Short Text
- Details: Type: Paragraph Text
- Log Id: Type: Short Text (see note below for details)
- Email To: Type: Email
- Assign the page to the Sysop Dashboards menu
In the iFrameWnd
- Add a Grid view that displays the Account Logs connected to the logged-in Account
- Title: Account Logs _ar=30
- Settings:
- No search
- Inline editing: On
- 10 records at a time
- No filtering
- Sort by Log Nb: high to low
- Limit to 5 records
- Fields:
- Date/Time
- Log Type
- Details
- Log ID
- Email To
- A Custom Email action with these settings: KTL Account Logs Email Settings.jpg.
- The blank value to Email To in Action #2 is intended. This field also acts as a flag and resetting it to blank prevents sending the email more than once.
- The Outcome phrase “Account Logs - Email sent successfully” is used in the code to confirm completion, so it must be exactly the same.
Note about the Log Id field
This is a unique ID that is a UTC millisecond timestamp. It is generated by the code at the moment the log is created and stored in localStorage. Its purpose is to validate that the log has been sent and received properly. With that confirmation, the log can safely be deleted from localStorage.
Refresh your app to see all changes take effect.
- Click on Account Settings link at the top right of your page.
- Click My Preferences menu button.
- You will see 4 new checkboxes (dynamically generated by code):
- Show View ID
- Show iFrameWnd
- Show DebugWnd
- Show Extra Debug
- Check all 4 and Submit:
- View IDs will be shown in red next to each view
- The iFrameWnd will appear at the bottom of the app
- The DebugWnd will show up
- In the console output, some new logs about WndMsg processing (REQ, ACK, etc.) will be shown.
- Uncheck all checkboxes and Submit to hide all views and stop extra logs.
- Check the Show iFrameWnd checkbox from the above procedure and Submit to see the iFrameWnd again.
- In the iFrameWnd you will see the heartbeat being submitted every minute. All fields will be populated properly with SW versions, timestamps, time zone and the Online flag being set to Yes.
- Open your app on two different devices (or browsers - ex: Chrome and Edge)
- Log-in with your own account in both
- On both browsers go to the same page, where there’s a Grid with filtering enabled
- In a given view, create a couple of filters in the first browser
- Wait about 30 seconds and in the second browser, you will see those filters appear for that same view.
Whenever you need to do a SW Update, do the following procedure:
- Be sure to close all browsers that you have opened on this app
- Open the SW Update page created previously
- Go back in the Builder’s Javascript pane and increment your App's version number in the global variable:
window.APP_VERSION = '1.0.0'; - Copy/paste your code in the Javascript pane – but don’t save yet!
- Update the KTL version in the Loader if needed.
NOTE: Sometimes you may want to intentionally hold back a KTL update until you also have an App update to push, so you can do both at the same time - Save the Javascript code. Important: wait until the spinner is gone
- Refresh your app to get the latest version
- Do a quick visual check to validate the numbers in the Version Info Bar at top right
- Click the BROADCAST NOW action link
- Validate that the version in the Grid matches that of the Version Info Bar
- Open the Status Monitoring page to see all users’ version slowly being updated and the process completes abroad for those who are online.
IMPORTANT!!! The steps 6 to 9 must be done without interruption, otherwise all users will see their app page(s) reloading over and over again.
If this happens, click BROADCAST NOW once again and check if the value in the Grid matches the one in the Version Info Bar – as it should.
If the looping persists
If, despite the retry mentioned above, the app keeps reloading in a loop, disable the iFrameWnd flag (false) in the ktl.core.setCfg function and save your Javascript code. Once the dust has settled, you can start investigating the root cause. Usually it’s due to a typo in a field name or a view title somewhere. Check the console logs also.
Behind the scenes, this is what happens: The KTL uses an API call to update the App Settings' APP_KTL_VERSIONS record. All users with opened browsers will have their iFrameWnd detect the version change and force a page reload to get the latest code.
Those who are not online will simply get the latest code when they launch the app next time.
- Open two browsers of different types, ex: Chrome and Edge.
- Log-in with your account having Public Filters role, in the first browser
- Log-in with another account not having Public Filters role, in the second browser
- Go to the same page on both browsers
- Create two User Filters with your account
- Set them to Public
- You can drag’n drop them left and right and can rename them
- On the second browser, those two filters will appear about 30 seconds later
- The other user can’t move them, rename them nor delete them
- In your page, click on the padlock icon to unlock Public Filters. See notes below about the padlock icon
- Make changes to the filter and re-order them
- All changes will be reflected in the other browser a few seconds later
The padlock only applies to Public Filters and is only visible to users having that role.
- Locked: Makes the Public Filters “read-only”. When you make changes to Public Filters, they won’t be saved locally or uploaded. This is useful for normal day to day usage. Otherwise, when you just want to change the sorting, searching, etc., an upload would occur each time, disturbing the others working with that view.
- Unlocked: Makes the Public Filters “writable”. When you make changes to Public Filters, they will both be saved locally and uploaded. This is useful during (or after) an editing session, when you’re ready to broadcast the updated filters to all users. Typically, you unlock, edit all filters and lock back.
It’s important to understand that the localStorage (where the filters information is stored) is not shared across different browser families – ex: Chrome and Edge. Furthermore, this is also true within the same browser family, when opening their private/incognito counterpart.
This means that without the automatic upload/download of filters, all users would have to re-create them when switching devices or browsers. But now, this takes care of the transfer in all cases.
This particularity can be leveraged by allowing you to log-in to 4 different accounts and/or roles at the same time. This can be very useful during testing phases for example.
Hope you’ll enjoy the KTL’s Advanced Features. Give us some feedback, we always love to hear from you.
Normand Defayette
Cortex R&D Inc.