13
13
# GNU Affero General Public License for more details.
14
14
15
15
# Modified by OpenC3, Inc.
16
- # All changes Copyright 2022 , OpenC3, Inc.
16
+ # All changes Copyright 2024 , OpenC3, Inc.
17
17
# All Rights Reserved
18
18
#
19
19
# This file may also be used under the terms of a commercial license
23
23
<template>
24
24
<v-dialog v-model="show" width="600">
25
25
<v-card>
26
- <form v-on: submit.prevent="updateActivity">
26
+ <form @ submit.prevent="updateActivity">
27
27
<v-system-bar>
28
28
<v-spacer />
29
29
<span>
86
86
data-test="activity-stop-time"
87
87
/>
88
88
</v-row>
89
- <v-row class="mx-2 mb-2">
90
- <v-radio-group
91
- v-model="utcOrLocal"
92
- row
93
- hide-details
94
- class="mt-0"
95
- >
96
- <v-radio label="LST" value="loc" data-test="lst-radio" />
97
- <v-radio label="UTC" value="utc" data-test="utc-radio" />
98
- </v-radio-group>
89
+ <v-row style="margin-top: 0px">
90
+ <v-col>
91
+ <v-radio-group
92
+ v-model="utcOrLocal"
93
+ row
94
+ hide-details
95
+ class="mt-0"
96
+ >
97
+ <v-radio label="LST" value="loc" data-test="lst-radio" />
98
+ <v-radio label="UTC" value="utc" data-test="utc-radio" />
99
+ </v-radio-group>
100
+ </v-col>
101
+ <v-col>
102
+ <v-checkbox
103
+ style="padding-top: 0px; margin-top: 0px"
104
+ v-model="recurring"
105
+ label="Recurring"
106
+ hide-details
107
+ data-test="recurring"
108
+ disabled
109
+ >
110
+ </v-checkbox>
111
+ </v-col>
112
+ </v-row>
113
+ <v-row v-if="recurring">
114
+ <v-col><div class="repeat">Repeat every</div></v-col>
115
+ <v-col>
116
+ <v-text-field
117
+ v-model="frequency"
118
+ dense
119
+ outlined
120
+ single-line
121
+ hide-details
122
+ disabled
123
+ /></v-col>
124
+ <v-col>
125
+ <v-select
126
+ :items="timeSpans"
127
+ v-model="timeSpan"
128
+ style="primary"
129
+ hide-details
130
+ dense
131
+ outlined
132
+ disabled
133
+ data-test="cmd-param-select"
134
+ />
135
+ </v-col>
136
+ </v-row>
137
+ <v-row v-if="recurring" style="padding-bottom: 10px">
138
+ <v-col><div class="repeat">Ending</div></v-col>
139
+ <v-col>
140
+ <v-text-field
141
+ v-model="recurringEndDate"
142
+ type="date"
143
+ label="End Date"
144
+ class="mx-1"
145
+ disabled
146
+ :rules="[rules.required]"
147
+ data-test="recurring-end-date"
148
+ /></v-col>
149
+ <v-col>
150
+ <v-text-field
151
+ v-model="recurringEndTime"
152
+ type="time"
153
+ step="1"
154
+ label="End Time"
155
+ class="mx-1"
156
+ disabled
157
+ :rules="[rules.required]"
158
+ data-test="recurrning-end-time"
159
+ /></v-col>
99
160
</v-row>
100
161
<v-row>
101
162
<span
104
165
v-text="timeError"
105
166
/>
106
167
</v-row>
107
- <v-row>
168
+ <v-row class="mt-2" >
108
169
<v-spacer />
109
170
<v-btn
110
171
@click="dialogStep = 2"
118
179
</div>
119
180
</v-card-text>
120
181
</v-stepper-content>
121
-
122
182
<v-stepper-step editable step="2">
123
183
Activity type Input
124
184
</v-stepper-step>
134
194
placeholder="INST COLLECT with TYPE 0, DURATION 1, OPCODE 171, TEMP 0"
135
195
prefix="cmd('"
136
196
suffix="')"
137
- hint="Timeline run commands with cmd_no_hazardous_check"
197
+ hint="Timeline runs commands with cmd_no_hazardous_check"
138
198
data-test="activity-cmd"
139
199
/>
140
200
</div>
145
205
<div v-else>
146
206
<span class="ma-2"> No required input </span>
147
207
</div>
148
- <v-row v-show="typeError">
208
+ <v-row v-show="typeError" class="mt-2" >
149
209
<span class="ma-2 red--text" v-text="typeError" />
150
210
</v-row>
151
- <v-row>
211
+ <v-row class="mt-2" >
152
212
<v-spacer />
153
213
<v-btn
154
214
@click="cancelActivity"
@@ -214,6 +274,12 @@ export default {
214
274
rules: {
215
275
required: (value) => !!value || 'Required',
216
276
},
277
+ recurring: false,
278
+ recurringEndDate: null,
279
+ recurringEndTime: null,
280
+ frequency: 90,
281
+ timeSpan: 'minutes',
282
+ timeSpans: ['minutes', 'hours', 'days'],
217
283
}
218
284
},
219
285
watch: {
@@ -260,6 +326,9 @@ export default {
260
326
this.kind = inputKind
261
327
this.activityData = ''
262
328
},
329
+ fileHandler: function (event) {
330
+ this.activityData = event ? event : null
331
+ },
263
332
updateValues: function () {
264
333
const sDate = new Date(this.activity.start * 1000)
265
334
const eDate = new Date(this.activity.stop * 1000)
@@ -270,45 +339,68 @@ export default {
270
339
this.kind = this.activity.kind.toUpperCase()
271
340
this.activityData = this.activity.data[this.activity.kind]
272
341
this.activityEnvironment = this.activity.data.environment
273
- },
274
- fileHandler: function (event) {
275
- this.activityData = event ? event : null
342
+ if (this.activity.recurring?.uuid) {
343
+ this.recurring = true
344
+ const rDate = new Date(this.activity.recurring.end * 1000)
345
+ this.recurringEndDate = format(rDate, 'yyyy-MM-dd')
346
+ this.recurringEndTime = format(rDate, 'HH:mm:ss')
347
+ this.frequency = this.activity.recurring.frequency
348
+ this.timeSpan = this.activity.recurring.span
349
+ }
276
350
},
277
351
cancelActivity: function () {
278
352
this.show = !this.show
279
353
},
280
354
updateActivity: function () {
281
355
// Call the api to update the activity
282
356
const start = this.toIsoString(
283
- Date.parse(`${this.startDate}T${this.startTime}`),
357
+ Date.parse(`${this.startDate}T${this.startTime}`)
284
358
)
285
359
const stop = this.toIsoString(
286
- Date.parse(`${this.stopDate}T${this.stopTime}`),
360
+ Date.parse(`${this.stopDate}T${this.stopTime}`)
287
361
)
288
362
const kind = this.kind.toLowerCase()
289
363
let data = { environment: this.activityEnvironment }
290
364
data[kind] = this.activityData
291
365
const tName = this.activity.name
292
366
const aStart = this.activity.start
367
+ var recurring = {}
368
+ if (this.recurring) {
369
+ recurring = {
370
+ frequency: this.frequency,
371
+ span: this.timeSpan,
372
+ end: this.toIsoString(
373
+ Date.parse(`${this.recurringEndDate}T${this.recurringEndTime}`)
374
+ ),
375
+ }
376
+ }
293
377
Api.put(`/openc3-api/timeline/${tName}/activity/${aStart}`, {
294
- data: { start, stop, kind, data },
295
- }).then((response) => {
296
- const activityTime = this.generateDateTime(
297
- new Date(response.data.start * 1000),
298
- )
299
- this.$notify.normal({
300
- title: 'Updated Activity',
301
- body: `${activityTime} (${response.data.start}) on timeline: ${response.data.name}`,
302
- })
378
+ data: { start, stop, kind, data, recurring },
303
379
})
304
- this.$emit('close')
305
- this.show = !this.show
380
+ .then((response) => {
381
+ const activityTime = this.generateDateTime(
382
+ new Date(response.data.start * 1000)
383
+ )
384
+ this.$notify.normal({
385
+ title: 'Updated Activity',
386
+ body: `${activityTime} (${response.data.start}) on timeline: ${response.data.name}`,
387
+ })
388
+ this.$emit('update')
389
+ this.show = !this.show
390
+ })
391
+ .catch((error) => {
392
+ this.show = !this.show
393
+ })
306
394
},
307
395
},
308
396
}
309
397
</script>
310
398
311
399
<style scoped>
400
+ .repeat {
401
+ padding-top: 10px;
402
+ text-align: right;
403
+ }
312
404
.v-stepper--vertical .v-stepper__content {
313
405
width: auto;
314
406
margin: 0px 0px 0px 36px;
0 commit comments