Mittwoch, 13. Mai 2020

Highlight current card

In the APEX universal theme, the is_current state is not visible in Cards regions.
Solution: Highlight active card in list regions with template Cards with some CSS.

 li.t-Cards-item.is-active div.t-Card {
    box-shadow: 0px 0px 6px 1px Yellowgreen;
}

Bug with Warn on Unsaved Changes

APEX version >= 5 supports a 'Warn on Unsaved Changes' functionally when the setting on page level is 'Yes'.
Problem: For item types 'Popup LOV' and 'Radio Group' the setting 'Ignore' is not applied and you get the warning message.
Solution: Use the following JS code in 'Execute when Page Loads' to fix this problem.

// for POPUP_LOV
$('input[id$=_HIDDENVALUE]').addClass('js-ignoreChange');

// for RADIO_GROUP
$('input[type=radio]').addClass('js-ignoreChange');

Montag, 4. Mai 2020

Cloud Visitors – APEX App


Application to monitor visitors of remote APEX sites

I have published several demo applications for open-source oracle APEX plugins on apex.oracle.com and other hosting locations. My joy and payback are, to watch the web traffic on the demo site. To do that, go to the Administration\Monitor Activity\Login Attempts report, there you can list visitors with there IP address. I then used a web site like iplocation.net to find out from where in the world the visitors came. I feel a bit connected to the world out there and I believe that it was worth sharing with the community.

I found the lessons on apex.oracle.com about REST data sources and SQL REST functions.
REST Enabling Database Objects 
Defining Web Sources

Then I took a chance to automate the reporting and location lookup for all my sites in one application that I run in my local development environment.
You can download this application from github.com
https://github.com/dstrack/Cloud_Visitors

You can see a demo of this app here:
https://apex.oracle.com/pls/apex/f?p=143496:LOGIN_DESKTOP

The PL/SQL script file  cloud_visitors_utl.sql creates the view CLOUD_VISITORS_V, the tables CLOUD_VISITORS and CLOUD_VISITORS_IP_BLACK_LIST and the package CLOUD_VISITORS_UTL.

At the demo sites:
Execute the script file cloud_visitors_utl.sql
The packages procedure cloud_visitors_utl.Define_RESTful_Service will be executed to install the REST endpoint.
In the view CLOUD_VISITORS_V, the visitor activity is selected from APEX_WORKSPACE_ACTIVITY_LOG, it is then grouped by session login_date, ip_address, application, and page. The performed requests and time spend is aggregated.

In your localhost:
Install the application in your local APEX development environment. Then go the Shared Components\Web Source Modules to edit the modules. The module IP_Geolocation is used to lookup the geolocations of your visitor's IP addresses and should not be removed. Remove the example modules and add modules for your demo sites.
The app enables you to choose the name of a web source module for a visitor's report.

Launch the app and enter your apex credentials.
The page 'Cloud Visitors'
Here you can display recent visitor's activities in an interactive Report from a local table.
After choosing a web source, you can control the scheduler job for the web source.
Click the 'Update now' button to load the recent information from the data source into the local table could_visitors.
Click the 'Launch refresh job' button to enable the frequent refresh of the report data.
A scheduler job will load the recent information with an SQL REST function from the data source joins it with the IP geolocation data and merges the result into the table cloud_visitors. Your own public IP address is added to the table cloud_visitors_ip_black_list and will be excluded from the reports.

Now you can choose a web source to be displayed and you don't have to wait for the display of the result. The data is updated every 4 hours.

And another problem is solved: The regular call of a web service at xyz.oraclecloudapps.com will also prevent the shutdown of an always free ATP site caused by developer inactivity!

The page 'Visitors - Web Source' shows an Interactive Report from location 'Web Source'. Only one web source (that you have to choose in the program editor) can be displayed and you have to wait up to 30 seconds for the result.

The page 'Visitors - SQL REST function' shows an Interactive Report from an SQL REST function. You can choose a web source to be displayed but you have to wait up to 30 seconds for the result.

The page 'IP Location - SQL REST function' allows you to Lookup the geo-location for an IP-Adress. Your own current public IP address and an IP Black List is shows. Here you can add IP addresses of robots that are excluded from the Cloud Visitors reports.

You may have to increase the Limit of 1000 web service requests that are permitted per day for your workspace, to avoid errors in the web service calls. Log in instance administration and go to page Manage Instance \ Security. In the region 'Workspace Isolation' you can change the 'Maximum Web Service Requests' to a higher value.