Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/bot/database/entity/cooldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { ColumnNumericTransformer } from './_transformer';

export interface CooldownInterface {
id?: string;
name: string;
value: string[];
miliseconds: number;
usageLimit: number;
type: 'global' | 'user';
pool: 'per-item' | 'shared';
wipeType: 'full' | 'full-last' | 'gradual';
timestamp?: number;
isErrorMsgQuiet: boolean;
isEnabled: boolean;
Expand All @@ -27,7 +30,7 @@ export const Cooldown = new EntitySchema<Readonly<Required<CooldownInterface>>>(
name: 'cooldown',
columns: {
id: { type: 'uuid', primary: true, generated: 'uuid' },
name: { type: String },
value: { type: 'simple-json' },
miliseconds: { type: Number },
type: { type: 'varchar', length: 10 },
timestamp: { type: 'bigint', transformer: new ColumnNumericTransformer(), default: 0 },
Expand Down
5 changes: 3 additions & 2 deletions src/bot/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,9 @@ class Message {
})).sort().join(', ');
case 'cooldown':
listOutput = _.map(cooldowns, function (o, k) {
const time = o.miliseconds;
return o.name + ': ' + (time / 1000) + 's';
// const time = o.miliseconds;
// return o.name + ': ' + (time / 1000) + 's';
return '';
}).sort().join(', ');
return listOutput.length > 0 ? listOutput : ' ';
case 'price':
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<template>
<b-form-group
:label="translate('permissions-to-apply')"
label-for="name"
>
<b-spinner v-if="state.loading !== $state.success"/>
<b-list-group v-else>
<b-list-group-item @click="value = []" :variant="value.length === 0 ? 'success' : ''">All <fa v-if="value.length === 0" icon="check" style="float:right; height: 24px"/></b-list-group-item>
<b-list-group-item
v-for="permission of permissions" :key="permission.id"
:variant="value.includes(permission.id) ? 'success' : ''"
@click="toggle(permission.id)"
>
{{permission.name}}
<fa v-if="value.includes(permission.id)" icon="check" style="float:right; height: 24px"/>
</b-list-group-item>
</b-list-group>
</b-form-group>
</template>

<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import { getSocket } from 'src/panel/helpers/socket';
import type { PermissionsInterface } from 'src/bot/database/entity/permissions';
import { orderBy, xor } from 'lodash-es';

@Component({})
export default class extends Vue {
psocket = getSocket('/core/permissions')

value: string[] = []

state: {
loading: number;
} = {
loading: this.$state.progress,
}

permissions: PermissionsInterface[] = [];

toggle(id: string) {
this.value = xor(this.value, [id])
}

async mounted() {
await new Promise((resolve) => {
this.psocket.emit('permissions', (err: string | null, data: Readonly<Required<PermissionsInterface>>[]) => {
if(err) {
return console.error(err);
}
this.permissions = orderBy(data, 'order', 'asc');
resolve()
})
})
this.state.loading = this.$state.success;
}
};
</script>
65 changes: 65 additions & 0 deletions src/panel/views/managers/cooldowns/components/name.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<b-form-group
:label="'Type to add command, keyword or group'"
label-for="name"
>
<b-form-tags
input-id="tags-basic"
v-model="_value"
class="p-1"
placeholder="Type to add !command, keyword or group:nameOfGroup"
:style="{
height: value.length === 0 ? '48px !important' : 'inherit'
}"
no-outer-focus
:remove-on-delete="true">
<template v-slot="{tags, inputId, placeholder, disabled, addTag, removeTag }">
<b-input-group style="height:2rem;">
<b-form-input
v-model="newTag"
:id="inputId"
:placeholder="placeholder"
:disabled="disabled"
@keydown.delete="newTag.length === 0 ? removeTag(tags[tags.length - 1]) : null"
@keydown.enter="addTag(newTag); newTag = ''"
></b-form-input>
<b-input-group-append>
<b-button @click="addTag(newTag)" :disabled="disabled" variant="primary">Add</b-button>
</b-input-group-append>
</b-input-group>
<ul class="list-inline d-inline-block mt-3 mb-0">
<li v-for="tag in tags" :key="tag" class="b-form-tag d-inline-flex align-items-baseline mw-100">
<span class="b-form-tag-content flex-grow-1 p-1" :class="{
'badge-info': tag.startsWith('!'),
'badge-success': tag.startsWith('group:'),
'badge-danger': !tag.startsWith('!') && !tag.startsWith('group:'),
}">
<template v-if="tag.startsWith('!')">{{ translate('command') }}</template>
<template v-else-if="tag.startsWith('group:')">{{ translate('group') }}</template>
<template v-else>{{ translate('keyword') }}</template>
</span>
<span class="b-form-tag-content flex-grow-1 text-truncate p-1 pr-3 badge-secondary">{{ tag.replace('group:', '') }}
<button @click="removeTag(tag)" aria-keyshortcuts="Delete" type="button" aria-label="Remove tag" class="close b-form-tag-remove" style="position:absolute; transform: translateX(3px) translateY(-2px);">×</button>
</span>
</li>
</ul>
</template>
</b-form-tags>
</b-form-group>
</template>

<script lang="ts">
import { Vue, Component, PropSync } from 'vue-property-decorator';
import type { CooldownInterface } from 'src/bot/database/entity/cooldown';

@Component({})
export default class extends Vue {
@PropSync('value') _value!: CooldownInterface['value'];

newTag = '';

touch() {
this.$emit('touch')
}
};
</script>
Loading