blob: 1c50f3d3cc8c77c2e65de73c1864ffb3c1f7721a (
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 -*-
(declaim (optimize (speed 0) (safety 3) (debug 3)))
(in-package :snow)
(defparameter *menu-config* '((:id "a_menu_home" :label "Home" :handler "/home" :permissions "t")
(:id "a_menu_git_update" :label "Git Update" :handler "/git-update" :permissions "t")
(:id "a_menu_asg_recycle" :label "ASG Recycle" :handler "/asg-recycle" :permissions "t")
(:id "a_menu_unhealthy_targetgroups" :label "Find Unhealthy Targetgroups" :handler "/unhealthy-targetgroups" :permissions "t")
(:id "a_menu_tfcloud_apply" :label "TFCloud Apply" :handler "/tfcloud-apply" :permissions "t")
(:id "a_menu_octopus_machines_with_roles" :label "Octo Machines With Roles" :handler "/octopus-machines-with-roles" :permissions "t")
(:id "a_menu_octopus_environments_with_roles" :label "Octo Envs With Roles" :handler "/octopus-environments-with-roles" :permissions "t")
(:id "a_menu_octopus_projects_with_roles" :label "Octo Projects With Roles" :handler "/octopus-projects-with-roles" :permissions "t")
(:id "a_menu_octopus_ode_deploy_release" :label "Deploy Octo Release to ODEs" :handler "/octopus-ode-deploy-release" :permissions "t")
(:id "a_menu_octopus_latest_deployments" :label "Octo Latest Deployments" :handler "/octopus-latest-deployments" :permissions "t")))
(defclass menuitem ()
((id :initarg :id
:initform nil
:accessor id)
(label :initarg :label
:initform nil
:accessor label)
(handler :initarg :handler
:initform nil
:accessor handler)
(permissions :initarg :permissions
:initform nil
:accessor permissions)
(children :initarg :children
:initform nil
:accessor children))
(:documentation ""))
(defclass menu-service (base-service)
((menuitems :initarg :menuitems
:initform nil
:accessor menuitems)
(location-p :initarg :location-p
:initform nil
:accessor location-p))
(:documentation ""))
(defmethod initialize-instance :after ((menu-service menu-service) &key)
(setf (menuitems menu-service)
(mapcar (lambda (x)
(make-instance 'menuitem
:id (getf x :id)
:label (getf x :label)
:handler (getf x :handler)))
(remove-if 'null (mapcar (lambda (x)
(when (find-if (lambda (y)
(string= (getf x :permissions) y))
`("t" ,(session-value :permissions)))
x))
*menu-config*)))))
(defun menu-json ()
(with-noauth (instance menu-service)
t))
|