mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-07-07 21:07:56 +02:00
added hide test campaigns from campaigns page
Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
@@ -278,6 +278,9 @@ func (c *Campaign) GetAll(g *gin.Context) {
|
||||
}
|
||||
// parse request
|
||||
companyID := companyIDFromRequestQuery(g)
|
||||
// default to including test campaigns for backward compatibility
|
||||
// only exclude when explicitly set to "false"
|
||||
includeTestCampaigns := g.Query("includeTest") != "false"
|
||||
queryArgs, ok := c.handleQueryArgs(g)
|
||||
if !ok {
|
||||
return
|
||||
@@ -292,6 +295,7 @@ func (c *Campaign) GetAll(g *gin.Context) {
|
||||
&repository.CampaignOption{
|
||||
QueryArgs: queryArgs,
|
||||
WithCampaignTemplate: true,
|
||||
IncludeTestCampaigns: includeTestCampaigns,
|
||||
},
|
||||
)
|
||||
// handle responses
|
||||
|
||||
@@ -844,6 +844,9 @@ func (r *Campaign) GetAll(
|
||||
if err != nil {
|
||||
return result, errs.Wrap(err)
|
||||
}
|
||||
// apply test campaign filter based on options
|
||||
db = r.applyTestCampaignFilter(db, options)
|
||||
|
||||
var dbCampaigns []database.Campaign
|
||||
res := db.Find(&dbCampaigns)
|
||||
if res.Error != nil {
|
||||
|
||||
@@ -78,8 +78,10 @@ const appendQuery = (query) => {
|
||||
if (search) {
|
||||
urlQuery += `&search=${search}`;
|
||||
}
|
||||
if (includeTest) {
|
||||
if (includeTest === true) {
|
||||
urlQuery += `&includeTest=true`;
|
||||
} else if (includeTest === false) {
|
||||
urlQuery += `&includeTest=false`;
|
||||
}
|
||||
|
||||
return urlQuery;
|
||||
|
||||
@@ -226,6 +226,13 @@
|
||||
const appStateService = AppStateService.instance;
|
||||
let contextCompanyID = null;
|
||||
let campaigns = [];
|
||||
let includeTestCampaigns = true;
|
||||
|
||||
// handler for when include test campaigns toggle changes
|
||||
const handleIncludeTestToggleChange = async () => {
|
||||
await tick();
|
||||
await refreshCampaigns();
|
||||
};
|
||||
let campaignsHasNextPage = false;
|
||||
let templateMap = new BiMap({});
|
||||
let recipientGroupsByID = {};
|
||||
@@ -700,7 +707,11 @@
|
||||
|
||||
const getCampaigns = async () => {
|
||||
try {
|
||||
const res = await api.campaign.getAll(tableURLParams, contextCompanyID);
|
||||
const options = {
|
||||
...tableURLParams,
|
||||
includeTest: includeTestCampaigns
|
||||
};
|
||||
const res = await api.campaign.getAll(options, contextCompanyID);
|
||||
if (!res.success) {
|
||||
throw res.error;
|
||||
}
|
||||
@@ -1280,9 +1291,17 @@
|
||||
<HeadTitle title="Campaigns" />
|
||||
|
||||
<main>
|
||||
<div class="relative">
|
||||
<div class="flex justify-between">
|
||||
<Headline>Campaigns</Headline>
|
||||
<div class="absolute top-0 right-0">
|
||||
<div class="flex gap-4 items-center">
|
||||
<CheckboxField
|
||||
bind:value={includeTestCampaigns}
|
||||
on:change={handleIncludeTestToggleChange}
|
||||
id="includeTestCampaigns"
|
||||
inline={true}
|
||||
>
|
||||
Include test campaigns
|
||||
</CheckboxField>
|
||||
<AutoRefresh
|
||||
isLoading={false}
|
||||
onRefresh={() => {
|
||||
|
||||
Reference in New Issue
Block a user