Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Add campaign search UI.

Kailash Nadh378e8145fe76
diff --git a/campaigns.go b/campaigns.go
index 7c33e898..64c9cf44 100644
--- a/campaigns.go
+++ b/campaigns.go
@@ -84,7 +84,8 @@ func handleGetCampaigns(c echo.Context) error {
single = true
}
if query != "" {
- query = string(regexFullTextQuery.ReplaceAll([]byte(query), []byte("&")))
+ query = `%` +
+ string(regexFullTextQuery.ReplaceAll([]byte(query), []byte("&"))) + `%`
}
err := app.queries.QueryCampaigns.Select(&out.Results, id, pq.StringArray(status), query, pg.Offset, pg.Limit)
diff --git a/frontend/fontello/config.json b/frontend/fontello/config.json
index d8d691ab..5e8f9365 100644
--- a/frontend/fontello/config.json
+++ b/frontend/fontello/config.json
@@ -496,6 +496,20 @@
"cancel"
]
},
+ {
+ "uid": "110ec51ea49a7f0cc9bfbde321f3c28d",
+ "css": "magnify",
+ "code": 59427,
+ "src": "custom_icons",
+ "selected": true,
+ "svg": {
+ "path": "M396.5 125Q468.8 125 531.3 161.1T629.9 259.8 666 396.5Q666 496.1 601.6 572.3L613.3 584H646.5L853.5 791 791 853.5 584 646.5V613.3L572.3 601.6Q496.1 666 396.5 666 322.3 666 259.8 629.9T161.1 531.3 125 395.5 161.1 259.8 259.8 161.1 396.5 125ZM396.5 209Q318.4 209 263.7 263.7T209 396.5 263.7 529.3 396.5 584 529.3 529.3 584 396.5 529.3 263.7 396.5 209Z",
+ "width": 1000
+ },
+ "search": [
+ "magnify"
+ ]
+ },
{
"uid": "f4ad3f6d071a0bfb3a8452b514ed0892",
"css": "vector-square",
@@ -12200,20 +12214,6 @@
"magnet-on"
]
},
- {
- "uid": "110ec51ea49a7f0cc9bfbde321f3c28d",
- "css": "magnify",
- "code": 59416,
- "src": "custom_icons",
- "selected": false,
- "svg": {
- "path": "M396.5 125Q468.8 125 531.3 161.1T629.9 259.8 666 396.5Q666 496.1 601.6 572.3L613.3 584H646.5L853.5 791 791 853.5 584 646.5V613.3L572.3 601.6Q496.1 666 396.5 666 322.3 666 259.8 629.9T161.1 531.3 125 395.5 161.1 259.8 259.8 161.1 396.5 125ZM396.5 209Q318.4 209 263.7 263.7T209 396.5 263.7 529.3 396.5 584 529.3 529.3 584 396.5 529.3 263.7 396.5 209Z",
- "width": 1000
- },
- "search": [
- "magnify"
- ]
- },
{
"uid": "cd529f71c055cf2da4843aafc1d70c8d",
"css": "magnify-minus",
diff --git a/frontend/src/assets/icons/fontello.css b/frontend/src/assets/icons/fontello.css
index 10bf8e79..3d6cf7ef 100644
--- a/frontend/src/assets/icons/fontello.css
+++ b/frontend/src/assets/icons/fontello.css
@@ -75,3 +75,4 @@
.mdi-arrow-up:before { content: '\e820'; } /* '' */
.mdi-arrow-down:before { content: '\e821'; } /* '' */
.mdi-cancel:before { content: '\e822'; } /* '' */
+.mdi-magnify:before { content: '\e823'; } /* '' */
diff --git a/frontend/src/assets/icons/fontello.woff2 b/frontend/src/assets/icons/fontello.woff2
index e6a4f868..fb07f159 100644
Binary files a/frontend/src/assets/icons/fontello.woff2 and b/frontend/src/assets/icons/fontello.woff2 differ
diff --git a/frontend/src/views/Campaigns.vue b/frontend/src/views/Campaigns.vue
index c568a45d..8b99a7b3 100644
--- a/frontend/src/views/Campaigns.vue
+++ b/frontend/src/views/Campaigns.vue
@@ -3,7 +3,7 @@
<header class="columns">
<div class="column is-two-thirds">
<h1 class="title is-4">Campaigns
- <span v-if="campaigns.total > 0">({{ campaigns.total }})</span>
+ <span v-if="!isNaN(campaigns.total)">({{ campaigns.total }})</span>
</h1>
</div>
<div class="column has-text-right">
@@ -12,6 +12,16 @@
</div>
</header>
+ <form @submit.prevent="getCampaigns">
+ <b-field grouped>
+ <b-input v-model="queryParams.query"
+ placeholder="Name or subject" icon="magnify" ref="query"
+ :disabled="isSearchAdvanced"></b-input>
+ <b-button native-type="submit" type="is-primary" icon-left="magnify"
+ :disabled="isSearchAdvanced"></b-button>
+ </b-field>
+ </form>
+
<b-table
:data="campaigns.results"
:loading="loading.campaigns"
@@ -207,6 +217,7 @@ export default Vue.extend({
previewItem: null,
queryParams: {
page: 1,
+ query: '',
},
pollID: null,
campaignStatsData: {},
@@ -271,6 +282,7 @@ export default Vue.extend({
getCampaigns() {
this.$api.getCampaigns({
page: this.queryParams.page,
+ query: this.queryParams.query,
});
},
diff --git a/frontend/src/views/Lists.vue b/frontend/src/views/Lists.vue
index 7d8e124d..bbbfe246 100644
--- a/frontend/src/views/Lists.vue
+++ b/frontend/src/views/Lists.vue
@@ -2,7 +2,9 @@
<section class="lists">
<header class="columns">
<div class="column is-two-thirds">
- <h1 class="title is-4">Lists <span v-if="lists.total > 0">({{ lists.total }})</span></h1>
+ <h1 class="title is-4">Lists
+ <span v-if="!isNaN(lists.total)">({{ lists.total }})</span>
+ </h1>
</div>
<div class="column has-text-right">
<b-button type="is-primary" icon-left="plus" @click="showNewForm">New</b-button>
diff --git a/frontend/src/views/Subscribers.vue b/frontend/src/views/Subscribers.vue
index 36986094..2fb515d8 100644
--- a/frontend/src/views/Subscribers.vue
+++ b/frontend/src/views/Subscribers.vue
@@ -3,8 +3,7 @@
<header class="columns">
<div class="column is-half">
<h1 class="title is-4">Subscribers
- <span v-if="subscribers.total > 0">({{ subscribers.total }})</span>
-
+ <span v-if="!isNaN(subscribers.total)">({{ subscribers.total }})</span>
<span v-if="currentList">
&raquo; {{ currentList.name }}
</span>
@@ -21,9 +20,9 @@
<div>
<b-field grouped>
<b-input @input="onSimpleQueryInput" v-model="queryInput"
- placeholder="E-mail or name" icon="account-search-outline" ref="query"
+ placeholder="E-mail or name" icon="magnify" ref="query"
:disabled="isSearchAdvanced"></b-input>
- <b-button native-type="submit" type="is-primary" icon-left="account-search-outline"
+ <b-button native-type="submit" type="is-primary" icon-left="magnify"
:disabled="isSearchAdvanced"></b-button>
</b-field>
@@ -51,7 +50,7 @@
<div class="buttons">
<b-button native-type="submit" type="is-primary"
- icon-left="account-search-outline">Query</b-button>
+ icon-left="magnify">Query</b-button>
<b-button @click.prevent="toggleAdvancedSearch" icon-left="cancel">Reset</b-button>
</div>
</div><!-- advanced query -->
diff --git a/queries.sql b/queries.sql
index 04ab6020..62ef264a 100644
--- a/queries.sql
+++ b/queries.sql
@@ -380,7 +380,7 @@ SELECT COUNT(*) OVER () AS total, campaigns.*, (
FROM campaigns
WHERE ($1 = 0 OR id = $1)
AND status=ANY(CASE WHEN ARRAY_LENGTH($2::campaign_status[], 1) != 0 THEN $2::campaign_status[] ELSE ARRAY[status] END)
- AND ($3 = '' OR (to_tsvector(name || subject) @@ to_tsquery($3)))
+ AND ($3 = '' OR CONCAT(name, subject) ILIKE $3)
ORDER BY campaigns.updated_at DESC OFFSET $4 LIMIT $5;
-- name: get-campaign