Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions admin/app/com/lucidchart/piezo/admin/controllers/Jobs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -485,24 +485,14 @@ class Jobs(
)
}

def jobGroupTypeAhead(sofar: String): Action[AnyContent] = Action { request =>
val groups = scheduler.getJobGroupNames().asScala.toList

Ok(Json.obj("groups" -> groups.filter { group =>
group.toLowerCase.contains(sofar.toLowerCase)
}))
}

def jobNameTypeAhead(group: String, sofar: String): Action[AnyContent] =
def jobNameTypeAhead(group: String): Action[AnyContent] =
Comment thread
jjudd marked this conversation as resolved.
Action { request =>
val jobs =
scheduler.getJobKeys(GroupMatcher.jobGroupEquals(group)).asScala.toSet

Ok(
Json.obj(
"jobs" -> jobs
.filter(_.getName.toLowerCase.contains(sofar.toLowerCase))
.map(_.getName),
Json.toJson(
jobs.map(_.getName),
),
)
}
Expand Down
14 changes: 6 additions & 8 deletions admin/app/com/lucidchart/piezo/admin/controllers/Triggers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Triggers(
Ok(
com.lucidchart.piezo.admin.views.html.editTrigger(
TriggerHelper.getTriggersByGroup(scheduler),
scheduler.getJobGroupNames().asScala,
monitoringTeams.value,
newTriggerForm,
formNewAction,
Expand Down Expand Up @@ -225,6 +226,7 @@ class Triggers(
Ok(
com.lucidchart.piezo.admin.views.html.editTrigger(
TriggerHelper.getTriggersByGroup(scheduler),
scheduler.getJobGroupNames().asScala,
monitoringTeams.value,
editTriggerForm,
formNewAction,
Expand All @@ -236,6 +238,7 @@ class Triggers(
Ok(
com.lucidchart.piezo.admin.views.html.editTrigger(
TriggerHelper.getTriggersByGroup(scheduler),
scheduler.getJobGroupNames().asScala,
monitoringTeams.value,
editTriggerForm,
formEditAction(group, name),
Expand All @@ -259,6 +262,7 @@ class Triggers(
BadRequest(
com.lucidchart.piezo.admin.views.html.editTrigger(
TriggerHelper.getTriggersByGroup(scheduler),
scheduler.getJobGroupNames().asScala,
monitoringTeams.value,
formWithErrors,
formEditAction(group, name),
Expand Down Expand Up @@ -289,6 +293,7 @@ class Triggers(
BadRequest(
com.lucidchart.piezo.admin.views.html.editTrigger(
TriggerHelper.getTriggersByGroup(scheduler),
scheduler.getJobGroupNames().asScala,
monitoringTeams.value,
formWithErrors,
formNewAction,
Expand Down Expand Up @@ -316,6 +321,7 @@ class Triggers(
Ok(
com.lucidchart.piezo.admin.views.html.editTrigger(
TriggerHelper.getTriggersByGroup(scheduler),
scheduler.getJobGroupNames().asScala,
monitoringTeams.value,
form,
formNewAction,
Expand All @@ -329,14 +335,6 @@ class Triggers(
)
}

def triggerGroupTypeAhead(sofar: String): Action[AnyContent] = Action { implicit request =>
val groups = scheduler.getTriggerGroupNames().asScala.toList

Ok(Json.obj("groups" -> groups.filter { group =>
group.toLowerCase.contains(sofar.toLowerCase)
}))
}

def triggerJob(group: String, name: String): Action[AnyContent] = Action { request =>
val jobKey = new JobKey(name, group)

Expand Down
93 changes: 93 additions & 0 deletions admin/app/com/lucidchart/piezo/admin/views/Icon.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.lucidchart.piezo.admin.views

import play.twirl.api.Html

object Icon {
private def icon(name: String, body: String): Html =
Html(
s"""<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-$name" viewBox="0 0 16 16" aria-hidden="true">$body</svg>""",
)

// The content for these SVGs was taken from https://icons.getbootstrap.com/
// But only the body of the svg was kept, to factor out the boilerplate
//
// They are licensed under the following terms:
// The MIT License (MIT)
//
// Copyright (c) 2019-2024 The Bootstrap Authors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

val download: Html = icon(
"download",
Comment thread
tmccombs marked this conversation as resolved.
"""
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5"/>
<path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z"/>
""",
)
val duplicate: Html = icon(
"copy",
"""
<path fill-rule="evenodd" d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z"/>
""",
)
val flash: Html = icon(
"lightning-charge-fill",
"""
<path d="M11.251.068a.5.5 0 0 1 .227.58L9.677 6.5H13a.5.5 0 0 1 .364.843l-8 8.5a.5.5 0 0 1-.842-.49L6.323 9.5H3a.5.5 0 0 1-.364-.843l8-8.5a.5.5 0 0 1 .615-.09z"/>
""",
)
val pause: Html = icon(
"pause-fill",
"""
<path d="M5.5 3.5A1.5 1.5 0 0 1 7 5v6a1.5 1.5 0 0 1-3 0V5a1.5 1.5 0 0 1 1.5-1.5m5 0A1.5 1.5 0 0 1 12 5v6a1.5 1.5 0 0 1-3 0V5a1.5 1.5 0 0 1 1.5-1.5"/>
""",
)
val pencil: Html = icon(
"pencil-fill",
"""
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.5.5 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11z"/>
""",
)
val play: Html = icon(
"play-fill",
"""
<path d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393"/>
""",
)
val plus: Html = icon(
"plus-circle",
"""
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>
""",
)
val question: Html = icon(
"question-circle-fill",
"""
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/>
""",
)
val remove: Html = icon(
"x-lg",
"""
<path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/>
""",
)
}
55 changes: 20 additions & 35 deletions admin/app/com/lucidchart/piezo/admin/views/editJob.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
formAction: play.api.mvc.Call,
existing: Boolean,
errorMessage: Option[String] = None,
scripts: List[String] = List[String]("js/jobData.js", "js/typeAhead.js")
scripts: List[String] = List[String]("js/jobData.js")
)(
implicit
request: play.api.mvc.Request[AnyContent],
Expand All @@ -25,44 +25,29 @@ <h3>Edit Job</h3>
<h3>New Job</h3>
}

<h4 class="text-danger">@jobForm.errors.filter(_.key == "").map(_.message).mkString(", ")</h4>
<form role="form" action="@formAction" method="POST">
<div class="form-horizontal">
@defining(if(existing) {Symbol("readonly")} else {Symbol("none")}) { newEditOnly =>
<h4 class="text-danger">@jobForm.errors.filter(_.key == "").map(_.message).mkString(", ")</h4>
<form role="form" action="@formAction" method="POST">
@defining(if(existing) {Symbol("readonly")} else {Symbol("none")}) { newEditOnly =>

@helper.inputText(jobForm("group"), Symbol("_label") -> "Group", Symbol("labelClass") -> "col-sm-3 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("placeholder") -> "Group", newEditOnly -> None, Symbol("class") -> "job-group-type-ahead form-control form-inline-control")
@helper.inputText(jobForm("name"), Symbol("_label") -> "Name", Symbol("labelClass") -> "col-sm-3 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("placeholder") -> "Name", newEditOnly -> None, Symbol("class") -> "form-control form-inline-control")
@helper.inputText(jobForm("class"), Symbol("_label") -> "Class", Symbol("labelClass") -> "col-sm-3 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("placeholder") -> "Name", Symbol("class") -> "form-control form-inline-control")
@helper.inputText(jobForm("description"), Symbol("_label") -> "Description", Symbol("labelClass") -> "col-sm-3 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("placeholder") -> "Description", Symbol("class") -> "form-control form-inline-control")
@helper.checkbox(jobForm("durable"), Symbol("_label") -> "Durable", Symbol("labelClass") -> "col-sm-3 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("readonly") -> None, Symbol("class") -> "form-inline-control", Symbol("checked") -> true, Symbol("disabled") -> true, Symbol("id") -> "durable-placeholder")
@if(!existing) {
<datalist id="job-groups-list">
@jobsByGroup.map { case (name, _) =>
<option value="@name"></option>
}
</datalist>
}

<input type="hidden" id="durable" name="durable" value="true" readonly="true" />
@helper.inputText(jobForm("group"), Symbol("_label") -> "Group", Symbol("placeholder") -> "Group", newEditOnly -> None, Symbol("class") -> "form-control", Symbol("list") -> "job-groups-list")
@helper.inputText(jobForm("name"), Symbol("_label") -> "Name", Symbol("placeholder") -> "Name", newEditOnly -> None, Symbol("class") -> "form-control") @helper.inputText(jobForm("class"), Symbol("_label") -> "Class", Symbol("placeholder") -> "Name", Symbol("class") -> "form-control")
@helper.inputText(jobForm("description"), Symbol("_label") -> "Description", Symbol("placeholder") -> "Description", Symbol("class") -> "form-control") @helper.checkbox(jobForm("durable"), Symbol("_label") -> "Durable", Symbol("readonly") -> None, Symbol("class") -> "form-check-input my-auto ms-3", Symbol("checked") -> true, Symbol("disabled") -> true, Symbol("id") -> "durable-placeholder")

@helper.checkbox(jobForm("requests-recovery"), Symbol("_label") -> "Requests recovery", Symbol("labelClass") -> "col-sm-3 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("class") -> "form-inline-control")
<input type="hidden" id="durable" name="durable" value="true" readonly="true" />

<h4>Job Data Map</h4>
@helper.checkbox(jobForm("requests-recovery"), Symbol("_label") -> "Requests recovery", Symbol("class") -> "form-check-input my-auto ms-3") }

<div class="job-data-map">
@helper.repeat(jobForm("job-data-map"), min = jobForm("job-data-map").indexes.length + 1) { dataMap =>
@com.lucidchart.piezo.admin.views.html.jobDataMap(jobForm("job-data-map"))

@dataMap("key").value.map { _ =>
@dataMap("value").value.map { _ =>
<div class="job-data-delete text-right"><a href="#">delete</a></div>
}
}

@helper.inputText(dataMap("key"), Symbol("_label") -> "Key", Symbol("labelClass") -> "col-sm-3 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("placeholder") -> "Key", Symbol("class") -> "job-data-key form-control form-inline-control")
@helper.inputText(dataMap("value"), Symbol("_label") -> "Value", Symbol("labelClass") -> "col-sm-3 text-right", Symbol("inputDivClass") -> "col-sm-4", Symbol("placeholder") -> "Value", Symbol("class") -> "job-data-value form-control form-inline-control")

}

<div class="job-data-add text-right"><a href="#">add</a></div>
</div>
}

</div>

<button type="submit" class="btn btn-default submit-btn">@submitValue</button>
<button type="button" class="btn btn-default submit-btn" onclick="history.back();" value="Cancel">Cancel</button>
</form>
<button type="submit" class="btn btn-primary submit-btn">@submitValue</button>
<button type="button" class="btn btn-danger submit-btn" onclick="history.back()" value="Cancel">Cancel</button>
</form>
}
Loading
Loading