Giter Site home page Giter Site logo

bacon's Introduction

Bacon

Simple attendance tool to quickly see who is at the office based on devices connected to wifi.

Built with Laravel, Craftable, Vue and Tailwind.

Bacon dashboard Bacon employee administration Bacon edit employee

Installation

There is a docker configuration included, so the installation process should be pretty straight forward.

Clone this repository, cd into it and run:

./harbor init

This will setup .env variables, install required packages and run npm.

Afterwards run:

./harbor start

This will start all the docker containers and set up network and volumes correctly.

Now you can visit http://localhost in your browser.

If you are changing js/css do not forget to have watcher running to recompile assets:

./harbor npm run watch

Request to update people in the office

You can send POST request to /update-devices endpoint with array of online devices.

curl -X POST https://EXAMPLE.com/api/update-devices -H 'Accept: application/json' -H 'Authorization: Bearer API_TOKEN from .env' -H 'Content-Type: application/json' --data-binary '[{"ip": "192.168.1.1", "mac": "a4:5d:a1:eb:e3:51"},{"ip": "192.168.1.56", "mac": "60:03:08:8d:99:6c"},{"ip": "192.168.1.31", "mac": "9c:93:4e:3e:4b:ac"},{"ip": "192.168.1.85", "mac": "b8:27:eb:e3:47:e9"},]'

Employee which has device present in this array will be shown as "At work".

Devices that don't belong to any employee will be added to the system, so you can assign them later.

I suggest making a Python script, that will run on Rasberry Pi connected to your network and scanning + sending it every few minutes.

Script could look something like this.

import re
import json
import subprocess
import requests

lines = subprocess.check_output("sudo arp-scan -l | grep 192", shell=True).splitlines()
first = True

json_file = open('json.txt', 'w')
json_file.write("[")

for line in lines:
    if first:
        first = False
    else:
        json_file.write(",")
    dump = {}
    dump['mac'] = re.findall(ur'(?:[0-9a-fA-F]:?){12}', line)[0]
    dump['ip']  = re.findall(r'[0-9]+(?:\.[0-9]+){3}', line)[0]
    json.dump(dump, json_file)
json_file.write("]")
json_file.close()

url = 'https://EXAMPLE.com/api/update-devices'
payload = open("json.txt")
headers = {'Accept': 'application/json', 'Authorization': 'Bearer API_TOKEN from .env', 'Content-Type': 'application/json'}
r = requests.post(url, data=payload, headers=headers)

I am sure this could be done in much better way, but these were my first lines of Python ever - PRs are always welcome. Don't forget to add a cron job that runs this script every few minutes. (For example five: */5 * * * *)

License

MIT

bacon's People

Contributors

matejminar avatar

Stargazers

Billal BEGUERADJ avatar Adinath Nikam avatar Dmitry R. avatar Biran Jobe avatar Lindemberg Barbosa avatar Markus Unterwaditzer avatar Bruno Garcia avatar

Forkers

begueradj

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.