Vba to trigger 'pointerdown' event on an html element - excel

Need help to trigger 'pointerdown' event on an html element as part of a webpage automation project in excel vba.
Have been able to successfully automate using 'mousedown' trigger but recently the webpage source code has been modified to use 'pointerdown' to trigger instead of 'mousedown'.
Existing 'mousedown' code:
Set e1 = IE.Document.createEvent("MouseEvent")
e1.initMouseEvent "mousedown", True, True, 0, 1, 0, 0, 0, 0, True, False, False, False, 0, Null
ElementCol.Item(i).dispatchEvent e1
Tried the following 'pointerdown' code, but excel is throwing 'Automation error' on initPointerEvent line:
Set e1 = IE.Document.createEvent("PointerEvent")
e1.initPointerEvent "pointerdown", True, True, 0, 1, 0, 0, 0, 0, False, False, False, False, 0, Null , 0, 0, 0, 0, 0, 0, 0, 0, 0, "", 0, False
ElementCol.Item(i).dispatchEvent e1
Any help would be greatly appreciated.

Related

Phaser.js the opposite of .putTileAtWorldXY

Im trying to make a terraria/papercraft like game, and i've been using tiled for the map, and i've wanted to edit the world(break, destroy blocks) and i've looked at this tutorial
https://medium.com/#michaelwesthadley/modular-game-worlds-in-phaser-3-tilemaps-2-dynamic-platformer-3d68e73d494a
at it has the place tile, but has nothing for destroy tile, so how would i destroy tiled tile maps in phaser?
seeing some prev q's, the tile.destroy method with map name sends out bugs every time of the layer name, etc, and nothing seems to work
if anyone has a solution, or could point to a working phaser three tutorial in breaking and destroying tiled maps, please give em, im new to phaser and tiled in general.
what im working on (for context) -> https://glitch.com/edit/#!/paperambi2?path=src%2Fscenes%2FGame.js%3A77%3A21
Depending on your use case you can remove or replace single tiles or groups. check out the documentation (documenation Link replace and documenation Link remove)
Here a demo:
(this demo does not use Tiled, but it should work in the same way, just with less layers)
Demo is based on offical demo
document.body.style = 'margin:0;';
var config = {
type: Phaser.AUTO,
width: 22 * 16,
height: 11 * 16,
scene: { preload, create },
banner: false
};
function preload () {
this.load.image('mario-tiles', 'https://labs.phaser.io/assets/tilemaps/tiles/super-mario.png');
}
function create () {
this.add.text(10, 10, 'Click to remove Tile\n( Use shift to replace Tile)')
.setScale(1.25)
.setColor('black')
.setOrigin(0)
.setStyle({fontStyle: 'bold', fontFamily: 'Arial'})
.setDepth(100);
// Load a map from a 2D array of tile indices
var level = [
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], [ 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, ], [ 0, 5, 6, 7, 0, 0, 0, 5, 6, 7, 0, 0, 5, 6, 7, 0, 0, 0, 5, 6, 7, 0, ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], [ 0, 0, 0, 14, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 14, 13, 14, 0, 0, 0, 0, 0, ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ], [ 0, 0, 14, 14, 14, 14, 14, 0, 0, 0, 15, 0, 0, 14, 14, 14, 14, 14, 0, 0, 0, 15, ], [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, ], [ 35, 36, 37, 0, 0, 0, 0, 0, 15, 15, 15, 35, 36, 37, 0, 0, 0, 0, 0, 15, 15, 15, ], [ 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, ] ]
// When loading from an array, make sure to specify the tileWidth and tileHeight
var map = this.make.tilemap({ data: level, tileWidth: 16, tileHeight: 16 });
var tiles = map.addTilesetImage('mario-tiles');
var layer = map.createLayer(0, tiles, 0, 0);
var shiftKey = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SHIFT);
// replace tile is blue tile
const NEW_TILE_INDEX_AFTER_REMOVE = 0
this.input.on('pointerdown', function({x,y}){
// replace Tile, when shift key is pressed
if(shiftKey && shiftKey.isDown){
let selectedTile = layer.getTileAtWorldXY(x,y);
// prevent error if tile doesn't exist
if(selectedTile){
layer.replaceByIndex(selectedTile.index, NEW_TILE_INDEX_AFTER_REMOVE, selectedTile.x, selectedTile.y, 1, 1);
}
} else {
// default action remove tile
layer.removeTileAtWorldXY(x,y);
}
});
}
new Phaser.Game(config);
<script src="https://cdn.jsdelivr.net/npm/phaser#3.55.2/dist/phaser.js"></script>
You just have to check, that you don't try to replace or remove non-existent tiles, this could cause a crashes / errors, and is more frequently an issue with multilayered maps.

