search by hash ui
This commit is contained in:
@ -7,6 +7,8 @@ import griffon.core.mvc.MVCGroup
|
||||
import griffon.core.mvc.MVCGroupConfiguration
|
||||
import griffon.inject.MVCMember
|
||||
import griffon.metadata.ArtifactProviderFor
|
||||
import net.i2p.data.Base64
|
||||
|
||||
import javax.annotation.Nonnull
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -42,10 +44,15 @@ class MainFrameController {
|
||||
params["uuid"] = uuid.toString()
|
||||
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
||||
model.results[uuid.toString()] = group
|
||||
|
||||
// this can be improved a lot
|
||||
def terms = search.toLowerCase().trim().split(Constants.SPLIT_PATTERN)
|
||||
def searchEvent = new SearchEvent(searchTerms : terms, uuid : uuid)
|
||||
|
||||
def searchEvent
|
||||
if (model.hashSearch) {
|
||||
searchEvent = new SearchEvent(searchHash : Base64.decode(search), uuid : uuid)
|
||||
} else {
|
||||
// this can be improved a lot
|
||||
def terms = search.toLowerCase().trim().split(Constants.SPLIT_PATTERN)
|
||||
searchEvent = new SearchEvent(searchTerms : terms, uuid : uuid)
|
||||
}
|
||||
core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : true,
|
||||
replyTo: core.me.destination, receivedOn: core.me.destination,
|
||||
originator : core.me))
|
||||
@ -137,6 +144,16 @@ class MainFrameController {
|
||||
markTrust("trusted-table", TrustLevel.NEUTRAL, model.trusted)
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void keywordSearch() {
|
||||
model.hashSearch = false
|
||||
}
|
||||
|
||||
@ControllerAction
|
||||
void hashSearch() {
|
||||
model.hashSearch = true
|
||||
}
|
||||
|
||||
void mvcGroupInit(Map<String, String> args) {
|
||||
application.addPropertyChangeListener("core", {e->
|
||||
core = e.getNewValue()
|
||||
|
@ -52,6 +52,8 @@ class MainFrameModel {
|
||||
def trusted = []
|
||||
def distrusted = []
|
||||
|
||||
boolean hashSearch
|
||||
|
||||
@Observable int connections
|
||||
@Observable String me
|
||||
@Observable boolean searchButtonsEnabled
|
||||
|
@ -76,6 +76,12 @@ class MainFrameView {
|
||||
|
||||
}
|
||||
panel( constraints: BorderLayout.EAST) {
|
||||
panel {
|
||||
buttonGroup(id : "searchButtonGroup")
|
||||
radioButton(text : "Keywords", selected : true, buttonGroup : searchButtonGroup, keywordSearchAction)
|
||||
radioButton(text : "Hash", selected : false, buttonGroup : searchButtonGroup, hashSearchAction)
|
||||
|
||||
}
|
||||
button(text: "Search", searchAction)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user