summaryrefslogtreecommitdiff
path: root/src/bgpview/bgpview.lisp
blob: 63124c2b63c4f9d7cf91f2e49cd94b479a28d406 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-

;; Copyright 2009, NORDUnet A/S.
;;
;; This file is part of Eduroam-stats.
;;
;; Eduroam-stats is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 2 of the License, or
;; (at your option) any later version.
;;
;; Eduroam-stats is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Eduroam-stats.  If not, see <http://www.gnu.org/licenses/>.

(in-package :bgp-logger)

(defwebapp bgpview-app
    :prefix "/bgpview"
    :description "FIXME: description of bgpview app"
    :autostart nil
    :debug t)

(defstore *bgpview-store* :prevalence
  (merge-pathnames (make-pathname :directory '(:relative "data"))
                   (asdf-system-directory :bgpview)))

(defun db-test (&rest args)
  (declare (ignore args))
  (with-connection *db-spec*
    (let ((msgs (query-dao 'bgp-message
			   (:limit
			    (:select 'timestamp 'prefix 'label 'path 'nexthop
				     :from 'bgp-message)
			    20))))
      ;(dolist (m msgs) (make-instance 'dataform :data m)))))
      (render-object-view msgs '(table bgp-message)))))

(defun init-user-session (comp)
  (setf (composite-widgets comp)
	(list "Welcome to BGP View"
	      (make-instance 'composite 
			     :widgets (list "First widget."
					    (lambda (&rest args)
					      (declare (ignore args))
					      (with-html
						(:p "Second widget.")))
					    #'db-test)))))

(defun start-bgpview (&rest args)
  (apply #'start-weblocks args)
  (start-webapp 'bgpview-app))
  
(defun stop-bgpview ()
  (stop-webapp 'bgpview-app)
  (stop-weblocks))