File tree 7 files changed +58
-6
lines changed
7 files changed +58
-6
lines changed Original file line number Diff line number Diff line change 11
11
},
12
12
"dependencies" : {
13
13
"compression" : " ^1.7.1" ,
14
+ "dayjs" : " ^1.11.5" ,
14
15
"express" : " ^4.18.1" ,
15
16
"sass" : " ^1.55.0" ,
16
17
"sirv" : " ^1.0.0" ,
Original file line number Diff line number Diff line change
1
+ import { readable } from 'svelte/store'
2
+ import dayjs from 'dayjs'
3
+
4
+ function update ( ) {
5
+ return dayjs ( )
6
+ }
7
+ export default readable ( update ( ) , set => {
8
+ let interval = setInterval ( ( ) => set ( update ( ) ) , 1000 )
9
+ return ( ) => clearInterval ( interval )
10
+ } )
Original file line number Diff line number Diff line change
1
+ <script lang =" ts" >
2
+ import type Payload from " ./types/Payload" ;
3
+ export let data: Payload ;
4
+
5
+ import dayjs from ' dayjs'
6
+ </script >
7
+
8
+ <tr >
9
+ <td >
10
+ {dayjs (data .timestamp ).format (" DD/MM/YY hh:mm:ss a" )}
11
+ </td >
12
+ <td >
13
+ {data .code }
14
+ </td >
15
+ <td >
16
+ <pre >{JSON .stringify (data .data , null , 4 )}</pre >
17
+ </td >
18
+ </tr >
Original file line number Diff line number Diff line change
1
+ export default interface Payload < T = any > {
2
+ code : string
3
+ data : T ,
4
+ timestamp : number
5
+ }
Original file line number Diff line number Diff line change 3
3
import { onMount } from " svelte" ;
4
4
5
5
import type { Socket } from " socket.io-client" ;
6
+ import Row from " ../components/payload/Row.svelte" ;
7
+ import type Payload from " ../components/payload/types/Payload" ;
6
8
let client: Socket ;
7
9
8
10
let messages = [];
14
16
);
15
17
16
18
console .log (" Ready" );
17
- client .on (" p" , function (data : { code : string ; data : any } ) {
19
+ client .on (" p" , function (data : Payload ) {
18
20
updateType (data .code );
19
- messages = [data , ... messages ];
21
+ messages = [
22
+ {
23
+ ... data ,
24
+ data: JSON .parse (data .data ),
25
+ },
26
+ ... messages ,
27
+ ];
20
28
});
21
29
});
22
30
56
64
</div >
57
65
58
66
{#each messages .filter (({ code }) => activeTypes .includes (code )) as data }
59
- <pre >
60
- {JSON .stringify (data , null , 2 )}
61
- </pre >
67
+ <Row {data } />
62
68
{/each }
63
69
64
70
<style lang =" scss" >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import * as sapper from '@sapper/server';
6
6
import { Server as HTTPServer } from 'http'
7
7
import { Server as SocketIOServer } from 'socket.io'
8
8
import { Client as SLAPI } from 'presonus-studiolive-api'
9
+ import type Payload from './components/payload/types/Payload' ;
9
10
10
11
const { PORT , NODE_ENV } = process . env ;
11
12
const dev = NODE_ENV === 'development' ;
25
26
let client = new SLAPI ( "192.168.0.19" )
26
27
27
28
client . on ( 'data' , ( data ) => {
28
- io . emit ( 'p' , data )
29
+ let payload : Payload = { code : data . code , data : JSON . stringify ( data ) , timestamp : new Date ( ) . getTime ( ) }
30
+ io . emit ( 'p' , payload )
29
31
} )
30
32
31
33
server . listen ( Number ( PORT ) , '0.0.0.0' , ( ) => {
Original file line number Diff line number Diff line change 968
968
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1"
969
969
integrity sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==
970
970
971
+ " @rgossiaux/svelte-headlessui@^1.0.2 " :
972
+ version "1.0.2"
973
+ resolved "https://registry.yarnpkg.com/@rgossiaux/svelte-headlessui/-/svelte-headlessui-1.0.2.tgz#9493251a40cd56d8bdc8f0f64623d886bb872b1e"
974
+ integrity sha512-sauopYTSivhzXe1kAvgawkhyYJcQlK8Li3p0d2OtcCIVprOzdbard5lbqWB4xHDv83zAobt2mR08oizO2poHLQ==
975
+
971
976
" @rollup/plugin-babel@^5.0.0 " :
972
977
version "5.3.1"
973
978
resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283"
@@ -1493,6 +1498,11 @@ cors@~2.8.5:
1493
1498
object-assign "^4"
1494
1499
vary "^1"
1495
1500
1501
+ dayjs@^1.11.5 :
1502
+ version "1.11.5"
1503
+ resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.5.tgz#00e8cc627f231f9499c19b38af49f56dc0ac5e93"
1504
+ integrity sha512-CAdX5Q3YW3Gclyo5Vpqkgpj8fSdLQcRuzfX6mC6Phy0nfJ0eGYOeS7m4mt2plDWLAtA4TqTakvbboHvUxfe4iA==
1505
+
1496
1506
1497
1507
version "2.6.9"
1498
1508
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
You can’t perform that action at this time.
0 commit comments