You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

262 lines
13 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>smartpager.network Webform</title>
<!-- <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet"> -->
<link href="css/materialdesignicons.min.css" rel="stylesheet">
<link href="css/vuetify.min.css" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
</head>
<body>
<div id="app">
<v-app>
<v-app-bar app>
<v-toolbar-title>Webform</v-toolbar-title>
<v-spacer></v-spacer>
<span>SmartPager Framework made with 🧡 by cheetah.cat - uses BOSKrypt AES256 Encryption </span>
<v-img src="ready.png" max-width="96px" max-height="48px"></v-img>
</v-app-bar>
<v-content>
<v-container> <!-- Device List-->
<v-data-table must-sort :footer-props="footerProps"
:options="options" :loading="loadingD" loading-text="Loading... Please wait"
:headers="devicesHeaders" item-key="_id" :items="deviceListData"
:single-expand="singleExpand" item-key="name" show-expand
class="elevation-1">
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>Device List</v-toolbar-title>
</v-toolbar>
</template>
<template v-slot:no-data>
No Devices to show
</template>
<template v-slot:expanded-item="{ headers, item }">
<td :colspan="headers.length">
<section v-if="item.deviceType == 'birdyslim'">
<pre>Device ID: {{ item.deviceID }}</pre>
<pre v-if="!!item.poweredOn">Powered On: {{ item.poweredOn }}</pre>
<pre v-if="!!item.isCharging">Charging: {{ item.isCharging }}</pre>
<pre v-if="!!item.battery">Battery: {{ item.battery }}</pre>
<pre v-if="!!item.lastSeen">Last Seen: {{ item.lastSeen }}</pre>
<pre v-if="!!item.rssi">POCSAG RSSI: -{{ item.rssi }}dBm</pre>
<pre v-if="!!item.gps">GPS Position:
Lat: {{ item.gps.latitude }}
Lng: {{ item.gps.longitude }}
Last Acquisition: {{ item.gps.lastGPSAcquisition }}m ago
</pre>
<pre v-if="!!item.lastLoRaPacket">
Last LoRaWAN Packet:
{{ item.lastLoRaPacket }}
</pre>
</section>
</td>
</template>
</v-data-table>
</v-container>
<hr>
<v-container> <!-- Recent Messages -->
<v-data-table must-sort :footer-props="footerProps"
:options="options" :loading="loadingM" loading-text="Loading... Please wait"
:headers="recentMessagesHeaders" item-key="id" :items="recentMessageListData" :items-per-page="5"
:single-expand="singleExpandRM" item-key="name" show-expand
class="elevation-1">
<template v-slot:top>
<v-toolbar flat>
<v-toolbar-title>Message History</v-toolbar-title>
<v-spacer></v-spacer>
<v-dialog v-model="dialogNewMessage" fullscreen hide-overlay transition="dialog-bottom-transition">
<template v-slot:activator="{ on, attrs }">
<v-btn color="primary" v-bind="attrs" v-on="on">
<v-icon>mdi-email</v-icon>
New Message
</v-btn>
</template>
<v-card>
<v-toolbar dark color="primary">
<v-btn icon dark @click="dialogNewMessage = false">
<v-icon>mdi-close</v-icon>
</v-btn>
<v-toolbar-title>New Message</v-toolbar-title>
<v-spacer></v-spacer>
</v-toolbar>
<v-container>
<v-row>
<v-col cols="12" sm="12" md="6">
<v-autocomplete
v-model="newMSGData.preset"
:items="presetSearchItems"
:loading="!presetSearchItems.length > 0"
color="white"
hide-no-data
dense
label="Profile"
placeholder="Start typing to Search"
prepend-icon="mdi-database-search"
></v-autocomplete>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="12" md="6">
<span>
Please leave a reference/name!
</span>
<v-textarea v-model="newMSGData.payload" label="Message"></v-select>
</v-col>
</v-row>
<v-row>
<v-col cols="12" sm="12" md="6">
<v-btn color="success" dark text @click="testMsg_send()">Send</v-btn>
</v-col>
</v-row>
</v-container>
</v-card>
</v-dialog>
</v-toolbar>
</template>
<template v-slot:no-data>
No Messages to show, you can send one using the 'New Message' Button
</template>
<template v-slot:expanded-item="{ headers, item }">
<td :colspan="headers.length">
<pre>{{ item }}</pre>
</td>
</template>
</v-data-table>
</v-container>
</v-content>
</v-app>
</div>
<script src="js/vue/vue.js"></script>
<script src="js/vue/vuetify.js"></script>
<script src="js/vue/vue-resource_1.5.1.js"></script>
<script>
new Vue({
el: '#app',
vuetify: new Vuetify(),
http: { root: '/' },
data() {
return {
EXPERTMODE:false,
dialogNewMessage: false,
presetSearchItems: [],
loadingD: true,
loadingM: false,
search: '',
expanded: [],
singleExpand: true,
singleExpandRM: true,
options: {
itemsPerPage: -1,
},
footerProps: {
itemsPerPageOptions: [ -1, 5, 10, 20, 50, 75, 100 ]
},
devicesHeaders: [
{ text: 'ID', align: 'start', groupable: false, sortable: false, value: 'deviceID', },
{ text: 'Type', value: 'deviceType', groupable: true },
{ text: 'Last Seen', value: 'lastSeen', groupable: false },
],
newMSGData: {
pager: {
payload: "Test Message",
},
preset: null,
},
lastMSGLog: null,
messagesCheckList: [],
deviceListData: [],
recentMessageListData: [],
recentMessagesHeaders: [
{ text: 'ID', align: 'start', groupable: false, sortable: false, value: 'id', },
{ text: 'Type', value: 'type', groupable: true, sortable: false },
{ text: 'State', value: 'state', groupable: false, sortable: false },
{ text: 'Date', value: 'date', groupable: false, sortable: false },
{ text: 'Message', value: '_payload', groupable: false, sortable: false },
],
}
},
created() {
this.refreshDevices()
setInterval(this.refreshDevices, 1e3)
this.refreshMessages()
setInterval(this.refreshMessages, 1e3)
this.$http.get('/api/modes')
.then(response => {
console.log(response.body)
this.presetSearchItems = response.body.map(x => { return {
text: x.name,
value: x.preset,
//Description
}})
}, response => {
})
},
methods: {
refreshDevices() {
this.$http.get('/api/devices').then(response => {
this.deviceListData = Object.keys(response.body).map(key => {
const item = response.body[ key ]
const keyData = key.split(':')
item.deviceType = keyData[ 0 ], item.deviceID = keyData[ 1 ]
item.lastSeen = new Date(item.lastSeen).toLocaleString()
//item.validStateText = this.validStateLUT[item.validState]
return item
})
//this.accountData.sort((a,b) => a.validState - b.validState)
this.loadingD = false
}, response => {
})
},
refreshMessages() {
if (this.messagesCheckList.length == 0) return
this.$http.get('/api/message/status', { params: {
ids: this.messagesCheckList
} }).then(response => {
this.recentMessageListData = response.body.map(msg => {
const stateArray = [msg._routerData.recvAck, msg._routerData.readAck, msg._routerData.response]
// msg.state = [ msg.type, stateArray.filter(x=>x!==false).length, ...stateArray ]
msg.state = '-'
if (msg.type === 'duplex') {
switch (stateArray.filter(x=>x!==false).length) {
case 0: msg.state = '📨 Sent'; break;
case 1: msg.state = '📬 Received'; break;
case 2: msg.state = '👀 Read'; break;
case 3: msg.state = '💬 Responded'; break;
}
}
msg.date = new Date(msg.date).toLocaleString()
return msg
})
this.loadingM = false
}, response => {
})
},
testMsg_send() {
console.log(this.newMSGData.preset)
this.$http.post('/api/message/preset/',
Object.assign({ preset: this.newMSGData.preset }, { payload: this.newMSGData.payload })
).then(x=>{
console.log('response', x)
this.messagesCheckList.push(x.body)
this.dialogNewMessage = false
})
}
}
})
</script>
</body>
</html>