Fix DB observationPage

This commit is contained in:
Wappler 2025-01-07 20:26:41 -06:00
parent 5dbcd4daa5
commit b7d987478a
22 changed files with 366 additions and 155 deletions

View File

@ -0,0 +1,15 @@
exports.up = function(knex) {
return knex.schema
.table('da', async function (table) {
table.string('db_signatureData');
})
};
exports.down = function(knex) {
return knex.schema
.table('da', async function (table) {
table.dropColumn('db_signatureData');
})
};

View File

@ -0,0 +1,15 @@
exports.up = function(knex) {
return knex.schema
.table('da', async function (table) {
table.renameColumn('db_TrainerSelected', 'db_trainerSelected');
})
};
exports.down = function(knex) {
return knex.schema
.table('da', async function (table) {
table.renameColumn('db_trainerSelected', 'db_TrainerSelected');
})
};

View File

@ -0,0 +1,15 @@
exports.up = function(knex) {
return knex.schema
.table('da', async function (table) {
table.renameColumn('DSPShortCode', 'dspShortCode');
})
};
exports.down = function(knex) {
return knex.schema
.table('da', async function (table) {
table.renameColumn('dspShortCode', 'DSPShortCode');
})
};

View File

@ -0,0 +1,21 @@
exports.up = function(knex) {
return knex.schema
.table('da', async function (table) {
table.dropColumn('db_employeeID');
table.dropColumn('getStartTime');
table.dropColumn('getEndTime');
table.dropColumn('getStationCode');
})
};
exports.down = function(knex) {
return knex.schema
.table('da', async function (table) {
table.string('db_employeeID', 255);
table.string('getStartTime', 255);
table.string('getEndTime', 255);
table.string('getStationCode', 255);
})
};

View File

@ -0,0 +1,15 @@
exports.up = function(knex) {
return knex.schema
.table('da', async function (table) {
table.text('db_signatureData').alter();
})
};
exports.down = function(knex) {
return knex.schema
.table('da', async function (table) {
table.string('db_signatureData', 255).alter();
})
};

View File

@ -0,0 +1,13 @@
exports.up = function(knex) {
return knex.schema
.createTable('da_meta', async function (table) {
table.increments('id');
})
};
exports.down = function(knex) {
return knex.schema
.dropTable('da_meta')
};

View File

@ -216,6 +216,15 @@
],
"services": {}
}
},
"ssh_key": {
"ertfastfiller_ed25519": {
"ssh-key-file": "/.wappler/.ssh/ertfastfiller_ed25519.pub",
"name": "ertfastfiller_ed25519",
"type": "ed25519",
"fingerprint": "64:50:e4:41:ed:26:78:df:fb:27:4a:cf:a7:58:02:2a",
"id": 44250508
}
}
}
}

View File

@ -11,7 +11,10 @@
"password": "3qx02yqcNDOuQZUC",
"database": "db_training"
},
"tz": "utc"
"tz": "utc",
"meta": {}
},
"fileName": "MyDB.json"
"fileName": "MyDB.json",
"actionFilePath": "file:///C:/WapplerProjects/app/modules/connections/MyDB.json",
"serverType": "node"
}

View File

