forked from rc/aircox
work on monitor
This commit is contained in:
@ -106,22 +106,30 @@ class Monitor(View,TemplateResponseMixin,LoginRequiredMixin):
|
||||
station = stations.stations.filter(name = POST.get('station')) \
|
||||
.first()
|
||||
if not station:
|
||||
return HttpResponse('')
|
||||
station.prepare(fetch=True)
|
||||
return Http404()
|
||||
|
||||
source = None
|
||||
if 'source' in POST:
|
||||
source = next([ s for s in station.sources
|
||||
if s.name == POST['source']], None)
|
||||
|
||||
if station and action == 'skip':
|
||||
if source:
|
||||
source.skip()
|
||||
else:
|
||||
station.streamer.skip()
|
||||
source = [ s for s in station.sources
|
||||
if s.name == POST['source']]
|
||||
source = source[0]
|
||||
if not source:
|
||||
return Http404
|
||||
|
||||
station.streamer.fetch()
|
||||
source = source or station.streamer.current_source
|
||||
if action == 'skip':
|
||||
self.actionSkip(request, station, source)
|
||||
if action == 'restart':
|
||||
self.actionRestart(request, station, source)
|
||||
return HttpResponse('')
|
||||
|
||||
def actionSkip(self, request, station, source):
|
||||
source.skip()
|
||||
|
||||
def actionRestart(self, request, station, source):
|
||||
source.restart()
|
||||
|
||||
|
||||
class StatisticsView(View,TemplateResponseMixin,LoginRequiredMixin):
|
||||
template_name = 'aircox/controllers/stats.html'
|
||||
|
Reference in New Issue
Block a user