Skip to content

Commit

Permalink
Removed all references to the narrowcasting room pc's
Browse files Browse the repository at this point in the history
  • Loading branch information
Berehum committed Oct 14, 2024
1 parent 8874100 commit 4b5dd40
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 255 deletions.
163 changes: 0 additions & 163 deletions amelie/narrowcasting/static/css/room_narrowcasting.css
Original file line number Diff line number Diff line change
Expand Up @@ -359,169 +359,6 @@ html, body {
margin-right: 1vw;
}

/* PC Status block */
#pc_status {
width: 38vw;
height: 44vh;
display: flex;
padding-left: 1vw;
}

#pc_status .pc_column {
width: 8vh;
height: 40vh;
display: flex;
flex-direction: column;
justify-content: flex-end;
padding: 2vmin 0;
}

#pc_status .pc_column.small {
width: 5vh;
}

#pc_status .pc_square {
box-sizing: border-box;
width: 100%;
height: 8vh;
border: 1px solid rgba(0,0,0,0.5);
background-color: var(--ia-blue-light);
display: flex;
flex-direction: column;
align-items: center;
}

#pc_status .pc_square[data-state="tv"] {
color: var(--ia-green-light);
}

#pc_status .pc_square[data-state="on"] {
color: var(--ia-green-light);
}

#pc_status .pc_square[data-state="off"] {
color: rgba(0, 0, 0, 0.2);
}

#pc_status .pc_square[data-state="unknown"] {
color: rgba(150, 150, 150, 1);
}

#pc_status .pc_square[data-state="admin"] {
color: rgba(221, 202, 40, 1);
}

#pc_status .pc_square[data-state="user"] {
color: var(--ia-red);
}

#pc_status .pc_square[data-state="guest"] {
color: rgba(222, 145, 81, 1);
}

#pc_status .pc_square i {
height: 8vh;
width: 8vh;

font-size: 4vh;
line-height: 8vh;
text-align: center;
}

#pc_status .pc_square span {
height: 4vh;
width: 7vh;

font-size: 2.5vh;
text-align: center;
line-height: 3vh;
white-space: nowrap;
overflow: hidden;
-ms-text-overflow: ellipsis;
text-overflow: ellipsis;
padding: 0 0.5vh;
}

#pc_status .pc_square.empty {
background: none;
border: none;
}

#pc_status .pc_square.small {
height: 4vh;
flex-direction: row;
}

#pc_status .pc_square.small i {
height: 4vh;
width: 4vh;

font-size: 2vh;
line-height: 4vh;
text-align: center;
}
#pc_status_legend {
width: 38vw;
height: 8vh;
padding: 1vh 2vmin;

font-size: 3vh;
line-height: 5vh;
white-space: nowrap;
overflow: hidden;
-ms-text-overflow: ellipsis;
text-overflow: ellipsis;
}

/* PC Legend block */
#pc_legend {
width: 38vw;
height: 6vh;
font-size: 2.5vh;
line-height: 3vh;
display: flex;
}

#pc_legend .pc_legend_column {
display: flex;
flex-direction: column;
padding-right: 1vw;
}

#pc_legend .pc_legend_column span {
line-height: 3vh;
}

#pc_legend .pc_legend_column span:before {
content: '●';
padding-right: 1vh;
}

#pc_legend .pc_legend_column span.on:before {
color: var(--ia-green-light);
}

#pc_legend .pc_legend_column span.off:before {
color: rgba(0, 0, 0, 0.3);
}

#pc_legend .pc_legend_column span.unknown:before {
color: rgba(150, 150, 150, 1);
}

#pc_legend .pc_legend_column span.admin:before {
color: var(--yellow-verylight);
}

#pc_legend .pc_legend_column span.user:before {
color: var(--ia-red);
}

#pc_legend .pc_legend_column span.guest:before {
color: var(--orange-verylight);
}


/*
* Right block layout - Media container & logo
*/
Expand Down
11 changes: 0 additions & 11 deletions amelie/narrowcasting/static/js/room_narrowcasting.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ $(document).ready(function(){
updateAndInterval(updateEvent, 5 * MINUTE);
updateAndInterval(updatePictures, 10 * MINUTE);
updateAndInterval(updateRoomDuty, 60 * MINUTE);
updateAndInterval(updatePCStatus, 20 * SECOND);
updateAndInterval(updateNowPlaying, 2 * SECOND);
});

Expand Down Expand Up @@ -252,16 +251,6 @@ function setNextPicture() {
}
}

function updatePCStatus() {
$.ajax({
url: "./pc_status"
}).done(function(data){
for (var key in data) {
$(".pc_square[data-host="+key+"]").attr('data-state', data[key]);
}
});
}

var nowPlayingExclude = [];

