-
Notifications
You must be signed in to change notification settings - Fork 0
Running in Offline Mode
You can skip the Graph API functionality if needed and run DB AutoOrgChart in offline mode. In this mode, the Org Chart will just serve the contents of employee_data.json without trying to update it first via Graph API.
This is handy if you want a static Org Chart or if you are unable to grant Graph API permissions in your Azure tenant. You can still run this as an App Service in Azure, but you'll just have to update employee_data.json manually.
- Clone this repository:
git clone https://github.com/yourusername/db-autoorgchart.git
- Open a terminal/powershell window from the base directory of the repo (where app.py is present) then create your virtual environment:
On Linux/Mac:
python3 -m venv venv
source venv/bin/activate
On Windows:
python -m venv venv
venv\Scripts\activate
- Install the Python dependencies:
pip install -r requirements.txt
Because we don't Graph API populating employee_data.json, we'll need to populate this ourselves. You have two options:
You can create this file by hand if you wish, I will attach the employee_data.json file that the demo website uses so that you can replicate the formatting with your own data. Ensure the user at the very top is the only employee without the 'managerId' field populated.
You will find this file in the root directory of the repo. Before you run it, you'll need to populate employees.csv (also in the root directory) with your employee data. It should be structured as follows:
id,name,title,department,email,phone,location,managerId
Example data should be visible within employees.csv to help you format the data correctly. The most important part is to ensure the 'managerId' data is available for every employee except for the top level user (whomever appears at the very top of your chart).
Once you have this CSV file ready, simply run the below command and it will create employee_data.json and save it into the root folder of the repo:
python import_csv_to_json.py
Once employee_data.json is popualted with your data, you can run in offline mode by running the following command from the root folder of the repo:
OFFLINE_MODE=true python run_offline.py
Or if you're using Powershell:
$env:OFFLINE_MODE="true"; python run_offline.py
If successful, your console should look something like this:
INFO:app:OFFLINE_MODE enabled: Scheduler and auto-updates disabled.
INFO:__main__:=== OFFLINE MODE ACTIVE ===
INFO:__main__:No Azure Graph API calls or auto-updates will occur.
INFO:__main__:Serving existing employee_data.json file.
INFO:__main__:Populate/update the JSON via CSV import script if needed.
INFO:__main__:=============================
INFO:__main__:Starting Offline Waitress server on 0.0.0.0:5000
INFO:__main__:Server running with 6 threads
INFO:__main__:Press Ctrl+C to stop the server
INFO:waitress:Serving on http://0.0.0.0:5000
INFO:app:Loading template from: templates/index.html
You're good to go! Open 127.0.0.1:5000 and see your Org Chart in all its glory.