summaryrefslogtreecommitdiff
path: root/lisp/service/octopus-projects-with-roles-service.lisp
blob: c3d9a6726b112dbf7f797fc3efaacc86a9e57376 (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
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
(declaim (optimize (speed 0) (safety 3) (debug 3)))

(in-package :snow)

(defclass octopus-projects-with-roles-service (rest-service)
  ()
  (:documentation ""))

(defun octopus-projects-with-roles-json ()
  (with-noauth (instance octopus-projects-with-roles-service)
    t))

(defclass octopus-projects-with-roles/view-service (octopus-projects-with-roles-service)
  ((form :initarg :form
         :initform nil
         :accessor form)
   (location-p :initform nil))
  (:documentation ""))

(defun octopus-projects-with-roles-view-json ()
  (with-noauth (instance octopus-projects-with-roles/view-service)
    (setf (form instance)
          (make-form "octopus-projects-with-roles-form"
                     nil
                     t
                     `((:name "roles" :label "Roles (comma or space separated)" :field-type "text" :required "required" :value ,(or (session-value :octopus-roles) ""))
                       (:label "Find Projects With Roles" :field-type "button" :onclick "on_octopus_projects_with_roles_results_clicked()"))))))

(defclass octopus-projects-with-roles/results-service (octopus-projects-with-roles/view-service)
  ((stdout :initarg :stdout
           :initform nil
           :accessor stdout)
   (location-p :initform nil))
  (:documentation ""))

(defun octopus-projects-with-roles-results-json (roles)
  (with-noauth (instance octopus-projects-with-roles/results-service)
    (cl-fad:with-output-to-temporary-file (f :template "/tmp/snow/temp-%")
      (get-octopus-projects-with-roles (make-instance 'octopus-process-step
                                                      :target-roles (remove-if (lambda (x) (org-ckons-core::null-or-empty-p x)) (cl-ppcre:split "[, ]" roles))
                                                      :stdout (pathname f)))
      (setf (stdout instance) (uiop:native-namestring (pathname f))))
    (setf (session-value :octopus-roles) roles)))