File tree Expand file tree Collapse file tree 6 files changed +92
-31
lines changed Expand file tree Collapse file tree 6 files changed +92
-31
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import moment from 'moment';
4
4
import UIkit from 'uikit' ;
5
5
import Icons from 'uikit/dist/js/uikit-icons' ;
6
6
import UIKitAlert from './components/UiKitAlert.vue' ;
7
+ import TaskRow from './tasks/components/TaskRow.vue' ;
7
8
import TaskType from './tasks/components/TaskType.vue' ;
8
9
import TaskOutput from './tasks/components/TaskOutput.vue' ;
9
10
import StatusButton from './tasks/components/StatusButton.vue' ;
@@ -53,6 +54,7 @@ new Vue({
53
54
'import-button' : ImportButton ,
54
55
'task-type' : TaskType ,
55
56
'task-output' : TaskOutput ,
57
+ 'task-row' : TaskRow ,
56
58
'click-to-close' : ClickToClose ,
57
59
'command-list' : CommandList
58
60
} ,
Original file line number Diff line number Diff line change 47
47
.then (response => {
48
48
this .task = response .data ;
49
49
this .running = false ;
50
+ this .$emit (' taskExecuted' , this .task );
50
51
})
51
52
}
52
53
},
53
54
mounted () {
54
55
}
55
56
}
56
- </script >
57
+ </script >
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <tr :class =" task.is_active ? '' : 'uk-text-danger'" >
3
+ <td >
4
+ <a :href =" showHref" >
5
+ {{ description }}
6
+ </a >
7
+ <span class =" uk-float-right uk-hidden@s uk-text-muted" >Command</span >
8
+ </td >
9
+ <td >
10
+ {{ task.average_runtime ? averageDurationInSeconds : 0 }} seconds
11
+ <span class =" uk-float-right uk-hidden@s uk-text-muted" >Avg. Runtime</span >
12
+ </td >
13
+ <td >
14
+ {{ task.last_result ? lastRunDate : 'N/A' }}
15
+ <span class =" uk-float-right uk-hidden@s uk-text-muted" >Last Run</span >
16
+ </td >
17
+ <td >
18
+ {{task.upcoming}}
19
+ <span class =" uk-float-right uk-hidden@s uk-text-muted" >Next Run</span >
20
+ </td >
21
+ <td class =" uk-text-center@m" >
22
+ <execute-button
23
+ :data-task =" task"
24
+ :url =" executeHref"
25
+ v-on:taskExecuted =" refreshTask"
26
+ icon-name =" play"
27
+ button-class =" uk-button-link"
28
+ />
29
+ </td >
30
+ </tr >
31
+ </template >
32
+
33
+ <script >
34
+ import moment from ' moment'
35
+ import ExecuteButton from ' ./ExecuteButton'
36
+
37
+ export default {
38
+ components: {
39
+ ExecuteButton
40
+ },
41
+
42
+ props: {
43
+ dataTask: {},
44
+ },
45
+
46
+ data () {
47
+ return {
48
+ task: this .dataTask
49
+ }
50
+ },
51
+
52
+ computed: {
53
+ description () {
54
+ return this .task .description .substring (0 ,29 );
55
+ },
56
+
57
+ averageDurationInSeconds () {
58
+ return this .task .average_runtime > 0 ? (this .task .average_runtime / 1000 ).toFixed (2 ) : 0 ;
59
+ },
60
+
61
+ lastRunDate () {
62
+ return moment (this .task .last_result .ran_at ).format (' YYYY-MM-DD hh:mm:ss' );
63
+ },
64
+
65
+ showHref () {
66
+ return this .$attrs .showhref ;
67
+ },
68
+
69
+ executeHref () {
70
+ return this .$attrs .executehref ;
71
+ }
72
+ },
73
+
74
+ methods: {
75
+ refreshTask (task ) {
76
+ this .task = task;
77
+ }
78
+ }
79
+ }
80
+ </script >
Original file line number Diff line number Diff line change 30
30
</thead >
31
31
<tbody >
32
32
@forelse ($tasks as $task )
33
- <tr class =" {{ $task -> is_active ?: ' uk-text-danger' } }" >
34
- <td >
35
- <a href =" {{ route (' totem.task.view' , $task )} }" >
36
- {{ str_limit ($task -> description , 30 )} }
37
- </a >
38
- <span class =" uk-float-right uk-hidden@s uk-text-muted" >Command</span >
39
- </td >
40
- <td >
41
- {{ number_format ( $task -> averageRuntime / 1000 , 2 ) } } seconds
42
- <span class =" uk-float-right uk-hidden@s uk-text-muted" >Avg. Runtime</span >
43
- </td >
44
- @if ($last = $task -> lastResult )
45
- <td >
46
- {{ $last -> ran_at -> toDateTimeString ()} }
47
- <span class =" uk-float-right uk-hidden@s uk-text-muted" >Last Run</span >
48
- </td >
49
- @else
50
- <td >
51
- N/A
52
- <span class =" uk-float-right uk-hidden@s uk-text-muted" >Last Run</span >
53
- </td >
54
- @endif
55
- <td >
56
- {{ $task -> upcoming } }
57
- <span class =" uk-float-right uk-hidden@s uk-text-muted" >Next Run</span >
58
- </td >
59
- <td class =" uk-text-center@m" >
60
- <execute-button :data-task =" {{ $task } }" url =" {{ route (' totem.task.execute' , $task )} }" icon-name =" play" button-class =" uk-button-link" ></execute-button >
61
- </td >
33
+ <tr is =" task-row"
34
+ :data-task =" {{ $task } }"
35
+ showHref =" {{ route (' totem.task.view' , $task )} }"
36
+ executeHref =" {{ route (' totem.task.execute' , $task )} }" >
62
37
</tr >
63
38
@empty
64
39
<tr >
Original file line number Diff line number Diff line change 2
2
3
3
namespace Studio \Totem \Http \Controllers ;
4
4
5
+ use Studio \Totem \Task ;
5
6
use Studio \Totem \Contracts \TaskInterface ;
6
7
7
8
class ExecuteTasksController extends Controller
@@ -29,6 +30,6 @@ public function index($task)
29
30
{
30
31
$ this ->tasks ->execute ($ task );
31
32
32
- return redirect ()-> back ( );
33
+ return Task:: find ( $ task -> id );
33
34
}
34
35
}
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ class Task extends TotemModel
43
43
protected $ appends = [
44
44
'activated ' ,
45
45
'upcoming ' ,
46
+ 'last_result ' ,
47
+ 'average_runtime ' ,
46
48
];
47
49
48
50
/**
You can’t perform that action at this time.
0 commit comments