@ -19,7 +19,7 @@
"nullable": false
}
},
"DSPShortCode": {
"dspShortCode": {
"db": {
"type": "string",
"maxLength": 255,
@ -43,39 +43,7 @@
"nullable": true
}
},
"db_employeeID": {
"db": {
"type": "string",
"maxLength": 255,
"primary": false,
"nullable": true
}
},
"getStartTime": {
"db": {
"type": "string",
"maxLength": 255,
"primary": false,
"nullable": true
}
},
"getEndTime": {
"db": {
"type": "string",
"maxLength": 255,
"primary": false,
"nullable": true
}
},
"db_TrainerSelected": {
"db": {
"type": "string",
"maxLength": 255,
"primary": false,
"nullable": true
}
},
"getStationCode": {
"db_trainerSelected": {
"db": {
"type": "string",
"maxLength": 255,
@ -98,6 +66,26 @@
"primary": false,
"nullable": true
}
},
"db_signatureData": {
"db": {
"type": "text",
"maxLength": 65535,
"primary": false,
"nullable": true
}
}
},
"db": {}
},
"da_meta": {
"columns": {
"id": {
"db": {
"type": "increments",
"primary": true,
"nullable": false
}
}
},
"db": {}

View File

@ -1,33 +1,64 @@
{
"meta": {
"options": {
"linkedFile": "/views/index0.ejs",
"linkedForm": "serverconnectform1"
},
"$_POST": [
{
"type": "text",
"fieldName": "ertDriveDate",
"name": "ertDriveDate"
},
{
"type": "text",
"fieldName": "db_fullName",
"name": "db_fullName"
},
{
"type": "text",
"name": "db_employeeID"
},
{
"type": "text",
"name": "db_TrainerSelected"
},
{
"type": "text",
"fieldName": "getStationCode",
"name": "getStationCode"
},
{
"type": "text",
"fieldName": "db_licenseNumber",
"name": "db_licenseNumber"
},
{
"type": "text",
"fieldName": "db_state",
"name": "db_state"
},
{
"type": "text",
"fieldName": "dspShortCode",
"name": "dspShortCode"
},
{
"type": "text",
"fieldName": "db_stateIssue",
"name": "db_stateIssue"
},
{
"type": "text",
"fieldName": "db_trainerSelected",
"name": "db_trainerSelected"
},
{
"type": "text",
"fieldName": "db_signatureData",
"name": "db_signatureData"
},
{
"type": "text",
"fieldName": "getStartTime",
"name": "getStartTime"
},
{
"type": "text",
"fieldName": "getEndTime",
"name": "getEndTime"
}
]
},
@ -46,7 +77,6 @@
"column": "ertDriveDate",
"type": "text",
"value": "{{$_POST.ertDriveDate}}",
"condition": "{{TIMESTAMP.formatDate('MM-dd-yyyy', false)}}",
"recid": 1
},
{
@ -56,45 +86,45 @@
"value": "{{$_POST.db_fullName}}",
"recid": 2
},
{
"table": "da",
"column": "db_employeeID",
"type": "text",
"value": "{{$_POST.db_employeeID}}",
"recid": 3
},
{
"table": "da",
"column": "db_TrainerSelected",
"type": "text",
"value": "{{$_POST.db_TrainerSelected}}",
"recid": 4
},
{
"table": "da",
"column": "getStationCode",
"type": "text",
"value": "{{$_POST.getStationCode}}",
"recid": 5
},
{
"table": "da",
"column": "db_licenseNumber",
"type": "text",
"value": "{{$_POST.db_licenseNumber}}",
"recid": 6
"recid": 3
},
{
"table": "da",
"column": "db_state",
"type": "text",
"value": "{{$_POST.db_state}}",
"recid": 4
},
{
"table": "da",
"column": "db_signatureData",
"type": "text",
"value": "{{$_POST.db_signatureData}}",
"recid": 5
},
{
"table": "da",
"column": "dspShortCode",
"type": "text",
"value": "{{$_POST.dspShortCode}}",
"recid": 6
},
{
"table": "da",
"column": "db_trainerSelected",
"type": "text",
"value": "{{$_POST.db_trainerSelected}}",
"recid": 7
}
],
"table": "da",
"returning": "id",
"query": "insert into `da` (`db_TrainerSelected`, `db_employeeID`, `db_fullName`, `db_licenseNumber`, `db_state`, `ertDriveDate`, `getStationCode`) values (?, ?, ?, ?, ?, ?, ?)",
"query": "insert into `da` (`db_fullName`, `db_licenseNumber`, `db_signatureData`, `db_state`, `db_trainerSelected`, `dspShortCode`, `ertDriveDate`) values (?, ?, ?, ?, ?, ?, ?)",
"params": [
{
"name": ":P1",
@ -111,31 +141,31 @@
{
"name": ":P3",
"type": "expression",
"value": "{{$_POST.db_employeeID}}",
"value": "{{$_POST.db_licenseNumber}}",
"test": ""
},
{
"name": ":P4",
"type": "expression",
"value": "{{$_POST.db_TrainerSelected}}",
"value": "{{$_POST.db_state}}",
"test": ""
},
{
"name": ":P5",
"type": "expression",
"value": "{{$_POST.getStationCode}}",
"value": "{{$_POST.db_signatureData}}",
"test": ""
},
{
"name": ":P6",
"type": "expression",
"value": "{{$_POST.db_licenseNumber}}",
"value": "{{$_POST.dspShortCode}}",
"test": ""
},
{
"name": ":P7",
"type": "expression",
"value": "{{$_POST.db_state}}",
"value": "{{$_POST.db_trainerSelected}}",
"test": ""
}
]

71
app/api/myQuery.json Normal file
View File

@ -0,0 +1,71 @@
{
"meta": {
"$_GET": [
{
"type": "text",
"name": "sort"
},
{
"type": "text",
"name": "dir"
}
]
},
"exec": {
"steps": {
"name": "Myquery",
"module": "dbconnector",
"action": "select",
"options": {
"connection": "MyDB",
"sql": {
"type": "select",
"columns": [],
"params": [],
"table": {
"name": "da"
},
"primary": "id",
"joins": [],
"query": "select * from `da`"
}
},
"output": true,
"meta": [
{
"type": "number",
"name": "id"
},
{
"type": "text",
"name": "dspShortCode"
},
{
"type": "text",
"name": "ertDriveDate"
},
{
"type": "text",
"name": "db_fullName"
},
{
"type": "text",
"name": "db_trainerSelected"
},
{
"type": "text",
"name": "db_licenseNumber"
},
{
"type": "text",
"name": "db_state"
},
{
"type": "text",
"name": "db_signatureData"
}
],
"outputType": "array"
}
}
}

View File

@ -1,3 +0,0 @@
{
"exec": {}
}

View File

@ -17,7 +17,7 @@
"module": "dbconnector",
"action": "select",
"options": {
"connection": "DB",
"connection": "MyDB",
"sql": {
"type": "select",
"columns": [],
@ -25,7 +25,7 @@
"table": {
"name": "da"
},
"primary": "ID",
"primary": "id",
"joins": [],
"query": "select * from `da`",
"orders": []
@ -35,32 +35,35 @@
"meta": [
{
"type": "number",
"name": "ID"
"name": "id"
},
{
"type": "text",
"name": "dspShortCode"
},
{
"type": "text",
"name": "ertDriveDate"
},
{
"type": "text",
"name": "db_fullName"
},
{
"type": "text",
"name": "db_trainerSelected"
},
{
"type": "text",
"name": "db_licenseNumber"
},
{
"type": "text",
"name": "db_stateIssue"
},
{
"type": "number",
"name": "db_employeeID"
"name": "db_state"
},
{
"type": "text",
"name": "owner"
},
{
"type": "text",
"sub": [],
"name": "db_SignatureData"
"name": "db_signatureData"
}
],
"outputType": "array"

View File

@ -1,5 +1,10 @@
{
"routes": [
{
"path": "/unsuccessful",
"page": "unsuccessful",
"layout": "main"
},
{
"path": "/index0",
"page": "index0",

View File

@ -11,7 +11,10 @@
"password": "3qx02yqcNDOuQZUC",
"database": "db_training"
},
"tz": "utc"
"tz": "utc",
"meta": {}
},
"fileName": "MyDB.json"
"fileName": "MyDB.json",
"actionFilePath": "file:///C:/WapplerProjects/app/modules/connections/MyDB.json",
"serverType": "node"
}

View File

@ -61,6 +61,43 @@ dmx.config({
}
],
"outputType": "array"
},
"data_view1": {
"meta": [
{
"type": "number",
"name": "id"
},
{
"type": "text",
"name": "dspShortCode"
},
{
"type": "text",
"name": "ertDriveDate"
},
{
"type": "text",
"name": "db_fullName"
},
{
"type": "text",
"name": "db_trainerSelected"
},
{
"type": "text",
"name": "db_licenseNumber"
},
{
"type": "text",
"name": "db_state"
},
{
"type": "text",
"name": "db_signatureData"
}
],
"outputType": "array"
}
}
});

