GQL Modules - GraphQL Modules for Remote Client Browsers


#86

Hi will guide which SQL SERVER Ver. need for this ?
2008 or 2012 ?


#87

Latest the better, 2016 is available and used by many.
Since SQL Express is free there is no reason not to use the latest.


#88

2008 and 2012 are old versions. It is 2017 and SQL express 2016 is current version.


#89

Even 2014… lol, which im on as installed before 2016 version was released and not got round to updating.
For a fresh install why you wouldn’t use latest I dont know.


#90

i am using 2008 SQL and some of reports not working because of old SQL ver. ?
and i am also facing some issues on advance delivery system just need to know it’s just because of old ver. ?
thanks


#91

Doubt many here have ever used 2008 ver… are you expecting someone to downgrade to test.
Its free, why dont you just update and if it fixes you know that was the issue…


#92

No. Provide the Version number of SambaPOS. Upgrade to the latest.

And your questions have nothing to do with this Topic. Make a new Topic.


#93

Hey guys im having some issues trying to get these modules working. basically i get the following screenshot


and the token states “Invalid clientId” however looking at the config.js file. Specifically the GQLclientId part

and sambapos application side…

as far as I can see the client id matches?

I tried to login to GQL also and I receive a successful token… but not for the GQLmodule client id.

any idea where I’m going wrong?


#94

Did you follow these instructions to modify the code? The error indicates the clientId was not even sent.

You also need to restart the Message Server Service after adding an Application.

P.S. I really need to update the Github soon :wink:


#95

Yes rather in importing all the rules and what not i decided to manually implement everything line by line but since i scroll back and forth a lot to ensure i dont miss anything, that assurity habit of mine might be causing me to miss something haha.

The code on github was all done during .60 and .61 but the modification part to config.js and other .js files were not updated and i did scroll down to ensure i didnt miss any updates(knowing how long its been since you made this) and i found the updated code and put it alongside the code i downloaded, then i put whatever additional coding that was required in and saved it.

I didnt restart message server however i did restart my pc so i believed that by doing so it may also restart the message server. After restarting the pc i tried again and it still wouldnt give me an access token for gqlmodules.

Out of curiosity if you have multiple applications setup for gql, would the additional applications interfere with the login process?

Im not at my pc right now but i do remember i had 3 applications setup.

1.graphiql
2.mobilepos(for the android application im testing.)
3. GqlModules(for the web based application for this tutorial)

I also setup an individual user for each application to test with,however everytime i do login to gql it only always creates a token for graphiql client.

I wonder if sorting them applications would make a difference. That is if i bring the gqlmodule to the top and see if that makes a difference.

Once i get back to my pc ill upload screenshots of each file that required modification and paste the code for better viewing.


#96

No. The Application is to set the Client Id. The Login is done via Username and Password (not PIN). GraphQL requires both for Authentication.

For the GraphiQL interface, that Web App is hard-coded with the Client Id (Identifier) as graphiql so you need to set up that Application in SambaPOS exactly like that for it to work. The Username and Password can be anything. But this has nothing to do with GQL Modules …


I see the error you are getting, but we need to see the Post Request (Form Data) to ensure it is sending the proper information. In Chrome, that will be in the Headers Tab, and the request is at the bottom …


#97

#UPDATE: 2017-06-03

GitHub Repository has been updated.

##Updates for GraphQL Authentication for SambaPOS 5.1.62+

GraphQL requires Authentication from Apps as of v5.1.62. This involves configuring an Application in:

Manage > Users > Applications

##Application Configuration

For GQL Modules you can identify the Application however you want, but you need the Client Id (Identifier) in SambaPOS to match GQLclientId variable in config_auth.js

###SambaPOS Application Configuration

It is also important to note that GraphQL Authentication is able to determine if the App is trying to access the engine on the Local Network, or from another Network such as the Internet. So you need to properly set the Authorization Type in SambaPOS to coincide with the type of access you are trying to provide. Note in my previous screenshot for setting up the Application, I have the Auth Type set to All Functions. This means I can access GraphQL from an App (GQLModules) from outside the Local Network, that is, from a remote location on the Internet.

###GQL Modules Configuration (config_auth.js)

Set the variable for GQLclientId in config_auth.js so that it matches the Application Identifier configured in SambaPOS. You can also set the GQLsecret variable if you configured an App Secret for the Application in SambaPOS. The variable for GQLappPassword should be left empty so that you will be prompted for this information using the Login Forms.


##Configure an Application User in SambaPOS

Create a User in SambaPOS that you will use for GraphQL Authentication. Be sure to have a strong Password for this User.


##App Authentication and PIN Login

This update includes Login Forms to prompt the operator for the Username and Password to Authenticate the App, and it has a 2nd prompt for a User PIN to identify which SambaPOS User is using the GQLModules App. The PIN Login has nothing to do with GraphQL Authentication. These are separate things …


##Cached Auto-login

