GithubHelp home page GithubHelp logo

dani3lsun / apex-plugin-apexsignature Goto Github PK

View Code? Open in Web Editor NEW
14.0 8.0 9.0 132 KB

Oracle APEX Region Plugin - APEX Signature

License: MIT License

JavaScript 100.00%
orclapex oracle-apex-plugin plsql oracle

apex-plugin-apexsignature's Introduction

Oracle APEX Region Plugin - APEX Signature

APEX Community APEX Plugin APEX Built with Love

APEX Signature allows you to draw smooth signatures into a HTML5 canvas and enables you to save the resulting image into database. It is based on JS Framework Signature Pad (https://github.com/szimek/signature_pad).

Changelog

1.1 - Added optional WaitSpinner when saving image into database

1.0.1 - Fixed character set issues with line minWidth/maxWidth decimal numbers

1.0 - Initial Release

Install

  • Import plugin file "region_type_plugin_de_danielh_apexsignature.sql" from source directory into your application
  • (Optional) Deploy the JS files from "server" directory on your webserver and change the "File Prefix" to webservers folder.

Plugin Settings

The plugin settings are highly customizable and you can change:

  • Width - Default width of signature area
  • Height - Default height of signature area
  • Line minWidth - Minimum width of a line. Defaults to 0.5
  • Line maxWidth - Maximum width of a line. Defaults to 2.5
  • Background Color - Background color of signature area. Defaults to "rgba(0,0,0,0)", can be RGB, Hex or color name like white or black
  • Pen color - Color used to draw the lines. Defaults to "black", can be RGB, Hex or color name like white or black
  • PLSQL Code - PLSQL code which saves the resulting image to database tables or collections, default APEX_COLLECTION: "APEX_SIGNATURE"
  • Clear Button JQuery Selector - JQuery Selector to identify the "Clear Button" to clear signature area (#MY_BUTTON_STATIC_ID or .my_button_class)
  • Save Button JQuery Selector - JQuery Selector to identify the "Save Button" to save signature into Database (#MY_BUTTON_STATIC_ID or .my_button_class)
  • Save empty Signature Alert text - Alert text when a User tries to save a empty signature
  • Show Wait Spinner - Show/Hide wait spinner when saving image into database
  • Logging - Whether to log events in the console

Plugin Events

  • Signature cleared - DA event that fires when the signature area get cleared
  • Signature saved to DB - DA event that fires when the signature is successfully save to DB
  • Signature saved to DB Error - DA event that fires when saving to DB had an error

How to use

  • Create a APEX Signature region on target page
  • Choose best fitting plugin attributes (help included)

Save to DB using PL/SQL (default Code of Plugin)

For saving files to DB you can use a PL/SQL function like this:

DECLARE
  --
  l_collection_name VARCHAR2(100);
  l_clob            CLOB;
  l_blob            BLOB;
  l_filename        VARCHAR2(100);
  l_mime_type       VARCHAR2(100);
  l_token           VARCHAR2(32000);
  --
BEGIN
  -- get defaults
  l_filename  := 'signature_' ||
                 to_char(SYSDATE,
                         'YYYYMMDDHH24MISS') || '.png';
  l_mime_type := 'image/png';
  -- build CLOB from f01 30k Array
  dbms_lob.createtemporary(l_clob,
                           FALSE,
                           dbms_lob.session);

  FOR i IN 1 .. apex_application.g_f01.count LOOP
    l_token := wwv_flow.g_f01(i);

    IF length(l_token) > 0 THEN
      dbms_lob.writeappend(l_clob,
                           length(l_token),
                           l_token);
    END IF;
  END LOOP;
  --
  -- convert base64 CLOB to BLOB (mimetype: image/png)
  l_blob := apex_web_service.clobbase642blob(p_clob => l_clob);
  --
  -- create own collection (here starts custom part (for example a Insert statement))
  -- collection name
  l_collection_name := 'APEX_SIGNATURE';
  -- check if exist
  IF NOT
      apex_collection.collection_exists(p_collection_name => l_collection_name) THEN
    apex_collection.create_collection(l_collection_name);
  END IF;
  -- add collection member (only if BLOB not null)
  IF dbms_lob.getlength(lob_loc => l_blob) IS NOT NULL THEN
    apex_collection.add_member(p_collection_name => l_collection_name,
                               p_c001            => l_filename, -- filename
                               p_c002            => l_mime_type, -- mime_type
                               p_d001            => SYSDATE, -- date created
                               p_blob001         => l_blob); -- BLOB img content
  END IF;
  --
END;

Get files from default PL/SQL code

If you use the default PL/SQL code provided with this plugin, the files are saved in a APEX collection called "APEX_SIGNATURE". Select it like that:

SELECT c001    AS filename,
       c002    AS mime_type,
       d001    AS date_created,
       blob001 AS img_content
  FROM apex_collections
 WHERE collection_name = 'APEX_SIGNATURE';

Demo Application

https://apex.oracle.com/pls/apex/f?p=APEXPLUGIN

Preview

apex-plugin-apexsignature's People

Contributors

dani3lsun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apex-plugin-apexsignature's Issues

Attribute "Page Items to Submit" not working

Expected behavior

Chose an Item to Submit, which i'd like to insert into the same table when writing the blob-signature.

Actual behavior

Session-State of the item remains empty when no manual page submit or pl/sql-submit executed

Steps to reproduce the issue

I marked the checkbox for "items to submit" in the plugin attributes. then filled in the item on the region.

APEX version (4.2.6 / 5.0.3)

5.0.2

Used web server / version and platform (ORDS 3.0.3 / Tomcat 7 / Apache 2.4 / Linux x64)

Ords 3.0.8

Used web browser / version and platform (Chrome 48 Mac / Firefox 44 Windows)

Firefox/Chrome

Thanks for this plugin. Works great!

save signature in DB

@ehabwagdy here we go...

Expected behavior

save the signature in DB

Actual behavior

1- what i should to write in "Save Button JQuery Selector" are button name or in button action select defined by dynamic action or what ?
2- i would to make change in attribute plsql to add my table are replace the following part

IF NOT
apex_collection.collection_exists(p_collection_name => l_collection_name) THEN
apex_collection.create_collection(l_collection_name);
END IF;
-- add collection member (only if BLOB not null)
IF dbms_lob.getlength(lob_loc => l_blob) IS NOT NULL THEN
apex_collection.add_member(p_collection_name => l_collection_name,
p_c001 => l_filename, -- filename
p_c002 => l_mime_type, -- mime_type
p_d001 => SYSDATE, -- date created
p_blob001 => l_blob); -- BLOB img content
END IF;

with my table

INSERT INTO CC.IBS_EMP_SIGNATURE (
IBS_NO, EMP_SIGNATURE, BOSTA_ID) 
VALUES ( 44433/* IBS_NO /,
l_blob/ EMP_SIGNATURE /,
4455 / BOSTA_ID */ );
commit;

Steps to reproduce the issue

APEX version (4.2.6 / 5.0.3)

Used web server / version and platform (ORDS 3.0.3 / Tomcat 7 / Apache 2.4 / Linux x64)

Used web browser / version and platform (Chrome 48 Mac / Firefox 44 Windows)

The plug-in doesn't work

Expected behavior

The image inserted in an APEX collection or in a table (added the INSERT SQL statement)

Actual behavior

Nothing happens

Steps to reproduce the issue

Normally draw a signature and press SAVE

APEX version (4.2.6 / 5.0.3)

21.1.6
and
21.2

Used web server / version and platform (ORDS 3.0.3 / Tomcat 7 / Apache 2.4 / Linux x64)

ords-21.3.0.266.1100

Used web browser / version and platform (Chrome 48 Mac / Firefox 44 Windows)

Chrome 96.0.4664.93 (Build ufficiale) (a 64 bit)

I know that this issue has already been posted, but it is in another language (dutch? german?) and I haven't understood anything.

Can you please help me?

Thank you, Angelo Tumedei

Issue with refresh

Expected behavior

Refresh report right away.

Actual behavior

First time not refresh, only second time will refresh.

Steps to reproduce the issue

Step 1. without signature, click save, display message for need signature --- it is correct.
Step 2. draw signature, click save again, display message for need signature again, report not fresh--- it is incorrect
Step 3. without signature, click save again, no message, report is fresh.

APEX version (4.2.6 / 5.0.3)

19.2

Used web server / version and platform (ORDS 3.0.3 / Tomcat 7 / Apache 2.4 / Linux x64)

Used web browser / version and platform (Chrome 48 Mac / Firefox 44 Windows)

Möglichkeit die Unterschrift als JPEG zu speichern

Hello,

is there a way to extend the plugin so that you can save the signature as JPEG?
According to the documentation of signature_pad this should be possible, but I don't know where I can adapt this to make it work with the plugin.

// Returns signature image as data URL (see https://mdn.io/todataurl for the list of possible parameters)
signaturePad.toDataURL(); // save image as PNG
signaturePad.toDataURL("image/jpeg"); // save image as JPEG
signaturePad.toDataURL("image/svg+xml"); // save image as SVG

Many thanks for the help!

Signature Saved to DB Event for DA not working

Expected behavior

Signature Saved to DB event to save signature picture in apex_collections table

Actual behavior

Signature Saved to DB not saving signature in apex_collections table

Steps to reproduce the issue

Create Dynamic Action

image

APEX version (4.2.6 / 5.0.3)

Product Build | 22.2.2

Used web server / version and platform (ORDS 3.0.3 / Tomcat 7 / Apache 2.4 / Linux x64)

Used web browser / version and platform (Chrome 48 Mac / Firefox 44 Windows)

image
image

image

Output to JPG

Expected behavior

I would like the plugin to output the signature to JPG instead of PNG.

Actual behavior

Seems like the default when saving the BLOB is PNG.

Steps to reproduce the issue

Take the normal steps and save to the DB using a simple insert statement.

APEX version (4.2.6 / 5.0.3)

18.1.0.00.45

Used web server / version and platform (ORDS 3.0.3 / Tomcat 7 / Apache 2.4 / Linux x64)

ORDS

Used web browser / version and platform (Chrome 48 Mac / Firefox 44 Windows)

Chrome latest

Question

I am sure that I missed this setting somewhere, but is it possible to have the plugin output a JPG/BLOB instead of PNG?

Missing Page Items to Submit

Expected behavior

Page items are set in session state

Actual behavior

They're blank (see below as to why)

Steps to reproduce the issue

Create a page item with the following attributes:

  • Maintain Session State: Per Request (Memory Only)
    • Note this is default starting in APEX 19.x I think

In the PL/SQL code reference that page item

-- ...
logger.log('p1_id', :p1_id);
-- ...

P1_ID will be null as there is no option to include it as part of the apex.server.plugin call.

Fix will be to include it

APEX version (4.2.6 / 5.0.3)

20.2 (also affects older versions of APEX (19 up I think)

Issue with saving signature as BLOB into table

Expected behavior

Hello there ! I try to save the signature as a blob image to my table, and I followed your code as it is here : #1 and created a Dynamic Action to save the signature directly in my table like this :

DECLARE

CURSOR l_cur_signature IS
SELECT c001 AS filename,
c002 AS mime_type,
d001 AS date_created,
blob001 AS img_content
FROM apex_collections
WHERE collection_name = 'APEX_SIGNATURE';

l_rec_signature l_cur_signature%ROWTYPE;
l_filename VARCHAR2( 100 ) := concat(to_char(LOCALTIMESTAMP, 'DDMMYYYYHH24MISS'),'.jpeg');

BEGIN
-- get original collection from plugin
OPEN l_cur_signature;
FETCH l_cur_signature
INTO l_rec_signature;
CLOSE l_cur_signature;
-- insert into own table
INSERT INTO STAFF_SIGN
(ID,
L_BLOB,
L_FILENAME,
L_MIME_TYPE,
DATE_CREATED,
USER_NAME,
INVOICE_ID,
INVOICE_RECEIVER)
VALUES
(:P38_INVOICE_ID,
l_rec_signature.img_content,
l_filename,
'images/jpeg',
sysdate,
:P0_USER,
:P38_INVOICE_ID,
:P38_INVOICE_RECEIVER);
-- delete original collection
apex_collection.delete_collection(p_collection_name => 'APEX_SIGNATURE');

END;

Actual behavior

but I get an error:
Ajax call returned server error ORA-20102: Application collection APEX_SIGNATURE does not exist for Execute PL/SQL Code. Do you have an idea of what is wrong here ?

APEX version (4.2.6 / 5.0.3)

Apex Release 19.2

Multiple Signatures?

Would your plugin have the capability to store multiple signatures into several different columns on a table? say 4 regions into their own columns?

Issue with saving Signature as Blob

Hello there ! I try to save the signature as a blob image to my table, and I followed your code as it is here : #1 , but I get an error:
Ajax call returned server error ORA-20102: Application collection APEX_SIGNATURE does not exist for Execute PL/SQL Code. Do you have an idea of what is wrong here ?

Apex Version 20.2 and 21.1 Not saved in DB first time in any browser

Expected behavior

All time Signature need to save in DB

Actual behavior

I using the plugin in multiple place in my application but same problem in all the screen is first time user open this screen not saved into DB but same user again updating it's working fine I will change any logic

Steps to reproduce the issue

First time not save into DB (New User) or new system.

APEX version (4.2.6 / 5.0.3)

Apex Version 20.2 and 21.1

Used web server / version and platform (ORDS 3.0.3 / Tomcat 7 / Apache 2.4 / Linux x64)

ORDS

Used web browser / version and platform (Chrome 48 Mac / Firefox 44 Windows)

Chrome and internet edge

try to use your plugin apex-plugin-apexsignature

i try to use your plugin
apex-plugin-apexsignature
but when i try to save sig to my database i get error
Ajax call returned server error ORA-01403: no data found for Execute PL/SQL Code
this line

l_blob := apex_web_service.clobbase642blob(p_clob => l_clob);
can you help me?:)
APEX 19-ORDS

BLOB and other data not saved

Hallo Daniel,
sorry to bother you. Hast Du das schonmal für 20.2 getestet ?
Ich vermute , der "token" wird nicht gefüllt... und darum geht es nicht weiter...

Expected behavior

signature and other data is saved to apex_collectione and/or mytable

Actual behavior

plugin neither saves to collection nor to table

Steps to reproduce the issue

Entry form for visitors. keying in name and telefon and finally signature
all shud be saved to the table Q_BESUCHER (name, filename, img_content (BLOB), mime_type, created_date)
for inserts
test-App on apex.oracle.com available #67820
User: Daniel - Workspace und Passwort separat per Mail...

APEX version (4.2.6 / 5.0.3)

APEX 20.2 on MAXAPEX.COM

Used web server / version and platform (ORDS 3.0.3 / Tomcat 7 / Apache 2.4 / Linux x64)

ORDS 20.3

Used web browser / version and platform (Chrome 48 Mac / Firefox 44 Windows)

Chrome V 86.0,4240.198.

my adjusted pl/sql of the plugin:

DECLARE

l_collection_name VARCHAR2(100);
l_clob CLOB;
l_blob BLOB;
l_filename VARCHAR2(100);
l_mime_type VARCHAR2(100);
l_token VARCHAR2(32000);
l_id VARCHAR2(10); -- PK of the visitor of table Q_BESUCHER

BEGIN
-- get defaults
l_filename := 'signature_' ||
to_char(SYSDATE,
'YYYYMMDDHH24MISS') || '.png';
l_mime_type := 'image/png';
-- build CLOB from f01 30k Array
dbms_lob.createtemporary(l_clob,
FALSE,
dbms_lob.session);

l_id := :P2_ID;

FOR i IN 1 .. apex_application.g_f01.count LOOP
l_token := wwv_flow.g_f01(i);

IF length(l_token) > 0 THEN
  dbms_lob.writeappend(l_clob,
                       length(l_token),
                       l_token);
END IF;

END LOOP;

-- convert base64 CLOB to BLOB (mimetype: image/png)
l_blob := apex_web_service.clobbase642blob(p_clob => l_clob);

-- create own collection (here starts custom part (for example a Insert statement))
-- INSERT INTO Q_BESUCHER_UNTERSCHRIFTEN(besucher_fk,filename, mime_type, img_content, date_created)
-- VALUES (l_id, l_filename,l_mime_type, l_blob, sysdate) ;

-- collection name
l_collection_name := 'APEX_SIGNATURE';
-- check if exist
IF NOT
apex_collection.collection_exists(p_collection_name => l_collection_name) THEN
apex_collection.create_collection(l_collection_name);
END IF;
-- add collection member (only if BLOB not null)
IF dbms_lob.getlength(lob_loc => l_blob) IS NOT NULL THEN
apex_collection.add_member(p_collection_name => l_collection_name,
p_c001 => l_filename, -- filename
p_c002 => l_mime_type, -- mime_type
p_c003 => :P2_ID, -- PK of Entry form
p_d001 => SYSDATE, -- date created
p_blob001 => l_blob); -- BLOB img content
END IF;

END;

Glad if you cud look into it - Danke Dir !!!
Gruss
Bernhard

Support to return data when signature is saved

Background: See #13 for Page Items to Submit and the session state option.

The use-case I have is the following:

  • Save the signature into a collection
  • When saving into a collection I want the seq_id and store this in a page item (let's sage p1_seq_id
  • Use that p1_seq_is as part of my regular page submit process which I'll then get the blob from the apex_collection

In order to do this need to pass a data object back in the PL/SQL code. Ex:

-- ...
apex_json.open_object;
apex_json.write('seqId', l_seq_id); 
apex_json.close_object; 
-- ...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.