nanawel / our-shopping-list

OSL is a simple shared list web-application based on Node and VueJS. Typical uses include shopping lists of course, and any other small todo-list that needs to be used collaboratively.
GNU Affero General Public License v3.0
82 stars 8 forks source link

Remote access question #7

Closed steveuk23 closed 1 year ago

steveuk23 commented 1 year ago

Hi. I like the look of this thanks. Is it possible to remotely add and delete items from the list and also retrieve the contents of the lists but not through the Web UI ? Sorry I'm new to Docker but I run Home assistant which gives me the ability to send mobile notifications when someone is in a area so I would like it to send the contents of this list if we were in a supermarket. Thanks

nanawel commented 1 year ago

Hi @steveuk23

Is it possible to remotely add and delete items from the list and also retrieve the contents of the lists but not through the Web UI ?

Yes sure, just use the API exposed by the backend the WebGUI is using. See examples using curl.

Get all the lists from the board "test"

curl https://osl.lanterne-rouge.info/boards/by-slug/test
{
  "_id": "70279b58-abe6-4e42-82c3-dd789376ea8e",
  "slug": "test",
  "name": "test",
  "createdAt": "2022-04-01T17:25:15.917Z",
  "updatedAt": "2022-11-13T23:52:04.497Z",
  "__v": 0,
  "lists": [
    {
      "_id": "4ccd5e08-4aa1-45a1-a8cf-2640c7d1c7a6",
      "name": "some list",
      "boardId": "70279b58-abe6-4e42-82c3-dd789376ea8e",
      "createdAt": "2022-04-01T17:25:19.236Z",
      "__v": 0,
      "id": "4ccd5e08-4aa1-45a1-a8cf-2640c7d1c7a6"
    },
    ...

If running in "single board mode", the request to use is fixed

curl https://osl.lanterne-rouge.info/boards/00000000-0000-0000-0000-000000000000

Get all the items from the list with UUID "4ccd5e08-4aa1-45a1-a8cf-2640c7d1c7a6"

curl https://osl.lanterne-rouge.info/lists/4ccd5e08-4aa1-45a1-a8cf-2640c7d1c7a6/items
[
  {
    "_id": "d7cce401-39db-4f11-b740-7a65dca71e01",
    "listId": "4ccd5e08-4aa1-45a1-a8cf-2640c7d1c7a6",
    "name": "_ So you tried \"test\" too he he :)",
    "details": "",
    "qty": null,
    "checked": false,
    "lastCheckedAt": "2022-09-17T05:53:34.249Z",
    "updatedAt": "2022-09-17T05:53:45.151Z",
    "createdAt": "2022-04-01T17:25:35.157Z",
    "__v": 0,
    "id": "d7cce401-39db-4f11-b740-7a65dca71e01"
  },
  ...

Check item with UUID "d7cce401-39db-4f11-b740-7a65dca71e01"

curl -X PATCH --data '{"checked": true}' -H 'Content-Type: application/json' https://osl.lanterne-rouge.info/items/d7cce401-39db-4f11-b740-7a65dca71e01

And so on...

Notice: You probably won't want to delete any item most of the time. Just check it.

All responses are in JSON (here truncated and formated with jq for better readability) and thus can easily be processed.

steveuk23 commented 1 year ago

Thanks for the reply that looks ideal. Have you ever thought about adding voice assistants to be able to add remove through them ?

nanawel commented 1 year ago

I have not. As the primary goals of this application are for it to be lightweight and straightforward, this feature seems very far from them :wink: