-
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.
Merge pull request #118 from lucidsoftware/PROD-2927-enumerate-monito…
…ring-teams Add ability to enumerate monitoring team options in config
- Loading branch information
Showing
11 changed files
with
170 additions
and
84 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
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.