declare _action varchar(45);
if json_valid(inJson) and inJson ->> '$.action' is not null then
set _action = inJson ->> '$.action';
else
set _action = '';
end if;
if _action = '' then
select 'dbr.pageview';
select inUUID as "uuid:";
-- Upload image to server side files
select 'dbr.upload.options', 'noreplace', 1;
select 'dbr.upload.options', 'add_time', 1;
select 'dbr.upload.options', 'accepted_files', '.jpg,.jpeg,.png';
select 'dbr.upload.options', 'title', 'Click here to upload node image';
select 'dbr.upload','/path/to/dbr/user/MapImages','sp_DBR_upload_file', inUUID;
select 'dummy';
select 'dbr.report', 'sp_DBR_nodes_history', '[form_action]', 'inJson=p_json';
select 'dbr.form', 'json', 'inPostJson';
select 'dbr.form', 'start', 'my_form'; -- The form starts here
select 'form_action', json_object(
'uuid',
inUUID,
'action',
'new_history'
) as p_json;
select 'dbr.form', 'textarea', 'descr', 'Description:';
select 'dummy';
select 'dbr.form', 'submit', 'Add new Node History';
select 'dbr.form', 'end'; -- The form ends here
select 'dummy';
elseif _action = 'new_history' then
set @uuid = inJson ->> "$.uuid";
set @in_descr = inPostJson ->> "$.in_descr";
select
description into @is_descr_empty
from AhaInfo.nodes_description
where uuid = @uuid;
if @is_descr_empty is null then
update AhaInfo.nodes_description
set description = CONCAT('[\"', REPLACE(@in_descr, 'user/', ''), '\"]')
where uuid = @uuid;
else
update AhaInfo.nodes_description
set description = CONCAT('[\"', replace(@in_descr, 'user/', ''), '\",', SUBSTRING(description, 2))
where uuid = @uuid;
end if;
select 'dbr.text', 'History for node successfully added.';
select 'dbr.text', '';
select 'dbr.pageview';
select
*
from AhaInfo.nodes_description
where uuid = @uuid;
-- select 'dbr.report', 'sp_DBR_merchant_home_page', 'inJson=p_json';
-- select 'dbr.button', 'Home Page';
-- select json_object(
-- 'action', ''
-- ) as p_json;
end if;