diff --git a/grandnational-dashboard/.DS_Store b/grandnational-dashboard/.DS_Store index 762de9f..bedf0db 100644 Binary files a/grandnational-dashboard/.DS_Store and b/grandnational-dashboard/.DS_Store differ diff --git a/grandnational-dashboard/.gitignore b/grandnational-dashboard/.gitignore index 52b89ef..252dd7e 100644 --- a/grandnational-dashboard/.gitignore +++ b/grandnational-dashboard/.gitignore @@ -133,9 +133,9 @@ dmypy.json # pytype static type analyzer .pytype/ -# Custom -*bower_components +# ignore bower and node_modules *node_modules -*font-awesome -*.mp4 -*docker-image +*bower_components + +# ignore video +*static/assets/videos/gn19-short.mp4 diff --git a/grandnational-dashboard/README.rst b/grandnational-dashboard/README.rst index e69de29..89ee7ee 100644 --- a/grandnational-dashboard/README.rst +++ b/grandnational-dashboard/README.rst @@ -0,0 +1,135 @@ +*************************************** +Grand National 2020 Countdown Dashboard +*************************************** + +This repo contains all files for the Grand National 2020 Countdown Dashboard. + +.. image:: https://git.nonprod.williamhill.plc/wh_capacity/grandnational-dashboard/uploads/47fdb6cc5b3a6658ee884ab148fb8a29/image.png + :width: 40% + + +The dashboard is installed on ``sc1uxpremn81`` running in docker. + +The dashboard uses ``python`` as an ASGI server, ``css`` for formatting, and ``jQuery`` for front-end scripts. + +We use `uvicorn `_ as an ASGI server and `gunicorn `_ to manage the asynchronous workers. We use `bootstrap `_ for front-end formatting and, `jQuery `_ for front-end scripts. We use `npm `_, `bower `_ and `poetry `_ to manage dependencies. + +Optionally we can use `docker `_ to orchestrate uvicorn and guvicorn. + + +Running Locally +=============== + +Requirements +------------ + +You will need installed: + +- python>=3.6.2 +- npm +- docker `(optional)` + +on your machine as a pre-requisite. Versions of python lower than 3.6.2 may work, but you will have to delete the ``poetry.lock`` file before installing the python dependencies. Versions lower than 3.6.2 will not come with `venv` - you will need to install an alternative (``virtualenv``) or use ``potery`` to manage the virtual environment for python. + +Installation Steps +------------------ + +Create workspace +^^^^^^^^^^^^^^^^ + +On your machine clone the repo: + +``cd ~`` + +``git clone https://git.nonprod.williamhill.plc/wh_capacity/grandnational-dashboard.git`` + +In this folder, create a virtual environment for python: + +``cd ~/grandnational-dashboard`` + +``python3 -m venv gn-dashboard`` + +Activate this environment: + +``source gn-dashboard/bin/activate`` + + +Install Dependencies +^^^^^^^^^^^^^^^^^^^^ + +Install ``bower`` using ``npm``: + +``npm install -g bower`` + +Install poetry: + +``pip install poetry`` + +Install the node depdencies with ``npm``: + +``npm install`` + +`this reads the dependencies from package.json`. + +Install the bower dependencies with ``bower``: + +``bower install`` + +`this reads the dependencies from bower.json`. + +Install the python dependencies with poetry: + +``poetry install --no-dev`` + +`this reads the dependencies from pyproject.toml and poetry.lock` + +Copy The Large Static Files +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The video used as a banner is too large for gitlab. You should do: + +``cd static/assets/videos`` + +and + +``wget http://sc1uxpremn81:9001/static/assets/videos/gn19-short.mp4``. + +Alternatively, if the dashboard isn't online, you can download the file manually from confluence: + +https://conf.willhillatlas.com/display/CME/Static+Files + +Place this video locally in ``static/assets/videos/`` saved as ``gn19-short.mp4``. + +Run the Webserver +^^^^^^^^^^^^^^^^^ + +Manually +"""""""" + +Running the webserver is done with ``uvicorn``. Go into ``grandnational_dashboard`` and launch uvicorn: + +``cd grandnational_dashboard`` + +``uvicorn main:app`` + +(The folder name is the same as the repo name. This may be confusing but is intentional when creating a project with poetry without a src folder. The full path you should be in is ``~/grandnational-dashboard/grandnational_dashboard`` and there should be a ``main.py`` file inside this folder.) + +Your dashboard should then be available at http://127.0.0.1:8000 + + +Docker +"""""" + +We can use Docker for deployment. To do this go back to the root of the project and build the docker image from the ``Dockerfile``. + +``cd ~/grandnational-dashboard`` + +``docker build . -t gn-20-dash`` + +When this has built you can run the container with: + +``docker run --rm --name dashboard -p 8000:80 gn-20-dash:latest`` + +Your dashboard will then be available at http://127.0.0.1:8000. + +This docker image runs gunicorn to manage the asynchronous workers. It's scaleable, and will smartly use the resources of the machine it's running on. diff --git a/grandnational-dashboard/app/.DS_Store b/grandnational-dashboard/app/.DS_Store deleted file mode 100644 index c469b00..0000000 Binary files a/grandnational-dashboard/app/.DS_Store and /dev/null differ diff --git a/grandnational-dashboard/app/__init__.py b/grandnational-dashboard/app/__init__.py deleted file mode 100644 index b794fd4..0000000 --- a/grandnational-dashboard/app/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '0.1.0' diff --git a/grandnational-dashboard/app/dashboard.py b/grandnational-dashboard/app/dashboard.py deleted file mode 100644 index dc5a14e..0000000 --- a/grandnational-dashboard/app/dashboard.py +++ /dev/null @@ -1,31 +0,0 @@ -from starlette.applications import Starlette -from starlette.templating import Jinja2Templates -from starlette.routing import Route, Mount -from starlette.staticfiles import StaticFiles - - -templates = Jinja2Templates(directory='templates') - - -async def home(request): - return templates.TemplateResponse( - 'index.html', - {'request': request}, - ) - -routes = [ - Route('/', endpoint=home), - Mount('/static', StaticFiles(directory='../static'), name='static'), - Mount( - '/node_modules', - StaticFiles(directory='../node_modules'), - name='node_modules', - ), - Mount( - '/bower_components', - StaticFiles(directory='../bower_components'), - name='bower_components', - ), -] - -app = Starlette(debug=True, routes=routes) diff --git a/grandnational-dashboard/app/main.py b/grandnational-dashboard/app/main.py deleted file mode 100644 index dc5a14e..0000000 --- a/grandnational-dashboard/app/main.py +++ /dev/null @@ -1,31 +0,0 @@ -from starlette.applications import Starlette -from starlette.templating import Jinja2Templates -from starlette.routing import Route, Mount -from starlette.staticfiles import StaticFiles - - -templates = Jinja2Templates(directory='templates') - - -async def home(request): - return templates.TemplateResponse( - 'index.html', - {'request': request}, - ) - -routes = [ - Route('/', endpoint=home), - Mount('/static', StaticFiles(directory='../static'), name='static'), - Mount( - '/node_modules', - StaticFiles(directory='../node_modules'), - name='node_modules', - ), - Mount( - '/bower_components', - StaticFiles(directory='../bower_components'), - name='bower_components', - ), -] - -app = Starlette(debug=True, routes=routes) diff --git a/grandnational-dashboard/app/templates/index.html b/grandnational-dashboard/app/templates/index.html deleted file mode 100644 index a549ef8..0000000 --- a/grandnational-dashboard/app/templates/index.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - Capacity Dashboard - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- -
-
-
- -
-
-