Both the Application Authentication and PIN Login are cached in Browser Storage so the next time you open your Browser, the Authentication and PIN Login are “automatic” …


##Switching User

Once you have performed App Authentication using the Username and Password, you should never need to do it again.

But there may be times when you want to switch the Registered User. For example, if you are using the POS Module, you might want to change the User on a Tablet so the Users Tickets are properly tracked. This can be done by Logging out, and you will be prompted for a PIN to register the User. Remember, this has nothing to do with GraphQL Authentication (that has already been done with a Username and Password); this is only to register the User of GQL Modules …



#98

Ok. I downloaded the latest update, configured the clientID to match the application client ID

UPDATE: Very strange, if i access the webpage from lets say my phone or tablet connected to the same network, it works??? but on the same machine in chrome it doesnt???

*Issue 1


It could not find this report because I did not make this report under reports. Reason? In the tutorial under Special report looking at

There’s no information there. Neither is there anything for GQLM Terminals either

I initially thought maybe just create the report with those names but leave it blank. But looking at the error message, it is trying to fetch data from that particular report, so I thought there definitely must be something in that report otherwise it is odd.
I searched the rest of the topic but couldn’t find anything specific to those reports.
Any ideas?


#99

Hmm, yeah, it is not sending the client_id. Try this to force a code reload …


#100

Special Reports post has been updated to contain the missing Reports.

GQLM Ticket Type Entity Types
GQLM Terminals


#101

Great! after the forced refresh now we are getting somewhere. However I came across another issue.
I get the following


In the modules I can only see the entity type which is set to default as it is in my database also. However I don’t have an entity screen named “Customers” so I’m not really sure how to filter this out or what should I do to resolve this.

EDIT Could this be because I currently don’t have any saved customer entities in the database?


#102

That variable is an Array of Entity Screen Names.

Remove ‘Customers’ from that variable if you don’t have an Entity Screen named “Customers”:

var POS_EntityTypes = ['Tables'];

P.S. that variable is mis-named really. It used to look for Entity Types, but now it looks for Entity Screen Names. So you need to have matching Entity Screens in SambaPOS for anything that you put in that variable. If you don’t have an Entity Screen named “Tables”, but you have one named “All Tables”, then use that instead.


#103

Ahh yep I did exactly that just before you started typing and then restarted message server with a new refresh and it’s all working now :smiley:. This was my first attempt at doing almost anything at all to do with GQL, I’m very excited!
Thanks a lot for all your help with this :). I re-read almost every thread relating to GQL in full depth and length to really get the gist of it all and slowly getting the hang of all of this .

I do have a few questions though I was hoping to get some help with.
there are probably 2-3 things I would like to add to this “POS” screen.

  1. “Print Bill” function button
  2. Table layout display when click the “Tables”, and a way to show the Table screen first if department is set to select entity. (Not necessary but desirable)
  3. Ticket Tags and how I can show them the same way they are shown in sambapos.(Useful when Order number is used during take away orders or fast food setup)

If I know what to edit and what codes to use in which file then I can start working on possibly adding to the functionality of that POS screen.
These would be amazing to have.


#104

That will not be easy at all. It might be possible by pulling Widget Data for Widgets assigned to the Tables screen, and based on the Widget coordinates, you might be able to layout a screen in HTML. But there is no method to “translate” a Custom Entity Screen into HTML. The getEntityScreenItems() query returns only a list of Entities with associated display formatting and nothing else.


Um, no ideas for that one.


Ticket Tags are displayed in the “Ticket List” when you Close the Ticket…

You can see that just shows Tag Values. That code is in the function POS_renderTicketList(). You can have it display the Tag Name as well …

You can also show Tags by clicking on the “Info Bar” at the top-middle of the POS Screen …

If you are wanting the Tag(s) to show in the “Order Screen” as well, it might be possible. You probably need to access the Tag(s) from the POS_Ticket.terminalTicket Object in function POS_showTicketOrders(). The POS_Ticket.terminalTicket object probably has the Ticket Tag information. You’ll need to use DevTools to set breakpoints and pause execution in that function and you can check that object content.


That is in the code somewhere already, but disabled. Print functions are part of this Array, which is Print Job Names:

var POS_PrintJobs   = ['Print Bill','Print Orders to Kitchen Printer'];

Search the module.js code for “PrintJob” and you will find the associated functions. The first occurrence shows the “buttons” commented out …

I think all you need to do is modify the Array to contain the name of your Print Bill Job, and uncomment that line.

And there are these functions, but I don’t think you need to do anything here:

POS_printJobSelect()
POS_executePrintJob()

Hmm… maybe you need to uncomment this too…


#105

Sweet that’s a good enough start to get me going.
Also one thing I noticed for order tags is if you select free tagging and save free tagging, then try to highlight an item to select an order tag, nothing appears on the screen. But if you disable free tagging, you can select order tags. Is there a way we can add that free tagging into the order tag area? is there a code that allows to create order tags? if there is maybe we can use that to make the free tagging work