mirror of https://github.com/zlatinb/muwire
search by hash ui
parent
1aeb230ea8
commit
14681c2060
|
@ -7,6 +7,8 @@ import griffon.core.mvc.MVCGroup
|
||||||
import griffon.core.mvc.MVCGroupConfiguration
|
import griffon.core.mvc.MVCGroupConfiguration
|
||||||
import griffon.inject.MVCMember
|
import griffon.inject.MVCMember
|
||||||
import griffon.metadata.ArtifactProviderFor
|
import griffon.metadata.ArtifactProviderFor
|
||||||
|
import net.i2p.data.Base64
|
||||||
|
|
||||||
import javax.annotation.Nonnull
|
import javax.annotation.Nonnull
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -42,10 +44,15 @@ class MainFrameController {
|
||||||
params["uuid"] = uuid.toString()
|
params["uuid"] = uuid.toString()
|
||||||
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
def group = mvcGroup.createMVCGroup("SearchTab", uuid.toString(), params)
|
||||||
model.results[uuid.toString()] = group
|
model.results[uuid.toString()] = group
|
||||||
|
|
||||||
// this can be improved a lot
|
def searchEvent
|
||||||
def terms = search.toLowerCase().trim().split(Constants.SPLIT_PATTERN)
|
if (model.hashSearch) {
|
||||||
def searchEvent = new SearchEvent(searchTerms : terms, uuid : uuid)
|
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,
|
core.eventBus.publish(new QueryEvent(searchEvent : searchEvent, firstHop : true,
|
||||||
replyTo: core.me.destination, receivedOn: core.me.destination,
|
replyTo: core.me.destination, receivedOn: core.me.destination,
|
||||||
originator : core.me))
|
originator : core.me))
|
||||||
|
@ -137,6 +144,16 @@ class MainFrameController {
|
||||||
markTrust("trusted-table", TrustLevel.NEUTRAL, model.trusted)
|
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) {
|
void mvcGroupInit(Map<String, String> args) {
|
||||||
application.addPropertyChangeListener("core", {e->
|
application.addPropertyChangeListener("core", {e->
|
||||||
core = e.getNewValue()
|
core = e.getNewValue()
|
||||||
|
|
|
@ -52,6 +52,8 @@ class MainFrameModel {
|
||||||
def trusted = []
|
def trusted = []
|
||||||
def distrusted = []
|
def distrusted = []
|
||||||
|
|
||||||
|
boolean hashSearch
|
||||||
|
|
||||||
@Observable int connections
|
@Observable int connections
|
||||||
@Observable String me
|
@Observable String me
|
||||||
@Observable boolean searchButtonsEnabled
|
@Observable boolean searchButtonsEnabled
|
||||||
|
|
|
@ -76,6 +76,12 @@ class MainFrameView {
|
||||||
|
|
||||||
}
|
}
|
||||||
panel( constraints: BorderLayout.EAST) {
|
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)
|
button(text: "Search", searchAction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue