mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-04-29 14:41:43 +02:00
reduce code in tag svelte view
This commit is contained in:
parent
48fa75386c
commit
e3653daea3
@ -45,7 +45,7 @@ func (r *JobRepository) AddTag(user *schema.User, job int64, tag int64) ([]*sche
|
|||||||
return tags, archive.UpdateTags(j, archiveTags)
|
return tags, archive.UpdateTags(j, archiveTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes a tag from a job by its ID
|
// Removes a tag from a job by tag id
|
||||||
func (r *JobRepository) RemoveTag(user *schema.User, job, tag int64) ([]*schema.Tag, error) {
|
func (r *JobRepository) RemoveTag(user *schema.User, job, tag int64) ([]*schema.Tag, error) {
|
||||||
j, err := r.FindByIdWithUser(user, job)
|
j, err := r.FindByIdWithUser(user, job)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -146,7 +146,7 @@ func (r *JobRepository) RemoveTagByRequest(tagType string, tagName string, tagSc
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes a tag from db by tag info
|
// Removes a tag from db by tag id
|
||||||
func (r *JobRepository) RemoveTagById(tagID int64) error {
|
func (r *JobRepository) RemoveTagById(tagID int64) error {
|
||||||
// Handle Delete JobTagTable
|
// Handle Delete JobTagTable
|
||||||
qJobTag := sq.Delete("jobtag").Where("jobtag.tag_id = ?", tagID)
|
qJobTag := sq.Delete("jobtag").Where("jobtag.tag_id = ?", tagID)
|
||||||
|
@ -80,58 +80,28 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="d-inline-flex flex-wrap">
|
<div class="d-inline-flex flex-wrap">
|
||||||
{#each tagList as tag (tag.id)}
|
{#each tagList as tag (tag.id)}
|
||||||
{#if tag.scope == "global"}
|
<InputGroup class="w-auto flex-nowrap" style="margin-right: 0.5rem; margin-bottom: 0.5rem;">
|
||||||
<InputGroup class="w-auto flex-nowrap" style="margin-right: 0.5rem; margin-bottom: 0.5rem;">
|
<Button outline color="secondary" href="/monitoring/jobs/?tag={tag.id}" target="_blank">
|
||||||
<Button outline color="secondary" href="/monitoring/jobs/?tag={tag.id}" target="_blank">
|
<Badge color="light" style="font-size:medium;" border>{tag.name}</Badge> :
|
||||||
<Badge color="light" style="font-size:medium;" border>{tag.name}</Badge> :
|
<Badge color="primary" pill>{tag.count} Job{(tag.count != 1)?'s':''}</Badge>
|
||||||
<Badge color="primary" pill>{tag.count} Job{(tag.count != 1)?'s':''}</Badge>
|
{#if tag.scope == "global"}
|
||||||
<Badge style="background-color:#c85fc8 !important;" pill>Global</Badge>
|
<Badge style="background-color:#c85fc8 !important;" pill>Global</Badge>
|
||||||
</Button>
|
{:else if tag.scope == "admin"}
|
||||||
{#if isAdmin}
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
color="danger"
|
|
||||||
on:click={() => removeTag(tag, tagType)}
|
|
||||||
>
|
|
||||||
<Icon name="x" />
|
|
||||||
</Button>
|
|
||||||
{/if}
|
|
||||||
</InputGroup>
|
|
||||||
{:else if tag.scope == "admin"}
|
|
||||||
<InputGroup class="w-auto flex-nowrap" style="margin-right: 0.5rem; margin-bottom: 0.5rem;">
|
|
||||||
<Button outline color="secondary" href="/monitoring/jobs/?tag={tag.id}" target="_blank">
|
|
||||||
<Badge color="light" style="font-size:medium;" border>{tag.name}</Badge> :
|
|
||||||
<Badge color="primary" pill>{tag.count} Job{(tag.count != 1)?'s':''}</Badge>
|
|
||||||
<Badge style="background-color:#19e5e6 !important;" pill>Admin</Badge>
|
<Badge style="background-color:#19e5e6 !important;" pill>Admin</Badge>
|
||||||
</Button>
|
{:else}
|
||||||
{#if isAdmin}
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
color="danger"
|
|
||||||
on:click={() => removeTag(tag, tagType)}
|
|
||||||
>
|
|
||||||
<Icon name="x" />
|
|
||||||
</Button>
|
|
||||||
{/if}
|
|
||||||
</InputGroup>
|
|
||||||
{:else}
|
|
||||||
<InputGroup class="w-auto flex-nowrap" style="margin-right: 0.5rem; margin-bottom: 0.5rem;">
|
|
||||||
<Button outline color="secondary" href="/monitoring/jobs/?tag={tag.id}" target="_blank">
|
|
||||||
<Badge color="light" style="font-size:medium;" border>{tag.name}</Badge> :
|
|
||||||
<Badge color="primary" pill>{tag.count} Job{(tag.count != 1)?'s':''}</Badge>
|
|
||||||
<Badge color="warning" pill>Private</Badge>
|
<Badge color="warning" pill>Private</Badge>
|
||||||
</Button>
|
|
||||||
{#if tag.scope == username}
|
|
||||||
<Button
|
|
||||||
size="sm"
|
|
||||||
color="danger"
|
|
||||||
on:click={() => removeTag(tag, tagType)}
|
|
||||||
>
|
|
||||||
<Icon name="x" />
|
|
||||||
</Button>
|
|
||||||
{/if}
|
{/if}
|
||||||
</InputGroup>
|
</Button>
|
||||||
{/if}
|
{#if (isAdmin && (tag.scope == "admin" || tag.scope == "global")) || tag.scope == username }
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
color="danger"
|
||||||
|
on:click={() => removeTag(tag, tagType)}
|
||||||
|
>
|
||||||
|
<Icon name="x" />
|
||||||
|
</Button>
|
||||||
|
{/if}
|
||||||
|
</InputGroup>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user