added filtered user display/removal to topic management page
This commit is contained in:
+29
-1
@@ -360,9 +360,37 @@ func TopicManage(ctxt ui.AmContext) (string, any, error) {
|
|||||||
}
|
}
|
||||||
ctxt.VarMap().Set("canInvite", member)
|
ctxt.VarMap().Set("canInvite", member)
|
||||||
|
|
||||||
|
// Get the filtered users list.
|
||||||
|
bozos, err := topic.GetBozos(ctxt.Ctx(), ctxt.CurrentUser())
|
||||||
|
if err != nil {
|
||||||
|
return ui.ErrorPage(ctxt, err)
|
||||||
|
}
|
||||||
|
ctxt.VarMap().Set("bozos", bozos)
|
||||||
|
|
||||||
ctxt.VarMap().Set("subscribed", false) // TODO
|
ctxt.VarMap().Set("subscribed", false) // TODO
|
||||||
ctxt.VarMap().Set("bozos", make([]string, 0)) // TODO
|
|
||||||
|
|
||||||
ctxt.VarMap().Set("amsterdam_pageTitle", "Manage Topic: "+topic.Name)
|
ctxt.VarMap().Set("amsterdam_pageTitle", "Manage Topic: "+topic.Name)
|
||||||
return "framed_template", "manage_topic.jet", nil
|
return "framed_template", "manage_topic.jet", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TopicRemoveBozo removes filtering from a specified user in the topic.
|
||||||
|
* Parameters:
|
||||||
|
* ctxt - The AmContext for the request.
|
||||||
|
* Returns:
|
||||||
|
* Command string dictating what to be rendered.
|
||||||
|
* Data as a parameter for the command string.
|
||||||
|
* Standard Go error status.
|
||||||
|
*/
|
||||||
|
func TopicRemoveBozo(ctxt ui.AmContext) (string, any, error) {
|
||||||
|
comm := ctxt.CurrentCommunity()
|
||||||
|
topic := ctxt.GetScratch("currentTopic").(*database.Topic)
|
||||||
|
bozoUid, err := strconv.Atoi(ctxt.URLParam("uid"))
|
||||||
|
if err != nil {
|
||||||
|
return ui.ErrorPage(ctxt, err)
|
||||||
|
}
|
||||||
|
err = topic.SetBozo(ctxt.Ctx(), ctxt.CurrentUser(), int32(bozoUid), false)
|
||||||
|
if err != nil {
|
||||||
|
return ui.ErrorPage(ctxt, err)
|
||||||
|
}
|
||||||
|
return "redirect", fmt.Sprintf("/comm/%s/conf/%s/op/%d/manage", comm.Alias, ctxt.GetScratch("currentAlias"), topic.Number), nil
|
||||||
|
}
|
||||||
|
|||||||
+2
-1
@@ -181,7 +181,8 @@ func (t *Topic) GetBozos(ctx context.Context, u *User) ([]TopicBozo, error) {
|
|||||||
return make([]TopicBozo, 0), nil
|
return make([]TopicBozo, 0), nil
|
||||||
}
|
}
|
||||||
rs, err := amdb.QueryContext(ctx, `SELECT b.bozo_uid, u.username, c.given_name, c.family_name
|
rs, err := amdb.QueryContext(ctx, `SELECT b.bozo_uid, u.username, c.given_name, c.family_name
|
||||||
FROM topicbozo b, users u, contacts c WHERE b.topicid = ? AND b.uid = ? AND b.bozo_uid = u.uid AND u.contactid = c.contactid`, t.TopicId, u.Uid)
|
FROM topicbozo b, users u, contacts c WHERE b.topicid = ? AND b.uid = ? AND b.bozo_uid = u.uid AND u.contactid = c.contactid
|
||||||
|
ORDER BY u.username`, t.TopicId, u.Uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ func setupEcho() *echo.Echo {
|
|||||||
opsGroup.GET("/scribble/:msg", ui.AmWrap(ScribbleMessage))
|
opsGroup.GET("/scribble/:msg", ui.AmWrap(ScribbleMessage))
|
||||||
opsGroup.GET("/nuke/:msg", ui.AmWrap(NukeMessage))
|
opsGroup.GET("/nuke/:msg", ui.AmWrap(NukeMessage))
|
||||||
opsGroup.GET("/manage", ui.AmWrap(TopicManage))
|
opsGroup.GET("/manage", ui.AmWrap(TopicManage))
|
||||||
|
opsGroup.GET("/rmbozo/:uid", ui.AmWrap(TopicRemoveBozo))
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,39 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ if len(bozos) > 0 }}
|
{{ if len(bozos) > 0 }}
|
||||||
|
<div class="max-w-4xl mb-8">
|
||||||
|
<div class="bg-white border border-gray-300 rounded-lg overflow-hidden">
|
||||||
|
<table class="w-full">
|
||||||
|
<tbody class="divide-y divide-gray-200">
|
||||||
|
{{ range i, b := bozos }}
|
||||||
|
<tr class="hover:bg-gray-50">
|
||||||
|
<td class="px-2 py-1 whitespace-nowrap text-center w-12">
|
||||||
|
<a href="{{ opsLink }}/rmbozo/{{ b.Uid }}" class="text-2xl hover:scale-125 inline-block transition-transform"
|
||||||
|
title="Remove">❌</a>
|
||||||
|
</td>
|
||||||
|
<td class="px-2 py-1 text-sm">
|
||||||
|
<<a class="text-blue-700 hover:text-blue-900 text-sm font-bold" target="_blank" href="/user/{{ b.Username }}">{{ b.Username }}</a>>
|
||||||
|
<i>{{ b.GivenName }} {{ b.FamilyName }}</i>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{ end }}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Legend -->
|
||||||
|
<div class="max-w-4xl">
|
||||||
|
<div class="bg-blue-50 border border-blue-200 rounded-lg p-4">
|
||||||
|
<h2 class="text-blue-800 font-bold text-lg mb-3">How to update the filtered users:</h2>
|
||||||
|
<div class="space-y-2 text-sm">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<span class="text-2xl">❌</span>
|
||||||
|
<span class="text-gray-700">Click this symbol to cease filtering this user in this topic.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user