function updateNowPlaying() {
Expand Down
1 change: 0 additions & 1 deletion amelie/narrowcasting/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
urlpatterns = [
path('', views.index, name='index'),
path('room/', views.room, name='room'),
path('room/pc_status/', views.room_pcstatus, name='room_pcstatus'),
path('room/link_spotify/', views.room_spotify_callback, name='room_spotify_callback'),
path('room/spotify/', views.room_spotify_now_playing, name='room_spotify_now_playing'),
path('room/pause_spotify/', views.room_spotify_pause, name='room_spotify_now_playing'),
Expand Down
66 changes: 1 addition & 65 deletions amelie/narrowcasting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from django.http import JsonResponse, Http404
from django.shortcuts import render, redirect
from django.urls import reverse
from django.views.decorators.cache import cache_page
from requests.auth import HTTPBasicAuth
from django.utils.translation import gettext as _
from django.views.decorators.cache import cache_page

from amelie.narrowcasting.models import SpotifyAssociation

Expand Down Expand Up @@ -37,69 +36,6 @@ def room(request):

return render(request, 'room.html')


@cache_page(2 * 60)
def room_pcstatus(request):
api_url = settings.ICINGA_API_HOST

if settings.ICINGA_API_PASSWORD == "":
raise ValueError(_("Icinga settings not configured."))

simple_hosts = ["lusky", "stoetenwolf", "guus"]
workstations = ["omaduck", "katrien", "cornelis", "prul", "gideon", "woerd", "dagobert", "martje",
"kwik", "kwek", "kwak", "lizzy"]

try:
res = requests.get(api_url + "objects/hosts", verify=settings.ICINGA_API_SSL_VERIFY,
auth=HTTPBasicAuth(settings.ICINGA_API_USERNAME, settings.ICINGA_API_PASSWORD))
hosts = [x for x in res.json()['results'] if x['name'] in simple_hosts or x['name'] in workstations]

res = requests.get(api_url + "objects/services", verify=settings.ICINGA_API_SSL_VERIFY,
auth=HTTPBasicAuth(settings.ICINGA_API_USERNAME, settings.ICINGA_API_PASSWORD))
services = [x for x in res.json()['results'] if x['attrs']['host_name'] in workstations]
except requests.exceptions.ConnectionError:
return JsonResponse({})

host_data = {}
for host in hosts:
host_data[host['name']] = host['attrs']
host_data[host['name']]['services'] = []

for service in services:
if service['attrs']['host_name'] in host_data.keys():
host_data[service['attrs']['host_name']]['services'].append(service)

# Construct a simple dict with only the info we need
result = {}
for host in host_data.keys():
data = host_data[host]

isup = not data['last_check_result']['output'].startswith("PING CRITICAL")

login_service_status = None
user = None
for service in data['services']:
if service['attrs']['display_name'] == "Logged in user":
login_service_status = service['attrs']['last_check_result']['output']
if login_service_status is not None:
if login_service_status.startswith("OK: No one logged in"):
user = None
elif login_service_status.startswith("OK:") and login_service_status.endswith("is logged in."):
user = login_service_status.replace("OK:", "").replace("is logged in.", "").strip()

if isup:
result[host] = "on"
if user is not None:
if user.lower() == "visitor":
result[host] = "guest"
else:
result[host] = "user"
else:
result[host] = "off"

return JsonResponse(result)


def room_spotify_callback(request):
auth_code = request.GET.get("code", None)
state = request.GET.get("state", None)
Expand Down
8 changes: 0 additions & 8 deletions amelie/settings/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,6 @@ def custom_show_toolbar(request):
# URL token. Is included in the healthcheck URL, should be set to a unique value per environment.
HEALTH_CHECK_URL_TOKEN = env("HEALTH_CHECK_URL_TOKEN", default=HEALTH_CHECK_URL_TOKEN)

###
# SysCom monitoring configuration (for room narrowcasting PC overview)
###
ICINGA_API_HOST = env("ICINGA_API_HOST", default=ICINGA_API_HOST)
ICINGA_API_USERNAME = env("ICINGA_API_USERNAME", default=ICINGA_API_USERNAME)
ICINGA_API_PASSWORD = env("ICINGA_API_PASSWORD", default=ICINGA_API_PASSWORD)


###
# Spotify settings (for room narrowcasting music displays)
###
Expand Down
8 changes: 1 addition & 7 deletions amelie/settings/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,12 +874,6 @@
# Health checks configuration
HEALTH_CHECK_URL_TOKEN = "amelie-health"

# The Icinga (Monitoring) host and details (ask the system administrators), used for the room narrowcasting page.
ICINGA_API_HOST = "https://monitoring.ia.utwente.nl:5665/v1/"
ICINGA_API_USERNAME = "iawebsite"
ICINGA_API_PASSWORD = ""
ICINGA_API_SSL_VERIFY = True

# The Spotify app details for the room narrowcasting page.
SPOTIFY_CLIENT_ID = "19f600baa77b4223b639088daa62f2f2"
SPOTIFY_CLIENT_SECRET = ""
Expand Down Expand Up @@ -929,4 +923,4 @@
BOOK_SALES_URL = "https://wo4you.nl/"

# Abbreviation of the room duty committee for access checks.
ROOM_DUTY_ABBREVIATION = "RoomDuty"
ROOM_DUTY_ABBREVIATION = "RoomDuty"

0 comments on commit 4b5dd40

Please sign in to comment.