Postgresql - Problem when update table with temporary table "You might need to add explicit type casts"

I'm in the middle of developing an app using node.js. my database is PostgreSQL. I tried to create a temporary table and then update my main table with that temporary table. the reason is that i have many records and data that must update every second. i know that one of the must efficient way is that first create a temp table by your data and then update main table with temporary table.
i create temp table successfully but when i try to update my main table i catch "No operator matches the given name and argument types. You might need to add explicit type casts" error.
anybody can help me or hint me how i can solve this problem?
my temporary creation sql is :
CREATE TEMP TABLE temp_binance_tradika_signals
(id, thpars_dati, thpars_vise, thpars_aipi, thpars_code, thpars_site, thpars_owne, thpars_list, thpars_prio, signal_state, signal_date, signal_account, signal_exchange, signal_abbrev, signal_id, signal_uid, signal_andis, signal_coin, signal_base, signal_symbol, signal_side, signal_step_log, signal_step_update, signal_lotstep, signal_lotint_step, signal_pricetick, signal_priceint_tick, signal_time_init, signal_date_alive, signal_dca_buy, signal_dca_sell, signal_amount_type, signal_score, open_percent, open_price, open_amount, open_date, open_trigger, open_prv_abbrev, open_prv_title, open_prv_code, close_percent, close_price, close_amount, close_date, close_trigger, close_period, close_result, close_prv_abbrev, close_prv_title, close_prv_code, price_latest_percent, price_latest_price, price_higest_percent, price_higest_price, price_lowest_percent, price_lowest_price, point_buy_percent, point_buy_price, point_buy_amount, point_buy_date, point_buy_lifelong, point_buy_lifetime, point_buy_bool, point_sell_percent, point_sell_price, point_sell_amount, point_sell_date, point_sell_lifelong, point_sell_lifetime, point_sell_bool, point_place_percent, point_place_price, point_eject_percent, point_eject_price, point_stoploss_percent, point_stoploss_price, point_stoploss_bool, point_expire_percent, point_expire_price, point_expire_bool, point_expire_date, point_expire_duration) AS
VALUES
('100100104895', '2021-07-08 22:59:15', null, null, null, null, null, null, null, 'ALIVE', '2021-07-08 22:59:08', 'Tradika.net', 'Binance', 'SL', 'JIMP_20210708225908_KEYUSDT', 'JIMP_20210708225908_KEYUSDT_SL', 'KEYUSDT_SL', 'KEY', 'USDT', 'KEYUSDT', 'Buy', 0.5, 0.1, 1, 0, 0.000001, 6, 60, '2021-07-08 23:00:15', 0.6, 0.6, null, 1, 0, 0.007369, null, '2021-07-08 22:59:15', 'SIGNAL', 'JIMP', 'Jim Panda Signals', 441, null, null, null, null, null, null, null, null, null, null, 0, 0.007369, 0, 0.007369, 0, 0.007369, -2.5, 0.007185, '1795', null, 600, null, null, -1, 0.007296, null, null, 43200, null, null, -2.3, 0.0072, -2.1, 0.007215, -6, 0.006927, null, 0.25, 0.007388, null, null, 345600),
('100100104896', '2021-07-08 22:59:15', null, null, null, null, null, null, null, 'ALIVE', '2021-07-08 22:59:08', 'Parsika.net', 'Binance', 'MP', 'JIMP_20210708225908_KEYUSDT', 'JIMP_20210708225908_KEYUSDT_MP', 'KEYUSDT_MP', 'KEY', 'USDT', 'KEYUSDT', 'Buy', 1, 0.2, 1, 0, 0.000001, 6, 100, '2021-07-08 23:00:55', 1, 1, null, 1, 0, 0.007369, null, '2021-07-08 22:59:15', 'SIGNAL', 'JIMP', 'Jim Panda Signals', 441, null, null, null, null, null, null, null, null, null, null, 0, 0.007369, 0, 0.007369, 0, 0.007369, -10, 0.006633, '1944', null, 600, null, null, -4, 0.007075, null, null, 86400, null, null, -9, 0.006706, -8.5, 0.006743, -15, 0.006264, null, 0.25, 0.007388, null, null, 345600)
;
and my update SQL from temporary table is :
UPDATE binance_tradika_signals
SET
signal_state = t.signal_state,
price_latest_price = t.price_latest_price
FROM temp_binance_tradika_signals t
WHERE t.id = binance_tradika_signals.id;
any help will be really appreciated.
The solution is :
id must present as integer not string.
the first row data of insert into temp table specify the datatype. so for example if you insert signal_step_log into temp table as JSON datatype, if you define this row as Varchar, int, Bool etc .... you will get an error.
Hope this will be useful.

