Doing something in the background and notify user when it's done - node.js

I am using nodejs has my server and React in the frontend.
There is a menu item on the UI that says View PDF, what I need to do is to get some PDF files from my S3 bucket when users choose this menu item, put some headers etc.
I can easily put a modal screen to show users the PDF files are being generated and display a link to the PDF when it's ready.
But what technology should I use if I want to do away the modal screen, but to allow users to continue to do some other stuffs and display a say dismissable alerts with the link to the PDF when it's ready.
How difficult is that and what do I need?

Definitely take a look at socket.io.
Web sockets allow you to establish two way communication between the client and server. For your use case, this means you can send a notification to the the client from the server.
This is not too difficult to implement but will require a bit of work on both the client and the server. You can find a lot of React examples here.

Related

No XEP-0333 Chat Markers in XMMPP Openfire backend - how to solve it?

We have an Openfire XMPP/Jabber server setup (with a NodeJs backend and React frontend).
Chat is a feature embedded in the app (NOT an overlay or window that is always visible). So the user has to navigate to a specific page to access the chat interface.
It is working via websockets and messaging sending is working fine. We have a React frontend.
The challenge is that XEP-0333 Chat Markers is not supported by Openfire (the spec never become production ready).
Therefore we need to know how can we implement this feature so that :
A users knows when they are online that they have an unread message (and later, how many unread message they have). For example, if they are not in the chat window and messages are arriving, we need to indicate that in the header of the app so they see it)
if a user goes offline, and comes back online but NOT into the chat window, how can we know if they have unread messages and notify them of that?
My understanding is that somehow we have to keep track of unread messages (eg perhaps in indexedb or local storage or even in postgres backend) and after the user reads a message, we delete it from storage. If the storage still has records for that user then clearly those are the unread messages.
Obviously we don't know if they actually READ the message, but we can assume that if the chat window is open and visible (ie. active tab in their browser) that any messages delivered have been read.
So if our application tab is active, but user is not in chat, and a message arrives, we store it. When they open chat and click on the sender, we remove it from storage.
Has anyone solved it this way? (looking for links to React or JS/TS code)
Is there a better way? (links to other solutions would be helpful, esp. code)

React: Is there a way to set up a button clicking on which would trigger opening default email client with PDF document attached to it?

Basically I would like to achieve the following result: on a web page user clicks on a Share button and it opens up his default email client with a PDF with the contents of the page attached to it.
I was think to use a combination of html2canvas and react-pdf to generate a PDF page and attach it to this email that would be opened directly from the client side. Is it something possible to implement, or would I need to do it through the server side, or is it something just generally not possible?
I found some topics about it, like this one, that state that it is only possible to add attachment from the client's machine, not the web (which includes both React client and Node.JS server that I have spinning on AWS EC2 / or something from AWS S3 bucket, I assume), however I feel like I have seen it being implemented on some sites in the past.
Ideally, in future it would be an overlay opening on Share button that would have options to open email / Slack / MS Teams client with that PDF attachment, but for now just focusing on email part.

Enforce print-only document on the web

I need to provide printable documents without any ability (or a very minimized ability) of the user to view or download them.
I don't even have to render the document. They could just click a text link and have it blindly print to a printer.
This can be done using native applications, but it would be far better to provide this feature from a web interface.
Some points:
I can encrypt the document on the server so the HTTP GET response is garbled. The client could fetch a dynamic key from the server just before print to re-assemble the data. This would prevent snooping through a web inspector.
I could demand the use of a browser extension that sends print jobs without presenting print preview windows.
What other ways could a user get the document? What else should I be thinking with preventing?

Using socket.io to send data to a specific view/id

I have a web application using NodeJS, Express, and MongoDB. In my application, I have a view, that can be seen by anyone who accesses the application. That view is rendered with a different image, depending on which a user selects to view (they do not need to be logged in) ie the view is mapView/mapId.
Now, I want something similar to notifications to occur in realtime for those that are on that page. When a specific event happens from an external source, I want to display a popup on the view to which the event belongs to. So the event may only belong to one mapView/mapId and not another mapView with a different ID. All users on the same mapView/mapId should see the notification. Remember, these are general users that do not need to be logged in.
I am researching into Socket.io because I know it is for making realtime applications. But I am wondering if this is even the right way to go. How will I send data to the correct mapView/mapId?
Check out what your server can do with rooms
The idea is that each of your connections, from a particular view, is joined to a room. Then you use socket.io from the server to send a message only to that room. And only those sockets will get the message.

Can I build an addin for Gmail?

Is there a way I can create an addin for my Gmail account? Is GreaseMonkey the only real way?
I use Gmail for customer service, and I'd like to create a tool that looks up the customer and preps a response to them based upon who it is in my database... instead of looking by hand for the client and typing it out.
You can add gadgets (same as iGoogle and wave) and add them to the side bar in GMail, but you will not have access to the e-mails themselves. You could create small lookup forms and such, though.
I don't see how else you could do it. You won't be able to run your own app on Google's backend, so that leaves the client (with javascript and something like GreaseMonkey) and your server (perhaps communicating with the client via AJAX).

Resources