arafatamim / tally-counter

Handy tally counter, for all your counting needs.

Home Page:https://tally-counter-pwa.netlify.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Suggestion] Add an optional timer (e.g. for counting traffic 15 minutes)

Wikinaut opened this issue · comments

My use case: I use the tally for counting traffic (bicycles, cars, …) for 15 minutes.

Suggestion:

Build in timer (option): stop function and/or signal after a certain time

For this purpose, we regularly need to start an additional app or a stop watch app or the like to stop our counting of items lets say after 15 minutes of counting. (Then we estimate or express the number of items per hour from that fiugures).

The counter could then stop acounting or at least show an optional signalisation.

Optionally, an acoustic signal (mp3) could be played when it ends.

It would facilitate the use of the script for our main purposes, if the tally had an optional timer which can be very stupid simple. In a first implementaion it could be limited to, for example, 15 minutes, The code can then later be extended to become user definable having different counting periods.

I'm trying to stick to the original purpose of the app and make it good at what it does best, ie, counting. I consider adding a timer out of scope for a simple hobby project like this. That being said, anyone is welcome to fork the source code and add their own features to it. I hope you understand.

I already forked and will perhaps add:

  • a timer
  • an csv and json export function (perhaps also import) to a file or to a web/cloud sink
  • function for collaborative counting (counting same or different items by different people) → community counting
  • make the default items configurable from a extra data json

Great!

have you changed the port from 8080 to 3000? where?

it is working, but where can I set up the port?

I replaced vue-cli with vite, which uses a different port by default. You can change it in vite.config.js like this:

export default defineConfig({
  ...
  server: {
    port: "8080",
  },
});

Should be added to the code, okay?

Right.

(ok. Your current code works now here on with a reverse proxy to localhost:8080)

I added (above):

  • make the default tally items configurable from a extra data json

And, pls. can you add some pointers to learn, how this app framework works? What is the framework which builds the gadgets and so on, I like it. Nothing against your code - I just want to know where to read how I can add stuff and so.

Do you allow, would you mind, I open a(one) separate "meta" issue with my suggestions?

I will then add checkboxes there

  • like this and
  • that
  • suggestion n

See #13

Sure, go ahead.

BTW, the app framework is called VueJS. You can consult the docs here.

@arafatamim Hi. Could you give me a hint how to integrate into the code a very simple timer for 15 minutes? I need this urgently for traffic/vehicles counting? A timer which stops counting and or flashes the screen and or gives an mp3 audio signal 15 minutes after clicking start or so.

Such a hint would be very helpful.

Maybe a setInterval in the onMounted hook? Something like this

const count = ref(10);
onMounted(() => {
const interval = setInterval(function () {
  console.log(count)  
  count.value -= 1;
  if (count.value === 0) {
      // play audio here
      clearInterval(interval); // Stopping the counter when reaching 0.
    }
  }, 1000);
}

could probably be modified to fit your use case. Haven't tested it though.