rustploy-gui 0.1.1

Rustploy — desktop client (glacier-ui) for the Rustploy PaaS daemon
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
// Janela "Novo job": motor Glacier próprio, aberto por open_window a partir
// do app principal (handlers/jobs.luau → open_new_job_window), que semeia a
// conexão + os catálogos de projetos/serviços já buscados pela janela
// principal (open_window({ data = ...
screen(title = "Novo job — Rustploy") {
  resources {
    component(name = SemProjetosParaJob) {
      text(class = muted, content = "Nenhum projeto ainda.")
    }

    link(rel = import, href = "components/picker_row.gvb", as = PickerRow)
    link(rel = import, href = "components/tab_button.gvb", as = TabButton)

    style """
      /* Titlebar custom (mesma linguagem visual do app.gv) */
      .titlebar       { width: fill; height: 32; background: var(--surface); align-y: center; }
      .titlebar_drag  { width: fill; height: fill; align-y: center; padding: 0 0 0 16; spacing: 9; }
      .titlebar_dot   { size: 10; color: var(--blue); }
      .titlebar_title { size: 12; bold: true; color: var(--muted); }
      .win_btn        { width: 48; padding: 5 0; color: var(--border); text-align: center; }
      .win_close      { width: 48; padding: 5 0; color: var(--danger); text-align: center; }

      .njob_screen { width: fill; height: fill; }
      .njob_body   { width: fill; height: fill; }

      .np_label   { size: 11; bold: true; color: var(--muted); }
      .np_input   { width: fill; }
      .np_group   { width: fill; spacing: 6; }
      .np_actions { width: fill; spacing: 10; align-y: center; }
      .np_spacer  { width: fill; }
    """

    script(src = "scripts/new_job_window.luau")
  }

  column(class = njob_screen) {
    row(class = titlebar) {
      row(class = titlebar_drag, on_press = window:drag) {
        text(class = titlebar_dot, content = "●")
        text(class = titlebar_title, content = "Novo job — Rustploy")
      }

      button(class = win_btn, on_click = window:minimize, text = "—")
      button(class = win_close, on_click = window:close, text = "✕")
    }

    scrollable(class = njob_body, direction = vertical) {
      column(class = form_panel) {
        // Passo 1: escolher o projeto
        if @njob_step == "pick_project" {
          text(class = label_cap, content = "ESCOLHA O PROJETO")

          text(
            class = muted,
            content = """
              O job sobe um stack docker-compose próprio; o projeto define a
              rede.
            """,
          )

          column(class = kv_list) {
            each @njob_projects as p (fallback = SemProjetosParaJob) {
              PickerRow(
                title = @p.name,
                subtitle = "",
                button_label = "Selecionar ›",
                action = njob_pick_project:@p.id,
              )
            }
          }

          row(class = np_actions) {
            column(class = np_spacer)
            button(class = btn_ghost, on_click = cancel, text = Cancelar)
          }
        }

        if @njob_step == "pick_service" {
          text(
            class = label_cap,
            content = "SERVIÇO GATILHO (OPCIONAL) — @njob_project_name",
          )

          text(
            class = muted,
            content = """
              Empresta env vars/secrets de base ao job (a rede Docker já vem do
              projeto). O job não roda dentro do container dele — sobe um stack
              novo, próprio. Sem serviço gatilho, o job é 100% autônomo e só
              recebe as env vars do projeto.
            """,
          )

          row(class = env_add) {
            button(
              class = btn_ghost,
              on_click = njob_pick_no_service,
              text = "Nenhum — job autônomo ›",
            )
          }

          text(
            if = @njob_services_filtered,
            equals = "[]",
            class = muted,
            content = "Este projeto ainda não tem serviços.",
          )

          column(class = kv_list) {
            PickerRow(
              :for-each = njob_services_filtered,
              var = s,
              title = @s.name,
              subtitle = "",
              button_label = "Selecionar ›",
              action = njob_pick_service:@s.id,
            )
          }

          row(class = np_actions) {
            column(class = np_spacer)
            button(class = btn_ghost, on_click = njob_back, text = "‹ Voltar")
          }
        }

        if @njob_step == "form" {
          if @njob_edit_id != "" {
            text(class = label_cap, content = "EDITAR JOB — @njob_name")
          } else {
            text(
              class = label_cap,
              content = "NOVO JOB — @njob_project_name / @njob_service_name",
            )
          }

          form(
            name = njob_form,
            on_submit = njob_create,
            width = fill,
            spacing = 10,
          ) {
            text(class = np_label, content = "NOME")

            input(
              class = np_input,
              form_control = njob_name,
              :value = njob_name,
              on_change = field:njob_name,
              placeholder = "ex.: backup-db",
            )

            text(class = label_cap, content = "FONTE DO COMPOSE")

            row(class = tabs) {
              TabButton(
                label = Compose,
                current = @njob_source,
                target = compose,
                action = njob_source:compose,
              )

              TabButton(
                label = Git,
                current = @njob_source,
                target = git,
                action = njob_source:git,
              )
            }

            if @njob_source == "compose" {
              text(class = np_label, content = "DOCKER-COMPOSE.YML")

              textarea(
                class = env_editor,
                font = mono,
                :value = njob_compose,
                placeholder = l"""
                  services:
                    job:
                      image: busybox
                      command: ["sh", "-c", "echo ok"]
                """,
              )
            }

            if @njob_source == "git" {
              text(
                class = muted,
                content = """
                  Selecione a conta conectada, o repositório e a branch. O repo
                  precisa já ter um docker-compose.yml no caminho informado.
                """,
              )

              row(class = busy_row, if = @njob_git_msg, not_equals = "") {
                spinner(class = busy_spin, if = @njob_git_busy)
                text(class = muted, content = "@njob_git_msg")
              }

              text(class = np_label, content = "CONTA GIT")

              select(
                class = select,
                :options = njob_git_providers,
                :value = njob_git_provider_id,
                on_change = njob_git_provider_pick,
                placeholder = "selecione a conta",
                labelField = display,
                valueField = id,
              )

              text(class = muted, content = "Conecte contas em Settings → Git.")
              text(class = np_label, content = "REPOSITÓRIO")

              select(
                class = select,
                :options = njob_git_repos,
                :value = njob_git_repo,
                on_change = njob_git_repo_pick,
                placeholder = "selecione o repositório",
                labelField = full_name,
                valueField = full_name,
              )

              text(class = np_label, content = "BRANCH")

              select(
                class = select,
                :options = njob_git_branches,
                :value = njob_git_branch,
                on_change = field:njob_git_branch,
                placeholder = "selecione a branch",
                labelField = name,
                valueField = name,
              )

              text(class = np_label, content = "CAMINHO DO COMPOSE NO REPO")

              input(
                class = np_input,
                form_control = njob_compose_path,
                :value = njob_compose_path,
                on_change = field:njob_compose_path,
                placeholder = docker-compose.yml,
              )
            }

            text(
              class = np_label,
              content = "MAIN SERVICE (nome dentro do compose acima)",
            )

            input(
              class = np_input,
              form_control = njob_main_service,
              :value = njob_main_service,
              on_change = field:njob_main_service,
              placeholder = "ex.: job",
            )

            text(class = np_label, content = "VARIÁVEIS DE AMBIENTE (opcional)")

            text(
              class = muted,
              content = """
                Sobrescrevem as do projeto/serviço gatilho por cima. Formato
                KEY=VALUE, uma por linha (# comentário).
              """,
            )

            textarea(
              class = env_editor,
              font = mono,
              :value = njob_env_text,
              placeholder = "FLOW_MYENV=test",
            )

            text(class = label_cap, content = "RECORRÊNCIA")

            row(class = tabs) {
              TabButton(
                label = Manual,
                current = @njob_kind,
                target = manual,
                action = njob_kind:manual,
              )

              TabButton(
                label = Intervalo,
                current = @njob_kind,
                target = interval,
                action = njob_kind:interval,
              )

              TabButton(
                label = Diária,
                current = @njob_kind,
                target = daily,
                action = njob_kind:daily,
              )

              TabButton(
                label = Semanal,
                current = @njob_kind,
                target = weekly,
                action = njob_kind:weekly,
              )
            }

            if @njob_kind == "interval" {
              text(class = np_label, content = "A CADA QUANTAS HORAS")

              // Teto de 168 = uma semana, igual ao da limpeza automática em
              // home.gv. Acima disso existe a recorrência "Semanal".
              spinbox(
                field_class = spin_field,
                form_control = njob_hours,
                :value = njob_hours,
                min = 1,
                max = 168,
                width = 90,
                placeholder = 6,
              )
            }

            if @njob_kind == "daily" {
              row(class = env_add) {
                column(class = np_group) {
                  text(class = np_label, content = "HORÁRIO")
                  timeedit(:value = njob_time)
                }
              }
            }

            if @njob_kind == "weekly" {
              text(class = np_label, content = "DIA DA SEMANA")

              // Mesma troca de home.gv: sete <TabButton> + handler viraram um
              // <radiogroup>, que grava `njob_weekday` sozinho.
              row(class = tabs) {
                radiogroup(
                  :value = njob_weekday,
                  :items = weekdays,
                  layout = row,
                )
              }

              row(class = env_add) {
                column(class = np_group) {
                  text(class = np_label, content = "HORÁRIO")
                  timeedit(:value = njob_time)
                }
              }
            }

            text(
              if = @njob_err,
              not_equals = "",
              class = err,
              content = "@njob_err",
            )

            row(class = busy_row, if = @njob_msg, not_equals = "") {
              spinner(class = busy_spin, if = @njob_busy)
              text(class = muted, content = "@njob_msg")
            }

            row(class = np_actions) {
              column(class = np_spacer)

              button(
                class = btn_ghost,
                if = @njob_edit_id,
                not_equals = "",
                on_click = njob_back,
                text = Fechar,
              )

              button(
                class = btn_ghost,
                if = @njob_edit_id,
                equals = "",
                on_click = njob_back,
                text = "‹ Voltar",
              )

              button(
                class = btn_primary,
                if = @njob_edit_id,
                not_equals = "",
                on_click = njob_create,
                text = Salvar,
              )

              button(
                class = btn_primary,
                if = @njob_edit_id,
                equals = "",
                on_click = njob_create,
                text = "Criar job",
              )
            }
          }
        }
      }
    }
  }
}