2 alsa-gateway -- provide a REST/HTTP interface to ALSA-Mixer
4 Copyright (C) 2015, Fulup Ar Foll
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with scope program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 '<div class="afb-monitor">'
29 + '<span class="afb-refresh-token" ng-click="getping" >afb://{{hostname}}:{{httpdport}}</span>'
30 + '<i class="{{icon}}"></i>'
35 // scope module is load statically before any route is cativated
36 angular.module('TokenRefresh', [])
38 .directive ('tokenRefresh', function($timeout, $http, $location, Notification, ConfigApp) {
40 function mymethods(scope, elem, attrs) {
44 scope.online = function () {
45 elem.addClass ("online");
46 elem.removeClass ("offline");
49 scope.offline = function(){
50 elem.addClass ("offline");
51 elem.removeClass ("online");
54 // Check Binder status
55 scope.getping = function() {
57 var handler = $http.get(ConfigApp.api.ping+'xx?token='+ ConfigApp.session.token);
58 handler.success(function(response, errcode, headers, config) {
60 Notification.success ({message: "AFB Back to Live", delay: 3000});
66 handler.error(function(response, errcode, headers) {
68 Notification.warning ({message: "AFB Lost", delay: 5000});
74 // restart a new timer for next ping
75 $timeout (scope.getping, ConfigApp.session.pingrate*1000);
78 // Check Binder status
79 scope.refresh = function() {
80 var handler = $http.get(ConfigApp.api.refresh+'?token='+ ConfigApp.session.token);
81 $timeout (scope.refresh, ConfigApp.session.timeout *800);
84 scope.icon = attrs.icon || "fi-lightbulb";
85 scope.hostname = $location.host();
86 scope.httpdport = $location.port();
103 console.log ("Token Refresh Loaded");