mirror of
https://github.com/corda/corda.git
synced 2024-12-27 08:22:35 +00:00
Address PR comments.
This commit is contained in:
parent
608550c920
commit
775c26c573
@ -2,7 +2,7 @@
|
||||
<configuration default="false" name="Explorer - demo nodes" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" value="net.corda.explorer.MainKt" />
|
||||
<option name="VM_PARAMETERS" value="-DAMQ_DELIVERY_DELAY_MS=15000" />
|
||||
<option name="VM_PARAMETERS" value="" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
||||
|
@ -2,7 +2,7 @@
|
||||
<configuration default="false" name="Explorer - demo nodes (simulation)" type="JetRunConfigurationType" factoryName="Kotlin" singleton="true">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" value="net.corda.explorer.MainKt" />
|
||||
<option name="VM_PARAMETERS" value="-DAMQ_DELIVERY_DELAY_MS=15000" />
|
||||
<option name="VM_PARAMETERS" value="" />
|
||||
<option name="PROGRAM_PARAMETERS" value="-S" />
|
||||
<option name="WORKING_DIRECTORY" value="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
|
||||
|
@ -18,8 +18,7 @@ import rx.Observable
|
||||
data class ProgressTrackingEvent(val stateMachineId: StateMachineRunId, val message: String) {
|
||||
companion object {
|
||||
fun createStreamFromStateMachineInfo(stateMachine: StateMachineInfo): Observable<ProgressTrackingEvent>? {
|
||||
return stateMachine.progressTrackerStepAndUpdates?.let { pair ->
|
||||
val (current, future) = pair
|
||||
return stateMachine.progressTrackerStepAndUpdates?.let { (current, future) ->
|
||||
future.map { ProgressTrackingEvent(stateMachine.id, it) }.startWith(ProgressTrackingEvent(stateMachine.id, current))
|
||||
}
|
||||
}
|
||||
@ -65,13 +64,7 @@ class StateMachineDataModel {
|
||||
private val stateMachineDataList = LeftOuterJoinedMap(stateMachineStatus, progressEvents) { id, status, progress ->
|
||||
val smStatus = status.value as StateMachineStatus.Added
|
||||
StateMachineData(id, smStatus.stateMachineName, smStatus.flowInitiator, status,
|
||||
EasyBind.map(progress) {
|
||||
if (it == null) {
|
||||
ProgressStatus(null)
|
||||
} else {
|
||||
ProgressStatus(it.message)
|
||||
}
|
||||
})
|
||||
EasyBind.map(progress) { ProgressStatus(it?.message) })
|
||||
}.getObservableValues()
|
||||
|
||||
val stateMachinesAll = stateMachineDataList
|
||||
|
@ -21,9 +21,7 @@ open class EventGenerator(val parties: List<Party>, val currencies: List<Currenc
|
||||
protected val currencyMap: MutableMap<Currency, Long> = mutableMapOf(USD to 0L, GBP to 0L) // Used for estimation of how much money we have in general.
|
||||
|
||||
protected fun addToMap(ccy: Currency, amount: Long) {
|
||||
val value = currencyMap[ccy]
|
||||
if (value != null)
|
||||
currencyMap[ccy] = Math.max(0L, value + amount)
|
||||
currencyMap.computeIfPresent(ccy) { _, value -> Math.max(0L, value + amount) }
|
||||
}
|
||||
|
||||
protected val issueCashGenerator = amountGenerator.combine(partyGenerator, issueRefGenerator, currencyGenerator) { amount, to, issueRef, ccy ->
|
||||
|
@ -23,7 +23,7 @@ import tornadofx.*
|
||||
* TODO : Predictive text?
|
||||
* TODO : Regex?
|
||||
*/
|
||||
class SearchField<T>(private val data: ObservableList<T>, val filterCriteria: List<Pair<String, (T, String) -> Boolean>>,
|
||||
class SearchField<T>(private val data: ObservableList<T>, vararg filterCriteria: Pair<String, (T, String) -> Boolean>,
|
||||
val disabledFields: List<String> = emptyList()) : UIComponent() {
|
||||
override val root: Parent by fxml()
|
||||
private val textField by fxid<TextField>()
|
||||
|
@ -102,10 +102,10 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
label("In progress") {
|
||||
graphic = FontAwesomeIconView(FontAwesomeIcon.ROCKET).apply { // Blazing fast! Try not to blink.
|
||||
graphic = FontAwesomeIconView(FontAwesomeIcon.ROCKET).apply {
|
||||
// Blazing fast! Try not to blink.
|
||||
glyphSize = 15.0
|
||||
textAlignment = TextAlignment.CENTER
|
||||
style = "-fx-fill: lightslategrey"
|
||||
@ -117,21 +117,27 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
||||
}
|
||||
|
||||
init {
|
||||
val searchField = SearchField(stateMachinesAll, listOf(
|
||||
val searchField = SearchField(stateMachinesAll,
|
||||
"Flow name" to { sm, s -> sm.stateMachineName.contains(s, true) },
|
||||
"Initiator" to { sm, s -> FlowInitiatorFormatter.format(sm.flowInitiator).contains(s, true) },
|
||||
"Flow Status" to { sm, s -> val stat = sm.stateMachineStatus.value.status ?: "No progress data"
|
||||
stat.contains(s, true) },
|
||||
"Error" to { sm, _ -> val smAddRm = sm.addRmStatus.value
|
||||
"Flow Status" to { sm, s ->
|
||||
val stat = sm.stateMachineStatus.value.status ?: "No progress data"
|
||||
stat.contains(s, true)
|
||||
},
|
||||
"Error" to { sm, _ ->
|
||||
val smAddRm = sm.addRmStatus.value
|
||||
if (smAddRm is StateMachineStatus.Removed)
|
||||
smAddRm.result.error != null
|
||||
else false },
|
||||
"Done" to { sm, _ -> val smAddRm = sm.addRmStatus.value
|
||||
else false
|
||||
},
|
||||
"Done" to { sm, _ ->
|
||||
val smAddRm = sm.addRmStatus.value
|
||||
if (smAddRm is StateMachineStatus.Removed)
|
||||
smAddRm.result.error == null
|
||||
else false },
|
||||
"In progress" to { sm, _ -> sm.addRmStatus.value !is StateMachineStatus.Removed }),
|
||||
listOf("Error", "Done", "In progress")
|
||||
else false
|
||||
},
|
||||
"In progress" to { sm, _ -> sm.addRmStatus.value !is StateMachineStatus.Removed },
|
||||
disabledFields = listOf("Error", "Done", "In progress")
|
||||
)
|
||||
root.top = searchField.root
|
||||
makeColumns(allViewTable, searchField.filteredData)
|
||||
@ -145,6 +151,7 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
||||
private val flowNameLabel by fxid<Label>()
|
||||
private val flowProgressVBox by fxid<VBox>()
|
||||
private val flowInitiatorGrid by fxid<GridPane>()
|
||||
private val flowInitiatorTitle by fxid<Label>()
|
||||
private val flowResultVBox by fxid<VBox>()
|
||||
|
||||
init {
|
||||
@ -158,19 +165,19 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
||||
}
|
||||
}
|
||||
when (smmData.flowInitiator) {
|
||||
is FlowInitiator.Shell -> makeShellGrid(flowInitiatorGrid) // TODO Extend this when we will have more information on shell user.
|
||||
is FlowInitiator.Peer -> makePeerGrid(flowInitiatorGrid, smmData.flowInitiator as FlowInitiator.Peer)
|
||||
is FlowInitiator.RPC -> makeRPCGrid(flowInitiatorGrid, smmData.flowInitiator as FlowInitiator.RPC)
|
||||
is FlowInitiator.Scheduled -> makeScheduledGrid(flowInitiatorGrid, smmData.flowInitiator as FlowInitiator.Scheduled)
|
||||
is FlowInitiator.Shell -> makeShellGrid(flowInitiatorGrid, flowInitiatorTitle) // TODO Extend this when we will have more information on shell user.
|
||||
is FlowInitiator.Peer -> makePeerGrid(flowInitiatorGrid, flowInitiatorTitle, smmData.flowInitiator as FlowInitiator.Peer)
|
||||
is FlowInitiator.RPC -> makeRPCGrid(flowInitiatorGrid, flowInitiatorTitle, smmData.flowInitiator as FlowInitiator.RPC)
|
||||
is FlowInitiator.Scheduled -> makeScheduledGrid(flowInitiatorGrid, flowInitiatorTitle, smmData.flowInitiator as FlowInitiator.Scheduled)
|
||||
}
|
||||
val status = smmData.addRmStatus.value
|
||||
if (status is StateMachineStatus.Removed) {
|
||||
status.result.match(onValue = { makeResultVBox(flowResultVBox, it) }, onError = { makeErrorVBox(flowResultVBox, it) })
|
||||
status.result.match(onValue = { makeResultVBox(flowResultVBox, it) }, onError = { makeErrorVBox(flowResultVBox, it) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T>makeResultVBox(vbox: VBox, result: T) {
|
||||
private fun <T> makeResultVBox(vbox: VBox, result: T) {
|
||||
if (result == null) {
|
||||
vbox.apply { label("No return value from flow.").apply { style { fontWeight = FontWeight.BOLD } } }
|
||||
} else if (result is SignedTransaction) {
|
||||
@ -186,8 +193,7 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
||||
}
|
||||
} else if (result is Unit) {
|
||||
vbox.apply { label("Flow completed with success.").apply { style { fontWeight = FontWeight.BOLD } } }
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// TODO Here we could have sth different than SignedTransaction/Unit
|
||||
vbox.apply {
|
||||
label("Flow completed with success. Result: ").apply { style { fontWeight = FontWeight.BOLD } }
|
||||
@ -215,19 +221,17 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
||||
}
|
||||
}
|
||||
|
||||
private fun makeShellGrid(gridPane: GridPane) {
|
||||
val title = gridPane.lookup("#flowInitiatorTitle") as Label
|
||||
private fun makeShellGrid(gridPane: GridPane, title: Label) {
|
||||
title.apply {
|
||||
text = "Flow started by shell user"
|
||||
}
|
||||
}
|
||||
|
||||
private fun makePeerGrid(gridPane: GridPane, initiator: FlowInitiator.Peer) {
|
||||
val title = gridPane.lookup("#flowInitiatorTitle") as Label
|
||||
private fun makePeerGrid(gridPane: GridPane, title: Label, initiator: FlowInitiator.Peer) {
|
||||
title.apply {
|
||||
text = "Flow started by a peer node"
|
||||
}
|
||||
gridPane.apply{
|
||||
gridPane.apply {
|
||||
row {
|
||||
label("Legal name: ") {
|
||||
gridpaneConstraints { hAlignment = HPos.LEFT }
|
||||
@ -249,8 +253,7 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
||||
}
|
||||
}
|
||||
|
||||
private fun makeRPCGrid(gridPane: GridPane, initiator: FlowInitiator.RPC) {
|
||||
val title = gridPane.lookup("#flowInitiatorTitle") as Label
|
||||
private fun makeRPCGrid(gridPane: GridPane, title: Label, initiator: FlowInitiator.RPC) {
|
||||
title.apply {
|
||||
text = "Flow started by a RPC user"
|
||||
}
|
||||
@ -267,8 +270,7 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
||||
}
|
||||
|
||||
// TODO test
|
||||
private fun makeScheduledGrid(gridPane: GridPane, initiator: FlowInitiator.Scheduled) {
|
||||
val title = gridPane.lookup("#flowInitiatorTitle") as Label
|
||||
private fun makeScheduledGrid(gridPane: GridPane, title: Label, initiator: FlowInitiator.Scheduled) {
|
||||
title.apply {
|
||||
text = "Flow started as scheduled activity"
|
||||
}
|
||||
|
@ -105,13 +105,13 @@ class TransactionViewer : CordaView("Transactions") {
|
||||
)
|
||||
}
|
||||
|
||||
val searchField = SearchField(transactions, listOf(
|
||||
val searchField = SearchField(transactions,
|
||||
"Transaction ID" to { tx, s -> "${tx.id}".contains(s, true) },
|
||||
"Input" to { tx, s -> tx.inputs.resolved.any { it.state.data.contract.javaClass.simpleName.contains(s, true) } },
|
||||
"Output" to { tx, s -> tx.outputs.any { it.state.data.contract.javaClass.simpleName.contains(s, true) } },
|
||||
"Input Party" to { tx, s -> tx.inputParties.any { it.any { it.value?.legalIdentity?.name?.commonName?.contains(s, true) ?: false } } },
|
||||
"Output Party" to { tx, s -> tx.outputParties.any { it.any { it.value?.legalIdentity?.name?.commonName?.contains(s, true) ?: false } } },
|
||||
"Command Type" to { tx, s -> tx.commandTypes.any { it.simpleName.contains(s, true) } })
|
||||
"Command Type" to { tx, s -> tx.commandTypes.any { it.simpleName.contains(s, true) } }
|
||||
)
|
||||
root.top = searchField.root
|
||||
// Transaction table
|
||||
|
@ -146,9 +146,9 @@ class CashViewer : CordaView("Cash") {
|
||||
* one which produces more results, which seems to work, as the set of currency strings don't really overlap with
|
||||
* issuer strings.
|
||||
*/
|
||||
val searchField = SearchField(cashStates, listOf(
|
||||
val searchField = SearchField(cashStates,
|
||||
"Currency" to { state, text -> state.state.data.amount.token.product.toString().contains(text, true) },
|
||||
"Issuer" to { state, text -> state.resolveIssuer().value?.name?.commonName?.contains(text, true) ?: false })
|
||||
"Issuer" to { state, text -> state.resolveIssuer().value?.name?.commonName?.contains(text, true) ?: false }
|
||||
)
|
||||
root.top = hbox(5.0) {
|
||||
button("New Transaction", FontAwesomeIconView(FontAwesomeIcon.PLUS)) {
|
||||
|
Loading…
Reference in New Issue
Block a user