-
-
Notifications
You must be signed in to change notification settings - Fork 7
Advanced Features
Last updated: June 2, 2023
These features are considered "advanced" in the sense that they require additional setup. Some of them provide communication methods between various parts of your app, thus leveraging quite powerful administration features.
Namely:
- iFrameWnd
- Heartbeat Monitoring
- User Preferences
- Account Logging
- Remote SW Updates (the page and view setup will come soon)
- User and Public Filters automatic Upload and Download
In this section, when you see a name for an object, a field or a view title, it must be written exactly as shown, case sensitive, spaces, everything. It is recommended to copy/paste to avoid any typos.
This shall be your default place for any future utility hidden pages. For now, the iFrameWnd page will be its first resident.
- Add a new Dropdown Menu named Invisible Menu.
- Do not any page yet, click Continue at bottom.
- In settings, uncheck Include this page in the Page Menu.
To use this feature, you must set the iFrameWnd flag to true in the ktl.core.setCfg function.
Create a new Login Page and give permission to all users. Set Page Name to: iFrameWnd. Its URL should automatically be set to iframewnd. This page will be the placeholder for the next features. For now, leave it blank as we need to create a few objects first. Now, go back to the Invisible Menu and assign the iFrameWnd to it.
If you want to add User Preferences to your app, there are some already built-in, and you can also add your own. Follow this procedure:
- Create a Role called Developer and assign it to yourself.
- In the Accounts object, add a Paragraph Text field named User Prefs.
- In the iFrameWnd page, add a view: Type: Details, For: Logged-in Account. Once the view is added, remove all fields, then add User Prefs. Set the view title to Current User Prefs _ar=10.
- Add a Form view that updates the currently logged-in account. Once the view is added, remove all fields, then add User Prefs. Set the view title to Update User Prefs. Enable the form's auto-reload in the Submit rule.
- Align both views on the same row to save space.
- Go to User Pages (at the bottom of the Pages view) and edit the Account Settings page.
- Add a menu named My Settings and move it to the top of the page.
- Add a link to a new page named My Preferences and enter to edit that page.
- Add a Form view that updates the currently logged-in account. Once the view is added, remove all fields, then add User Prefs. Set the view title to My Preferences.
- Refresh your app and click on the - Account Settings link, then on My Preferences button in top menu.
- You will see 4 new checkboxes (dynamically generated by code): Show View ID, Show iFrameWnd, Show DebugWnd and Show Extra Debug.
- Check all 4, submit and view the result: 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, and some new logs about WndMsg processing (REQ, ACK, etc.) will be shown in the console output.
- Uncheck all those you don’t want and submit. It is recommended to leave Show iFrameWnd on if you’re planning to set up the User Preferences that follow.
If you want to add Heartbeat Monitoring to your app to assess an account's presence and generate alerts, or perform remote SW updates, follow this procedure:
- Add the User Preferences feature from the above procedure.
- In the Accounts object, add these fields:
- SW Version: Type: Short text.
- UTC HB: Type: Date/Time, Date Format: mm/dd/yyyy, Default Date: none, Time Format: military, Default Time: none.
- TZ: Type: 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 Last Activity: Type: Date/Time, Date Format: mm/dd/yyyy, Time Format: military.
- Create a new object called App Settings with these fields:
- Rename the default first field from App Settings Name to Item: Type: Short Text, set as object’s Display Field and Sort in Alphabetic order.
- Value: Type: Paragraph Text.
- Date/Time: Type: Date/Time, Date Format: mm/dd/yyyy, Time Format: military.
- In the iFrameWnd page created above, add a Form view that updates the currently logged-in account. Once the view is added, remove all fields, then add on a first line: SW Version, UTC HB and LOC HB. Set LOC HB as read-only. Then on a second line: Online, UTC Last Activity and TZ. Set the view title to Heartbeat. In the form’s Submit rules, enable auto-reload and set the Confirmation message to “Heartbeat sent successfully.”.
- Still in the iFrameWnd, add a table view that displays App Settings, with title: App Settings _ar=20. Source filter: Item Starting with APP, sorted alphabetically A to Z. No Search, inline editing = On, 10 records at a time, no filtering allowed. Add all fields. Set Value’s Truncate Text to 75 characters.
- Be sure you have the Show iFrameWnd checkbox on in User Prefs above.
- Refresh the app and you should see in the iFrameWnd the heartbeat being submitted every minute and the Online being set to Yes.
- VIEWER: To view the heartbeats, online status, latest activity, SW Version, etc., create a Sysop Dashboard page accessible to Developer role only, with a table view that shows the Accounts having an Active status. Title: Account Status _ar=60. Fields: Name, Online, LOC HB, UTC HB, UTC Last Activity, SW Version and User Prefs. This view will refresh itself every minute, so you can assess the presence, latest activity and SW Version for each account.
- Note: The Online status flag is set, but not reset automatically. You’ll need to create a daily task to reset it. We also have some existing code that does it with API calls and will add it to the KTL soon. We will also provide all code for Online updates, emails and audio alerts, custom status colorizing, etc.
- Create a Status Monitoring page, where only the Developer Role can access, add a grid view for App Settings object. Title: SW Update. Filter Source on Item contains APP_KTL_VERSIONS. Settings: no search, Inline Edit = On, 10 records, no filtering. Leave three fields: Item, Value and Date/Time.
- Add an Action column: Header: Broadcast SW Update, Link Text: BROADCAST NOW. Action is Update this record, Item to a field value: Item. Confirmation msg: SW Update in progress.... You can set the text style in bold red with the display rule: when Item is not blank.
When you have a new code release and you want all users to be updated synchronously:
- Open the Status Monitoring page created above.
- Increment your App's version number in the global variable: window.APP_VERSION = '1.0.0';
- Copy/paste your code in the Javascript pane - do not save yet!
- Update the KTL version in the Loader if needed. Sometimes you intentionally hold back a KTL update until you have an App update, then do both at the same time.
- Save the Javascript code.
- Refresh your app to get the latest version.
- Click BROADCAST NOW action.
This will 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.
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 not work 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.
To support automatic Upload and Download, follow this procedure:
- Create an object named User Filters and add these fields:
- Account: Type: 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: Type: Paragraph Text.
- Object Settings : Display Field: Account, Sort Order: Account, a to z.
- Delete the first default field created: User Filters Name.
- Go to the iFrameWnd page and add a new Table that displays User Filters connected to the logged-in account. Call it User Filters, remove the Account column and leave only the Date/Time and Filters Code. Set Filters Code’s Truncate Text to 75 characters.
- Source: Limit number of records to 1.
- Settings: no search, Inline Editing = On, 10 records at a time, no filtering. Title: User Filters _ar=30 (you can change the 30 for 10 seconds temporarily for quicker testing, then put back to 30)
To assess this feature:
Open two different browsers (ex: Chrome and Edge) and log-in with your own account in both. Open them to the same page, where there’s a table with filtering enabled. Create a couple of filters in the first browser, wait about 30 seconds and you will see those filters appear in the second browser. Same applies for Public Filters: set a filter to Public, make changes to it, and all will be reflected in the other browser, but also for all users of that view.
*Note about browsers: the localStorage is not shared across different browsers (and also within the same browser but in private/incognito mode). This is when the automatic Upload/Download feature then comes in handy, by allowing this transfer to occur in real-time, within about 30 seconds.
If you want to add Account Logging to your app, follow this procedure:
- Create an object named Account Logs and add these fields:
- Log Nb: Type: Auto-Increment.
- Account: Type: 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.
- Log Type: Type: Short Text.
- Details: Type: Paragraph Text.
- Log Id: Type: Short Text. See note below for details.
- Email To: Type: Email.
- In the Object Settings: Display Field: Account, Sort Order: Log Nb, low to high.
- In the iFrameWnd, add a view: Type: Table, For: Account Logs, connected to the logged-in Account.
- Once the view is added, remove all fields, then add Date/Time, Log Type, Details, Log ID, Email To and an Custom Email action with these settings, as from the screen capture 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.
- Set the view title to Account Logs _ar=30, disable search, enable Inline editing, 10 records at a time, no filter.
- Sort by Log Nb: high to low, limit to 5 records.
*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 sent via the API call. 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.