Grand National 2020

- -
-
-

Cheltenham 2020

- -
-
-
-
-
-
-
-
-
-
-

Cheltenham Festival 2020

-
-

Day One 🐴 Tuesday 10th March

-
Featuring the Unibet Champion Hurdle
-
-

Day Two 🐴 Wednesday 11th March

-
Featuring the Betway Queen Mother Champion Chase
-
-

Day Three 🐴 Thursday 12th March

-
Featuring the Ryanair Chase
-
-

Gold Cup Day 🏆 Friday 13th March

-
Featuring the Magners Cheltenham Gold Cup
-
-
-

Grand National 2020

-
-

Liverpool's Day 🐴 Thursday 2nd April

-
Featuring the Betway Aintree Hurdle
-
-

Ladies Day at Aintree 🐴 Friday 3rd April

-
Featuring the JLT Melling Steeple
-
-

Grand National Day 🏆 Saturday 4th April

-
Featuring the Randox Health Grand National Steeple Chase
-
-

1st Favourite: Tiger Roll 🇮🇪

-
2nd Favourite: Burrows Saint 🇫🇷
-
-
-
-
- - - - diff --git a/grandnational-dashboard/bower.json b/grandnational-dashboard/bower.json index 90bd1c7..86c9cf3 100644 --- a/grandnational-dashboard/bower.json +++ b/grandnational-dashboard/bower.json @@ -3,7 +3,7 @@ "description": "", "main": "index.js", "authors": [ - "dtomlinson " + "dtomlinson " ], "license": "ISC", "homepage": "", @@ -15,8 +15,7 @@ "tests" ], "dependencies": { - "masonry-layout": "desandro/masonry#^4.2.2", - "jquery.countdown": "^2.2.0", - "Morphist": "^3.0.0" + "Morphist": "^3.0.0", + "jquery.countdown": "^2.2.0" } } diff --git a/grandnational-dashboard/grandnational_dashboard/.DS_Store b/grandnational-dashboard/grandnational_dashboard/.DS_Store deleted file mode 100644 index c469b00..0000000 Binary files a/grandnational-dashboard/grandnational_dashboard/.DS_Store and /dev/null differ diff --git a/grandnational-dashboard/grandnational_dashboard/dashboard.py b/grandnational-dashboard/grandnational_dashboard/dashboard.py deleted file mode 100644 index dc5a14e..0000000 --- a/grandnational-dashboard/grandnational_dashboard/dashboard.py +++ /dev/null @@ -1,31 +0,0 @@ -from starlette.applications import Starlette -from starlette.templating import Jinja2Templates -from starlette.routing import Route, Mount -from starlette.staticfiles import StaticFiles - - -templates = Jinja2Templates(directory='templates') - - -async def home(request): - return templates.TemplateResponse( - 'index.html', - {'request': request}, - ) - -routes = [ - Route('/', endpoint=home), - Mount('/static', StaticFiles(directory='../static'), name='static'), - Mount( - '/node_modules', - StaticFiles(directory='../node_modules'), - name='node_modules', - ), - Mount( - '/bower_components', - StaticFiles(directory='../bower_components'), - name='bower_components', - ), -] - -app = Starlette(debug=True, routes=routes) diff --git a/grandnational-dashboard/grandnational_dashboard/templates/index.html b/grandnational-dashboard/grandnational_dashboard/templates/index.html index 42bb096..49b1936 100644 --- a/grandnational-dashboard/grandnational_dashboard/templates/index.html +++ b/grandnational-dashboard/grandnational_dashboard/templates/index.html @@ -1,36 +1,40 @@ - - Capacity Dashboard + + + + Grand National Dashboard - - + - - - - - - - + + + + + + + + + + - + - + - - + + + + - -