~pepe/neil

4997a358bce1870f70f9438fddaf9da8f591349f — Josef Pospíšil 3 months ago 65f43ff
Add view client action
3 files changed, 31 insertions(+), 3 deletions(-)

M neil/guides.janet
M neil/sock/acts.janet
M templates/actions.temple
M neil/guides.janet => neil/guides.janet +8 -0
@@ 365,3 365,11 @@
  [q]
  [;all-projects (>Y active?) (>Y (name-has-match q))
   (match-n-sort q) (limit 20) (>: 0)])

(defn all-clients-match
  ```
  Path to all clients that match `q`.
  ```
  [q]
  [;all-clients (>Y (name-has-match q))
   (match-n-sort q) (limit 20) (>: 0)])

M neil/sock/acts.janet => neil/sock/acts.janet +13 -2
@@ 181,6 181,7 @@
              actions/render-dict
              @{:tasks @[]
                :projects @[]
                :clients @[]
                :actions @[]
                :running (running-task brush)}))
    "empty-actions"))


@@ 219,6 220,12 @@
      (location sck (resolve :projects/detail :id id)))
    "view-project"))

(defn view-client [sck {:id id}]
  (make-watch
    (fn [_ _ _]
      (location sck (resolve :clients/detail :id id)))
    "view-client"))

(defn view-task [sck {:id id}]
  (make-watch
    (fn [_ _ _]


@@ 259,7 266,7 @@
      (def r (running-task brush))
      (var c nil)
      (var q nil)
      (if-let [category (peg/match ~(* (<- (set "@#!")) '(to -1)) query)]
      (if-let [category (peg/match ~(* (<- (set "@#!$")) '(to -1)) query)]
        (do
          (set c (first category))
          (set q (last category)))


@@ 267,13 274,16 @@
          (set c nil)
          (set q query)))
      (def args @{:running r
                  :tasks @[] :projects @[] :actions @[]})
                  :tasks @[] :projects @[] :clients @[] :actions @[]})
      (if (or (not c) (= c "#"))
        (update args :tasks array/concat
                (retrieve brush (active-tasks-match q))))
      (if (or (not c) (= c "@"))
        (update args :projects array/concat
                (retrieve brush (active-projects-match q))))
      (if (or (not c) (= c "$"))
        (update args :clients array/concat
                (retrieve brush (all-clients-match q))))
      (when (or (not c) (= c "!"))
        (def lr (load brush (:soak brush :task/last-ran)))
        (->>


@@ 293,6 303,7 @@
      "/tasks/cancel" cancel-task
      "/tasks/done" done-task
      "/projects/:id" view-project
      "/clients/:id" view-client
      "/clear" empty-actions}))

(defn perform [sck action]

M templates/actions.temple => templates/actions.temple +10 -1
@@ 9,7 9,8 @@ $}
        call hilitePosition()"`)
(def r (args :running))
(def actions-count (+ (* (length (args :tasks)) (if r 1 2))
                      (length (args :projects)) (length (args :actions))))
                      (length (args :projects)) (length (args :clients)) 
                      (length (args :actions))))
%}
<list _="on load call hilitePosition()" id="items" position="0"
  count="{{ actions-count }}">


@@ 45,5 46,13 @@ $}
      <a class="icon-eye button pseudo" action="/projects/{{ (p :uuid) }}"></a>
    </hstack>
  {% ) %}
  {% (loop [p :in (args :clients)
              :after (++ i)]  %}
    <hstack position="{{ i }}" {- get-results -} class="item">
      <span>${{ (p :uuid) }} {{ (p :name) }}</span>
      <spacer></spacer>
      <a class="icon-eye button pseudo" action="/clients/{{ (p :uuid) }}"></a>
    </hstack>
  {% ) %}
</list>