BACKSTORY
I am building a module that extends a .NET web app that I did not develop. All I know is that if I create a "view.ascx" file, populate it with the appropriate vb .net html and javascript code and put that file in the right place, that some good stuff is going to happen. Im having issues though.
My Goal, enable a web based TWAIN scanning utility.(I'm using a scanner to get a picture of the sole of the foot of a patient.) The scanning plugin (DynamicWebTwain) has the ability to set some http form fields and call a post method to an action page (aspx) file. The action page should then use those fields to store the file and make write a record in SQL with a pointer to the uplaoaded file destination and associated that with the patient chart id. The uploaded file name, storage path etc are all composed of data that sits in variables in the application mentioned above.
ISSUES
The view.ascx file (which encodes the reading of the application variable instances, the plugin embedding and the JS triggers) is loaded one time when the application loads. Therefore, the patient specific information, captured in a form is not actually available unless I reload the page. This of course is because you cant specify the patient demographics before the application is opened.
As a result of item 1. I am unable to set form fields with meaningful information and as such cannot pass it to the actionpage.aspx and upload and save everything properly in the filesystem and DB in the first pass.
WORKFLOW SUMMARY
Patient enters, dr loads web app. at this time the variables pertaining to the Patient are empty. the control is not reloaded at any point and those variables remain unchanged (blank) in my module as the Dr. navigates through the app. Dr. puts in PT name and DOB and clicks next which goes to the Scanner form.
Scanner module has not refreshed variable data. Dr. Takes scan via plugin, triggers JS to set and drive scanner, is presented with a Save button, Save button sets form fields and calls the action page.
ATTEMPTED WORKAROUNDS
Point the action page to the ascx file, in other words call myself - FAIL - Would love a good explanation of why this is not OK.
Re-evaluate tha variables within the actionpage.aspx file. ( well to do that i tried using the same references in the headers as found in my view.ascx file
"<%# Control Language="vb" AutoEventWireup="false"
Inherits="DriveWorks.Live.Parts.Modules.LiveModuleControl" %>
<%# Import Namespace="DriveWorks.Live.Parts.Theme" %>"
And of course this did not fly - FAIL - If I could somehow talk to the application again from the actionpage.aspx file, i.e. call another ASCX page that would revaluate the variables and give me back the results, then that might solve my problems. Would love a good explanation on feasibility and approach with code samples.
Still green please be kind and Mind you the web app that I am building the module for is a black box to me..
Related
My meaning is I press a button (in the webpage) which executes an addEventListener() function. After that, the function changes some JSON data and saves that. Then, in the future, people could access the JSON data.
An example is a login/register page deployed using Netlify.
So I first have a simple file system:
login-register-project:
- index.html
- db.json
- login-page:
- login.html
- login.js
- register-page:
- register.html
- register.js
- home-page:
- hub.html
- hub.js
Inside db.json has:
{
"username":{
"pw":"password",
"login_bool":false
}
}
home-page is the page displayed after login or register is complete.
index.html sends the user to register-page's register.html. There would then be a login instead option in there, which the user can use to choose either to register or login.
After filling in register.html's register details and clicking the "sign in" button, register.js would then put the data into db.json, sets login_bool to true and redirect the user to https://websitename.com/home-page/hub.html?{user's usrname}|{user's pw}
Alternatively, after filling in login.html's login details and clicking the "login" button, login.js would then set login_bool to true and redirect the user to https://websitename.com/home-page/hub.html?{user's usrname}|{user's pw}.
hub.html then checks whether the username and password data given were correct and checks if login_bool was set to true. If all information is correct, the website displays its contents. If login_bool was set to false or the username/password were incorrect, the user will be redirected to index.html
BTW, there will be a "log out" button in hub.html that lets users to "log out" and sets login_bool to false.
Now, if this works, then how would I retrieve the data from the JSON file deployed and copy it to my JSON file so that when I deploy a new update, no data will be lost?
If I missed anything/my information was incorreect/you require furthur information, please tell me.
Thanks to anyone who answers.
Short answer: Your logic is correct but that's not how it works on Netlify. I'd rather advise using an external database to store this data.
Long answer: Netlify's deploys are immutable once published. This means that, any change that you wish to push to your site's code, would have to trigger a new deploy and upload those changes. While you can possibly use Netlify API to handle updating your site on-the-fly (like on a click of the button), this would be an overkill for the task you're trying to achieve, not to mention a bit difficult. The flow would look something like:
Fetch the list of files in the current deploy
Hash the new files that you wish to upload as SHA1
Create a new deploy with the list of previous files + new file that you wish to upload
Upload the new file
Wait a few seconds for the deploy to go live
Fetch the data from the updated site
Even if you manage to do all this, this would definitely be much slower, not to mention difficult to manage in case of concurrent read/writes.
Preface: I'm a novice programmer at best.
I'm trying to make a github pages page and I'd like it to store some data on a JSON within the same repo. All it needs to do is wait for a button press on the webpage and then increment a value in the JSON file, then write the new value to the JSON in the repo.
testCounter.html which contains the script
<!DOCTYPE html>
<button>Increment</button>
<br>
<div id="counter">...</div>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.0.min.js"></script>
<script>
for(;;){
var counterJSON = JSON.parse(/*get json file here*/);
//update the number shown on the page
//check for button click
counterJSON.counter++;
//write updated JSON file
}
</script>
testJSON.json which contains the data for the counter
{"counter": 0}
I'd like any user with the page open to see it continuously update even if they didn't click the button, thus the infinite loop. Any time the button is clicked, the number should be increased by 1 and written to the JSON file.
Github Pages is designed for hosting simple static websites and supports no form of server-side code, so there is no means to do this which is either trivial or doesn't have other issues.
Github does have an API so you could possibly build a single page application which allows someone to OAuth against Github and then issue a pull request which updates the counter when you approve it. This is unlikely to be practical for your needs.
You should find a hosting service more suitable to your needs.
You can use smart contracts in blockchain for writing and accessing data from remote on gh static pages. Not only Ethereum.
Currently I'm working on a project where a user enters a lot of data constantly for a hour long window. I'm looking to have one user control all the data via some control panel and then have a link they can distribute to other users that will allow them to view that data without the ability to edit it.
Right now I'm doing some extremely weird methods. I have an XHR request on the control page that fires whenever a field is finished being edited. From there the data is sent to a php file that converts the data into a simple text file. Then the distributed link file will load that file one time and translate it into the necessary format.
Some potential problems I've run into are it seems odd that I'm sending starting as javascript data then going to a php file then to a text file then translating the data all the way back into javascript data again. Another problem I've come into is I'm not sure of a way to force users to reload the page when a field is edited in the control panel after the user has opened the view page.
Have I totally gone overboard here? What are some better concepts I could employ to accomplish this task?
If i understand what you want to do this is how i will do this:
First the data entry
if you have lot of fields you better use a form wizard, i don't have a particular one in mind right now but there is lot of them just search jQuery Form wizard
Here is an example:
http://i.stack.imgur.com/Luk2b.jpg
The concept of the form wizard is to guide user via multiple page and also validate the data. And click save when and the end.
Then save date in database.
Display content
All you need to do is to create a global separate page to display your content.
Let see something like: http://yourserver.com/view/{id}
where id is the identifier of the particular row in your database.
i'm not sure if i totally understand what u about to do. i'm trying to make your work description shorter here:
want to build a website that one person can edit a single page's content in 1 hour, and others can view the content change in that 1 hour.
if this is what u want to build, here's the module:
teacher: the one who can edit the page
student: the one who can only view the page
server: information center
teacher client edits page -> teacher client sends update data to server -> server saves data -> server sends update notice to student client -> student client receives update notice -> student fetches update data from server
to make this module work well, i suggest try socket instead of http reqeust, just like online games or IMs do.
well, try socket.io
I'm developing a simple(!) 2 page application.
Page1: Takes basic details from the user about the program is creating for his trip - name of the trip, dates etc.
After clicking Save, a entry is created on MongoDB using controllers in Lithium PHP for the program. A id is generated and passed on to page 2 as a parameter in URL like so:
$this->redirect('/iplans/save/' . $program_id . '/' . $program_name);
Page 2: is a single page application using many Backbone scripts (hosted in individual js files) and allows the user to add datewise details of his program. No js script is in-line.
I want the backbone collection to be saved on the server side when Finish is pressed but need to send in the program_id with this collection so that the right program is updated in MongoDB.
Questions:
How does one ensure that the program_id from lithium/php server side is picked up by backbone javascripts that are in their own js files (not inline)
What other options are available besides Controller::redirect to forward the control from page1 to page2?
What other options can be used to pass-on the program_id and any other values that may be needed to backbone/JS layer. Is there a standard-way of passing such items?
There are a couple of options:
Parse out program_id from window.location.href
Dynamicly create a bit of javascript in your lithium view. it could be as simple as:
"<script> myvars = " . json_encode(array(...)) . "<script>"
and then you can read the variables from the javascript.
Create the onDomRady function dynamically from lithium
That is a good way. That is, one page show form and receive data from the form, and one page that show some data. They are not related to each other, and it will make the code easy to understand.
You could use AJAX/JSON to send/receive data to/from the server. Also see answer 1b,1c
If it's just a variable being written to the session that you need to access in a single-page app, just make a controller (i.e. SessionsController) that returns the current session information, and turn content negotiation on.
Then you can get whatever keys you need any time.
I'm trying to create a work flow that will send an email to the users in the contact field for the page that the initial link was followed from.
In other words, a user clicks a link on page ../top/sub/pages/page1.aspx which takes them to a form here: ..top/lists/feedback/newform.aspx. Once they submit the form on the top level page it starts a workflow (at ..top/lists/feedback/) which will email the users in the meta data for the referrer page (../top/sub/pages/page1.aspx) and finish by deleting the feedback item.
My problem lies in trying to email the correct user. I have tried to make a work-flow on the sub-site, but it seems like the work-flow has ZERO access outside of its directory.
My next idea would be to try and send the user as a parameter (as part of the form) using a script, but I'm unsure of how to access the information I need.
How would I access the page's contact user? Am I even on the right track?
ps. I dont have access to the server and therefore am unable to use visual studio
Probably there might be some dirty workaround.
add a hidden field to you top/lists/feedback/
add a delegate control that stores the contact on the page the user came from i.e. in the user session (or somewhere in SharePoint or in DB) and place the control on the pages ../top/sub/pages/ (or place it everywhere but make it work only on the pages)
add an itemeventreceiver in the list ..top/lists/feedback/ that grabs what the delegate control saved and inserts it into the hidden field in the item that is created in the ..top/lists/feedback/newform.aspx
use the hidden field in the wotkflow.
I hope you can either accept it or generate you own idea reading my answer.
Good luck!