View File

@ -418,7 +418,7 @@
</form>
-->
</div>
<form id="pouchconnectform1">
<form id="myDBSeverForm1" is="dmx-serverconnect-form" method="post" action="/api/myInsert" dmx-on:success="browser1.goto('/success',true,'Success')" dmx-on:error="">
<div class="form-group mb-3 row">
<label for="inp_ertDriveDate" class="col-sm-2 col-form-label">Date</label>
<div class="col-sm-3">
@ -428,7 +428,7 @@
<div class="form-group mb-3 row">
<label for="inp_owner1" class="col-sm-2 col-form-label">Company Name</label>
<div class="col-sm-3">
<select id="inp_db_dspShortCode" class="form-select" dmx-bind:options="dspListJson.data.DSPCompanies" optionvalue="dspShortCode" optiontext="dspName.titlecase()" name="dspShortCode" dmx-bind:value="selectedValue">
<select id="inp_db_dspShortCode" class="form-select" dmx-bind:options="dspListJson.data.DSPCompanies" optionvalue="dspShortCode" optiontext="dspName.titlecase()" name="dspShortCode">
</select>
</div>
@ -448,14 +448,14 @@
<div class="form-group mb-3 row">
<label for="inp_db_stateIssue" class="col-sm-2 col-form-label">State</label>
<div class="col-sm-3">
<select id="inp_db_stateIssue" class="form-select" dmx-bind:options="stateJSON.data.states" optiontext="name" name="db_stateIssue" dmx-bind:value="selectedValue" optionvalue="abbreviation">
<select id="inp_db_stateIssue" class="form-select" dmx-bind:options="stateJSON.data.states" optiontext="name" name="db_state" optionvalue="abbreviation">
</select>
</div>
</div>
<div class="form-group mb-3 row">
<label for="inp_db_trainerSelected" class="col-sm-2 col-form-label">Trainer</label>
<div class="col-3">
<select id="inp_db_trainerSelected" class="form-select" dmx-bind:options="trainerJSON.data.Trainer" name="db_trainerSelected" optiontext="Name" optionvalue="ID" dmx-bind:value="selectedValue">
<select id="inp_db_trainerSelected" class="form-select" dmx-bind:options="trainerJSON.data.Trainer" name="db_trainerSelected" optiontext="Name" optionvalue="Login">
</select>
</div>
@ -474,14 +474,14 @@
</div>
</div>
<div class="row justify-content-center border border-2">
<h4 dmx-hide="!pouchconnectform1.db_signatureData.value.isEmpty()" class="text-center">Waiting for signature</h4>
<h4 class="text-center">Waiting for signature</h4>
<div class="row justify-content-center">
<img width="125" height="100" class="align-self-start bg-opacity-25 bg-light-subtle w-75" dmx-bind:data-srcset="" dmx-bind:data-src="pouchconnectform1.db_signatureData.value" dmx-bind:src="signatureEncoded.value" dmx-show="!pouchconnectform1.db_signatureData.value.isEmpty()" alt="SignatureCapture">
<img width="100" class="align-self-start bg-opacity-25 bg-light-subtle w-75" dmx-bind:data-srcset="" dmx-bind:data-src="pouchconnectform1.db_signatureData.value" dmx-bind:src="signatureEncoded.value" dmx-show="!pouchconnectform1.db_signatureData.value.isEmpty()" alt="SignatureCapture" height="75" id="imgSignatureDataCapture">
</div>
</div>
<p></p>
<button id="btn1" class="btn btn-lg text-bg-primary text-warning fw-bold text-capitalize" data-bs-toggle="modal" data-bs-target="#SignatureModal1"><span style="font-weight: normal;">Sign</span></button><button id="btn5" class="btn btn-lg text-warning fw-bold text-capitalize text-bg-success ms-4" data-bs-target="#SignatureModal1" dmx-on:click="pouchInsert.run();modalsuccess.show()" dmx-bind:disabled="inp_db_fullName.value.isEmpty()||inp_db_licenseNumber.value.isEmpty()">Save&nbsp;</button>
<button id="btn1" class="btn btn-lg text-bg-primary text-warning fw-bold text-capitalize" data-bs-toggle="modal" data-bs-target="#SignatureModal1"><span style="font-weight: normal;">Sign</span></button><button id="btn5" class="btn btn-lg text-warning fw-bold text-capitalize text-bg-success ms-4" data-bs-target="#SignatureModal1" dmx-on:click="myDBSeverForm1.submit()">Save&nbsp;</button>
<button id="btn6" class="btn" type="reset">reset</button>
</form>
@ -492,36 +492,6 @@
</div>
</div>
<div class="container" dmx-show="toggleSignatureDataEncoded.checked">
<table class="table table-striped table-sm">
<thead>
<tr>
<th></th>
<th>full name</th>
<th>license number</th>
<th>Date</th>
<th>signature data</th>
<th>trainer&nbsp;</th>
<th>state&nbsp;</th>
<th>Dummy1</th>
</tr>
</thead>
<tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="pouchdbview1.data" id="tableRepeat3">
<tr>
<td dmx-text="_id"></td>
<td dmx-text="db_fullName"></td>
<td dmx-text="db_licenseNumber"></td>
<td dmx-text="db_employeeID"></td>
<td dmx-text="db_signatureData.substring(0, 15)">
</td>
<td dmx-text="db_trainerSelected"></td>
<td dmx-text="db_stateName"></td>
<td dmx-text="dummy1"></td>
</tr>
</tbody>
</table>
</div>
<script src="/PDF/pdfLibSignature.js"></script>

