List sources not in a channel on channel edit page

This commit is contained in:
Tim Van Baak 2025-02-21 07:37:18 -08:00
parent 42ee09b386
commit 154a4fc904
2 changed files with 16 additions and 1 deletions

View File

@ -22,6 +22,11 @@ func GetSourcesInChannel(db DB) (map[string][]string, error) {
rows, err := db.Query(` rows, err := db.Query(`
select name, source select name, source
from channels from channels
union
select '' as name, sources.name as source
from sources
left outer join channels on channels.source = sources.name
where channels.name is null
order by name, source order by name, source
`) `)
if err != nil { if err != nil {

View File

@ -29,6 +29,7 @@
</datalist> </datalist>
{{ range $channel, $sources := .ChannelSources }} {{ range $channel, $sources := .ChannelSources }}
{{ if $channel }}
<p><b><a href="/channel/{{ $channel }}">{{ $channel }}</a></b></p> <p><b><a href="/channel/{{ $channel }}">{{ $channel }}</a></b></p>
<table> <table>
{{- range $sources }} {{- range $sources }}
@ -42,8 +43,17 @@
<td><a href="/source/{{ . }}">{{ . }}</a></td> <td><a href="/source/{{ . }}">{{ . }}</a></td>
</tr> </tr>
{{ end }} {{ end }}
</table> </table>
{{ end }} {{ end }}
{{ end }}
{{ if index .ChannelSources "" }}
<p><b>not in a channel</b></p>
<ul>
{{ range index .ChannelSources "" }}
<li><a href="/source/{{ . }}">{{ . }}</a></li>
{{ end }}
</ul>
{{ end }}
</nav> </nav>
{{- end }} {{- end }}