-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathImportCampaign.vue
More file actions
171 lines (168 loc) · 6.56 KB
/
Copy pathImportCampaign.vue
File metadata and controls
171 lines (168 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<template>
<v-app>
<v-container fluid fill-height>
<v-layout align-center justify-center>
<v-flex xs7>
<v-card class="elevation-12">
<v-toolbar dark color="primary">
<v-toolbar-title>Import data</v-toolbar-title>
<v-spacer></v-spacer>
<Menu :where="'Import data'"></Menu>
</v-toolbar>
<v-card-text>
<v-container fluid grid-list-sm>
<v-layout row wrap>
<v-flex>
<v-card>
<v-card-text>
<v-text-field ref='campaignDir' label='Campaign directory'></v-text-field>
<v-text-field ref='campaignName' label='Campaign name'></v-text-field>
<v-text-field ref='idMalette' label='Id malette' value='1'></v-text-field>
<v-text-field ref='idRederbro' label='Id rederbro' value='1'></v-text-field>
<v-text-field ref='cameraNB' label='Camera number' value='6'></v-text-field>
<v-text-field ref='description' label='Description' value='An amazing campaign'></v-text-field>
</v-card-text>
</v-card>
</v-flex>
<v-flex>
<v-card>
<v-card-text>
<v-layout>
<v-btn color="primary" v-on:click='launch()'>Launch import</v-btn>
<v-btn color="primary" v-on:click='scan()'>Scan for end</v-btn>
<v-btn color="primary" v-on:click='stopScan()'>Stop scan</v-btn>
</v-layout>
<v-layout>
<v-flex>
<v-text-field ref='logFile' label="Log file"></v-text-field>
</v-flex>
<v-layout row justify-center>
<v-dialog v-model="dialog">
<v-btn slot="activator" color="primary" v-on:click='showLog()'>Show log</v-btn>
<v-card>
<v-toolbar dark color="primary">
<v-toolbar-title>Import data log</v-toolbar-title>
</v-toolbar>
<v-card-text>{{log}}</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary" @click="dialog = false">Close</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-layout>
</v-layout>
</v-card-text>
</v-card>
<v-card class="mt-1">
<v-card-text>
<v-list dense>
<v-list-tile>
<v-list-tile-content>Number:</v-list-tile-content>
<v-list-tile-content class="align-end">{{ number }}</v-list-tile-content>
</v-list-tile>
<v-divider></v-divider>
<v-list-tile>
<v-list-tile-content>Status:</v-list-tile-content>
<v-list-tile-content class="align-end">{{ status }}</v-list-tile-content>
</v-list-tile>
<v-divider></v-divider>
<v-list-tile>
<v-list-tile-content>Doing:</v-list-tile-content>
<v-list-tile-content class="align-end">{{ doing }}</v-list-tile-content>
</v-list-tile>
<v-divider></v-divider>
<v-list-tile>
<v-list-tile-content>Pourcent:</v-list-tile-content>
<v-list-tile-content class="align-end">{{ pourcent.toFixed(2) }}%</v-list-tile-content>
</v-list-tile>
<v-divider></v-divider>
<v-list-tile>
<v-list-tile-content>Time:</v-list-tile-content>
<v-list-tile-content class="align-end">{{ time.toFixed(2) }} seconds</v-list-tile-content>
</v-list-tile>
</v-list>
</v-card-text>
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-card-text>
</v-card>
</v-flex>
</v-layout>
</v-container>
</v-app>
</template>
<script>
import ApiManager from '@/apiManager'
import Menu from '@/components/Menu'
export default {
name: 'ImportCampaign',
components: {
Menu
},
data () {
return {
number: 0,
status: 'down',
doing: 'nothing',
pourcent: 0,
log: '',
doScan: null,
time: 0,
dialog: false
}
},
methods: {
showLog () {
var args = '{}'
if (this.$refs.logFile.$refs.input.value !== '') {
args = {'logFile': this.$refs.logFile.$refs.input.value}
}
ApiManager.postImportLog(args).then(answer => {
this.log = answer.data.answer
})
},
launch () {
var args = {
'path': this.$refs.campaignDir.$refs.input.value,
'id_malette': this.$refs.idMalette.$refs.input.value,
'id_rederbro': this.$refs.idRederbro.$refs.input.value,
'camera_number': this.$refs.cameraNB.$refs.input.value,
'description': this.$refs.description.$refs.input.value,
'campaign_name': this.$refs.campaignName.$refs.input.value
}
ApiManager.postImportLaunch(args).then(answer => {
this.scan()
})
},
scan () {
this.stopScan()
const that = this
this.doScan = setInterval(function () {
that.status = 'up'
ApiManager.getImportStatus().then(answer => {
that.number++
that.doing = answer.data.answer.doing
that.pourcent = answer.data.answer.pourcent
that.status = answer.data.answer.status
that.time = answer.data.answer.time
})
}, 1000)
},
stopScan () {
if (this.doScan != null) {
clearInterval(this.doScan)
}
}
},
watch: {
status: function () {
if (this.status === 'down') {
this.stopScan()
}
}
}
}
</script>