View File

@ -1,4 +1,5 @@
<!-- Wappler include head-page="layouts/main" fontawesome_5="cdn" bootstrap5="local" is="dmx-app" id="observationPage" appConnect="local" components="{dmxBootstrap5TableGenerator:{},dmxMasonry:{},dmxFormatter:{},dmxBootstrap5Popovers:{},dmxBootstrap5Toasts:{},dmxDataTraversal:{},dmxStateManagement:{},dmxDatastore:{},dmxValidator:{},dmxBootstrap5Offcanvas:{},dmxBootstrap5Modal:{},dmxBootstrap5Navigation:{},dmxBootstrap5Tooltips:{},dmxBootbox5:{},dmxNotifications:{},dmxPouchDB:{},dmxBootstrap5Alert:{},dmxBootstrap5Collapse:{}}" jquery_slim_35="cdn" moment_2="cdn" -->
<dmx-serverconnect id="MyserverconnectQuery" url="/api/myQuery"></dmx-serverconnect>
<div is="dmx-pouchdb-detail" id="pouchdbdetail2" dmx-bind:docid="select1.value" db="dbCouch" collection="db_training"></div>
<dmx-data-view id="data_view2" dmx-bind:data="datastore1.data" filter="!numSection.isEmpty()&amp;&amp;!pointValue.isEmpty()"></dmx-data-view>
<dmx-datastore id="datastore1"></dmx-datastore>
@ -16,12 +17,6 @@
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div id="conditional1" is="dmx-if">
<div class="alert" id="alert1" is="dmx-bs5-alert" role="alert" show="true" type="danger">
<p>The data is outdated. Please click REFRESH</p><button id="btn3" class="btn btn-secondary" dmx-on:click="pouchdbdetail1.refresh()">REFRESH DATA</button>
</div>
</div>
<p>Modal body text goes here.</p>
<form id="form2">
<div class="form-group mb-3 row">
@ -235,7 +230,7 @@
<div class="row">
<div class="col-3 align-self-center">
<select id="select1" class="form-select" optiontext="db_fullName" optionvalue="_id" dmx-bind:disabled="datastore1.data.hasItems()" dmx-bind:options="pouchdbview1.data" dmx-on:changed="toasts1.showSimple({message: selectedValue, delay: 2000});pouchdbdetail2.select(selectedValue)">
<select id="select1" class="form-select" optiontext="db_fullName" optionvalue="id" dmx-bind:disabled="datastore1.data.hasItems()" dmx-bind:options="MyserverconnectQuery.data.Myquery" dmx-on:changed="toasts1.showSimple({message: selectedIndex, delay: 2000})">
</select>
<select id="select2" class="form-select" dmx-bind:options="dspListJson.data.DSPCompanies" optiontext="dspName.titlecase()" optionvalue="dspShortCode" dmx-bind:value="selectedValue" name="getDSPShortCode">
</select>
@ -249,28 +244,23 @@
<th>Name</th>
<th>License No.</th>
<th>Issue State</th>
<th>Employee No.</th>
<th>Trainer Login</th>
</tr>
</thead>
<tbody is="dmx-repeat" dmx-generator="bs5table" id="tableRepeat4" dmx-bind:repeat="data_view1.data">
<tr>
<td dmx-bs-tooltip="('Record # '+_id)" data-bs-trigger="hover" data-bs-placement="top" dmx-text="db_fullName"></td>
<td dmx-bs-tooltip="('Record # '+id)" data-bs-trigger="hover" data-bs-placement="top" dmx-text="db_fullName"></td>
<td dmx-text="db_licenseNumber"></td>
<td dmx-class:bg-danger="db_stateName.isEmpty()" dmx-text="db_stateName"></td>
<td dmx-text="db_employeeID"></td>
<td dmx-text="db_state"></td>
<td dmx-text="data_view1.data[0].db_trainerSelected"></td>
</tr>
</tbody>
</table>
<dmx-data-view id="data_view1" dmx-bind:data="pouchdbview1.data" filter="_id==select1.value"></dmx-data-view>
<dmx-data-view id="data_view1" dmx-bind:data="MyserverconnectQuery.data.Myquery" filter="id==select1.value"></dmx-data-view>
</div>
</div>
<div class="row">
<div class="col">
<div id="conditional2" is="dmx-if" dmx-bind:condition="pouchdbdetail1.stale">
<div class="alert" id="alert2" is="dmx-bs5-alert" role="alert">
<p>!!! Use this alert to show if its a stale db read and refresh</p>
</div>
</div>
<p>status messages: {{select1.value}}</p>
<div class="row">
<button id="btn2" class="btn bg-warning" data-bs-toggle="modal" data-bs-target="#saveObservationResults">Finalize &amp; Print PDF Results</button>

