Skip to content

Commit

Permalink
Setup Webhooks Toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Dec 3, 2024
1 parent 758a82c commit fc3362e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 4 additions & 0 deletions api/lib/models/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export const AugmentedLayer = Type.Object({
status: Type.Optional(Type.String()),
created: Type.String(),
updated: Type.String(),
uuid: Type.String(),
name: Type.String(),
webhooks: Type.Boolean(),
description: Type.String(),
enabled: Type.Boolean(),
enabled_styles: Type.Boolean(),
Expand Down Expand Up @@ -75,6 +77,8 @@ export default class LayerModel extends Modeler<typeof Layer> {
.select({
count: sql<string>`count(*) OVER()`.as('count'),
id: Layer.id,
uuid: Layer.uuid,
webhooks: Layer.webhooks,
priority: Layer.priority,
created: Layer.created,
updated: Layer.updated,
Expand Down
4 changes: 3 additions & 1 deletion api/routes/connection-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export default async function router(schema: Schema, config: Config) {
body: Type.Object({
name: Default.NameField,
priority: Type.Optional(Type.Enum(Layer_Priority)),
webhooks: Type.Optional(Type.Boolean()),
description: Default.DescriptionField,
enabled: Type.Optional(Type.Boolean()),
task: Type.String(),
Expand Down Expand Up @@ -253,6 +254,7 @@ export default async function router(schema: Schema, config: Config) {
name: Type.Optional(Default.NameField),
priority: Type.Optional(Type.Enum(Layer_Priority)),
description: Type.Optional(Default.DescriptionField),
webhooks: Type.Optional(Type.Boolean()),
cron: Type.Optional(Type.String()),
memory: Type.Optional(Type.Integer()),
timeout: Type.Optional(Type.Integer()),
Expand Down Expand Up @@ -320,7 +322,7 @@ export default async function router(schema: Schema, config: Config) {
let changed = false;
// Avoid Updating CF unless necessary as it blocks further updates until deployed
for (const prop of [
'cron', 'task', 'memory', 'timeout', 'enabled', 'priority',
'cron', 'task', 'memory', 'timeout', 'enabled', 'priority', 'webhooks',
'alarm_period', 'alarm_evals', 'alarm_points', 'alarm_threshold'
]) {
// @ts-expect-error Doesn't like indexed values
Expand Down
2 changes: 1 addition & 1 deletion api/web/src/components/CloudTAK/util/CopyField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
v-else
ref='infobox'
class='position-relative bg-gray-500 rounded-top py-2 px-2 text-truncate'
:style='rows === 1 ? `height: 44px;` : ``'
:style='rows === 1 ? `height: 36px;` : ``'
:class='{
"hover-button hover-border cursor-pointer": hover,
}'
Expand Down
13 changes: 11 additions & 2 deletions api/web/src/components/Layer/LayerConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@
</div>
<div class='col-md-12'>
<TablerToggle
v-model='config.webhook'
v-model='config.webhooks'
label='Enable Webhooks'
/>

<CopyField
v-if='config.uuid'
v-if='config.webhooks && config.uuid'
v-model='config.uuid'
/>
</div>
<div class='col-md-4'>
Expand Down Expand Up @@ -330,8 +331,10 @@ import { std } from '/src/std.ts';
import DataSelect from '../util/DataSelect.vue';
import cronstrue from 'cronstrue';
import TaskModal from './utils/TaskModal.vue';
import CopyField from '../CloudTAK/util/CopyField.vue';
import {
TablerInput,
TablerToggle,
TablerEnum,
TablerLoading
} from '@tak-ps/vue-tabler';
Expand All @@ -347,6 +350,8 @@ export default {
name: 'LayerConfig',
components: {
TablerLoading,
TablerToggle,
CopyField,
IconSquareChevronRight,
IconChevronDown,
IconRefresh,
Expand Down Expand Up @@ -385,7 +390,9 @@ export default {
save: false
},
config: {
uuid: '',
connection: null,
webhooks: false,
priority: 'off',
data: null,
task: '',
Expand Down Expand Up @@ -429,6 +436,7 @@ export default {
},
methods: {
reload: function() {
this.config.webhooks = this.layer.webhooks;
this.config.connection = this.layer.connection;
this.config.data = this.layer.data;
this.config.task = this.layer.task;
Expand All @@ -441,6 +449,7 @@ export default {
this.config.alarm_evals = this.layer.alarm_evals;
this.config.alarm_points = this.layer.alarm_points;
this.config.alarm_threshold = this.layer.alarm_threshold;
this.config.uuid = this.layer.uuid;
this.disabled = true;
},
Expand Down

0 comments on commit fc3362e

Please sign in to comment.