Fetching host availability to external webpage in Nagios

Is there any possible way to fetch the live availability of host/host group from Nagios monitoring tool (where host/hostgroups are already configured) which can be redirected/captured to an external webpage.
are there any exposed API's to do that, couldn't found a way.
Nagios is on a Linux host.
Any help or info is appreciated.
EDIT1:
I have a hostgroup say for example 'All_prod' in this hostgroup I will be having around 20 linux hosts for all the host there would be some metrics/checks defined (example availability, cpu load, free memory ..etc). Here I want the report of only availability metrics of all the host(example : lets say if in 24 hours if the availability is down for 10 minutes then it should provide me with the report as it was down for 10 minutes in 24 hours or just give me any related info which i can evaluate using data evaluation).
it would be great if there are any API's to fetch that information, which will return the data as json/xml.
You can use the Nagios JSON API. You can use the query builder here http://NAGIOSURL/jsonquery.html.
But, to answer your specific question, the queries for hosts would look like this:
http://NAGIOSURL/cgi-bin/statusjson.cgi?query=host&hostname=localhost
Which will output something similar to the following:
{
"format_version": 0,
"result": {
"query_time": 1497384499000,
"cgi": "statusjson.cgi",
"user": "nagiosadmin",
"query": "host",
"query_status": "released",
"program_start": 1497368240000,
"last_data_update": 1497384489000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"host": {
"name": "localhost",
"plugin_output": "egsdda",
"long_plugin_output": "",
"perf_data": "",
"status": 8,
"last_update": 1497384489000,
"has_been_checked": true,
"should_be_scheduled": false,
"current_attempt": 10,
"max_attempts": 10,
"last_check": 1496158536000,
"next_check": 0,
"check_options": 0,
"check_type": 1,
"last_state_change": 1496158536000,
"last_hard_state_change": 1496158536000,
"last_hard_state": 1,
"last_time_up": 1496158009000,
"last_time_down": 1496158536000,
"last_time_unreachable": 1480459504000,
"state_type": 1,
"last_notification": 1496158536000,
"next_notification": 1496165736000,
"no_more_notifications": false,
"notifications_enabled": true,
"problem_has_been_acknowledged": false,
"acknowledgement_type": 0,
"current_notification_number": 2,
"accept_passive_checks": true,
"event_handler_enabled": true,
"checks_enabled": false,
"flap_detection_enabled": true,
"is_flapping": false,
"percent_state_change": 0,
"latency": 0.49,
"execution_time": 0,
"scheduled_downtime_depth": 0,
"process_performance_data": true,
"obsess": true
}
}
}
And for hostgroups:
http://NAGIOSURL/nagios/cgi-bin/statusjson.cgi?query=hostlist&hostgroup=linux-servers
Which will output something similar to the following:
{
"format_version": 0,
"result": {
"query_time": 1497384613000,
"cgi": "statusjson.cgi",
"user": "nagiosadmin",
"query": "hostlist",
"query_status": "released",
"program_start": 1497368240000,
"last_data_update": 1497384609000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"selectors": {
"hostgroup": "linux-servers"
},
"hostlist": {
"localhost": 8
}
}
}
Hope this helps!
EDIT 1 (To correspond with the question's EDIT 1):
What you're asking for isn't built in by default. You can use the above methods to grab the data for each host (but it sounds like you want it for each service), so again we will use the JSON API found at http://YOURNAGIOSURL/jsonquery.html to grab service data..
http://YOURNAGIOSURL/nagios/cgi-bin/statusjson.cgi?query=service&hostname=localhost&servicedescription=Current+Load
We'll get the following output (something similar, anyway):
{
"format_version": 0,
"result": {
"query_time": 1497875258000,
"cgi": "statusjson.cgi",
"user": "nagiosadmin",
"query": "service",
"query_status": "released",
"program_start": 1497800686000,
"last_data_update": 1497875255000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"service": {
"host_name": "localhost",
"description": "Current Load",
"plugin_output": "OK - load average: 0.00, 0.00, 0.00",
"long_plugin_output": "",
"perf_data": "load1=0.000;5.000;10.000;0; load5=0.000;4.000;6.000;0; load15=0.000;3.000;4.000;0;",
"max_attempts": 4,
"current_attempt": 1,
"status": 2,
"last_update": 1497875255000,
"has_been_checked": true,
"should_be_scheduled": true,
"last_check": 1497875014000,
"check_options": 0,
"check_type": 0,
"checks_enabled": true,
"last_state_change": 1497019191000,
"last_hard_state_change": 1497019191000,
"last_hard_state": 0,
"last_time_ok": 1497875014000,
"last_time_warning": 1497019191000,
"last_time_unknown": 0,
"last_time_critical": 1497018891000,
"state_type": 1,
"last_notification": 0,
"next_notification": 0,
"next_check": 1497875314000,
"no_more_notifications": false,
"notifications_enabled": true,
"problem_has_been_acknowledged": false,
"acknowledgement_type": 0,
"current_notification_number": 0,
"accept_passive_checks": true,
"event_handler_enabled": true,
"flap_detection_enabled": true,
"is_flapping": false,
"percent_state_change": 0,
"latency": 0,
"execution_time": 0,
"scheduled_downtime_depth": 0,
"process_performance_data": true,
"obsess": true
}
}
}
The most important line for what you're trying to do (as far as I understand it) is the perfdata line:
"perf_data": "load1=0.000;5.000;10.000;0; load5=0.000;4.000;6.000;0; load15=0.000;3.000;4.000;0;",
This is the data you'd use to generate whatever custom metrics report you're trying to generate.
Keep in mind this is something that is sort of built in to Nagios XI (not in an exportable format like you're requesting) but the metrics component does allow you to easily drill down and take a look at some metric specific data.
Hope this helps!

Syntax to create a heat map with Highcharts

I would like to do a heat map but without 'time' and integer as X and Y axis (In fact in the example of Highcharts http://jsfiddle.net/9pJhF/ it use csv with integers and data time) but with the strings, something like that:
'Name1','A',3077
'Name2','B',5486
'Name3','A',377
'Name4','B',546
'Name5','A',77
'Name6','B',46
I would like to know how is implemented the data variable when we not use the csv or a trick to circumvent the problem with csv strings.
You can use something like this
xAxis: {
//type: 'category',
categories: ['Name1','Name2','Name3'],
tickInterval: 1,
gridLineWidth: 1,
tickLength: 0,
lineWidth: 0,
min: 0,
max: 2
},
yAxis: {
categories: ['Name1a','Name2a','Name3a'],
tickInterval: 1,
title: {
text: null
},
minPadding: 0,
maxPadding: 0,
startOnTick: false,
endOnTick: false,
tickLength: 0,
lineWidth: 0,
min: 0,
max: 2
},
http://jsfiddle.net/tZ6GP/5
http://jsfiddle.net/tZ6GP/6

Heat map with Highcharts and csv string data [duplicate]

I would like to do a heat map but without 'time' and integer as X and Y axis (In fact in the example of Highcharts http://jsfiddle.net/9pJhF/ it use csv with integers and data time) but with the strings, something like that:
'Name1','A',3077
'Name2','B',5486
'Name3','A',377
'Name4','B',546
'Name5','A',77
'Name6','B',46
I would like to know how is implemented the data variable when we not use the csv or a trick to circumvent the problem with csv strings.
You can use something like this
xAxis: {
//type: 'category',
categories: ['Name1','Name2','Name3'],
tickInterval: 1,
gridLineWidth: 1,
tickLength: 0,
lineWidth: 0,
min: 0,
max: 2
},
yAxis: {
categories: ['Name1a','Name2a','Name3a'],
tickInterval: 1,
title: {
text: null
},
minPadding: 0,
maxPadding: 0,
startOnTick: false,
endOnTick: false,
tickLength: 0,
lineWidth: 0,
min: 0,
max: 2
},
http://jsfiddle.net/tZ6GP/5
http://jsfiddle.net/tZ6GP/6

Resources