View File

@ -4,15 +4,12 @@
<div class="container wappler-block p-5">
<div class="row text-center p-5">
<div class="col">
<svg xmlns="http://www.w3.org/2000/svg" width="150" height="150" fill="#51c42b" class="bi bi-check-circle-fill" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"></path>
</svg>
<h1 class="mt-4">All Done<br>Stay on this page<br>Wait for further instruction</h1>
<h1 class="text-bg-success">All good.<br>Data saved okay<a href="/index0" internal="true" dmx-style:color="'white'">.</a></h1>
<h1>
<hr>Stay on this page<br>Wait for further instruction
</h1>
<p class="lead">Thank you for filling out the forms.</p>
<a class="btn btn-primary" href="/">Return home</a>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/pouchdb@9.0.0/dist/pouchdb.min.js"></script>
<script src="/PDF/dummyFunctions.js"></script>
</div>

14
views/unsuccessful.ejs Normal file
View File

@ -0,0 +1,14 @@
<!-- Wappler include head-page="layouts/main" fontawesome_5="cdn" bootstrap5="local" is="dmx-app" id="success" appConnect="local" components="{dmxStateManagement:{}}" -->
<meta name="ac:route" content="/unsuccessful">
<div class="container wappler-block p-5">
<div class="row text-center p-5">
<div class="col">
<h1 class="text-bg-danger">Hmm. Something wrong happen.</h1>
<h4>(Don't worry we'll fix it)</h4>
<h1>Please let a Trainer know<a href="/index0" internal="true" dmx-style:color="'black'">.</a></h1>
<p class="lead">Thank you for filling out the forms.</p>
</div>
</div>
</div>