-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally change trigger monitoring team into a dropdown of teams en…
…umerated in a local file
- Loading branch information
Tanner Jorgensen
committed
Jan 22, 2025
1 parent
ee6d51d
commit d558507
Showing
10 changed files
with
167 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
admin/app/com/lucidchart/piezo/admin/models/MonitoringTeams.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.lucidchart.piezo.admin.models | ||
|
||
import play.api.Configuration | ||
import java.nio.file.Files | ||
import play.api.libs.json.Json | ||
import scala.util.Try | ||
import java.io.File | ||
import java.io.FileInputStream | ||
import play.api.libs.json.JsArray | ||
import play.api.Logging | ||
import scala.util.control.NonFatal | ||
import scala.util.Failure | ||
|
||
case class MonitoringTeams(value: Seq[String]) { | ||
def teamsDefined: Boolean = value.nonEmpty | ||
} | ||
object MonitoringTeams extends Logging { | ||
def apply(configuration: Configuration): MonitoringTeams = { | ||
val path = configuration.getOptional[String]("com.lucidchart.piezo.admin.monitoringTeams.path") | ||
|
||
val value = path.flatMap { p => | ||
Try { | ||
Json.parse(new FileInputStream(p)) | ||
.as[JsArray] | ||
.value | ||
.map(entry => (entry \ "name").as[String]) | ||
.toSeq | ||
}.recoverWith { | ||
case NonFatal(e) => | ||
logger.error(s"Error reading monitoring teams from $p", e) | ||
Failure(e) | ||
}.toOption | ||
}.getOrElse(Seq.empty) | ||
|
||
MonitoringTeams(value) | ||
} | ||
|
||
def empty: MonitoringTeams = MonitoringTeams(Seq.empty) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
window.addEventListener('load', () => { | ||
const priorityInput = document.getElementById('triggerMonitoringPriority'); | ||
const setMonitoringFieldVisibility = () => { | ||
const priority = priorityInput.value; | ||
const monitoringDetails = document.getElementById('triggerMonitoringDetails'); | ||
if (priority == 'Off') { | ||
monitoringDetails.style.display = 'none'; // hide | ||
} else { | ||
monitoringDetails.style.display = 'block'; // show | ||
} | ||
}; | ||
|
||
priorityInput.addEventListener('change', setMonitoringFieldVisibility); | ||
setMonitoringFieldVisibility(); | ||
}, {once: true}); |
Oops, something went wrong.