Making some progress

This commit is contained in:
Martin Donnelly 2020-08-16 20:11:32 +01:00
parent 29c7c7e132
commit ac4e57433e
10 changed files with 83 additions and 30 deletions

View File

@ -30,7 +30,7 @@
<style lang="scss" global> <style lang="scss" global>
@import "./css/global.scss"; @import "./css/traintimes.scss";
@import './fonts/fujicons.css'; @import './fonts/fujicons.css';
.up, .up,

View File

@ -49,10 +49,10 @@
<section class="navbar-section text-right"> <section class="navbar-section text-right">
<a href="/#/tweets" class="btn bg-primary ">Tweets</a> <a title="Tweets" href="/#/tweets" class="btn--slim bg-primary"><i class="fa fa-twitter" style="color:white;"></i></a>
<a href="/#/settings" class="btn bg-primary ">Settings</a> <a title="Settings" href="/#/settings" class="btn bg-primary "><i class="fa fa-cog-solid" style="color:white;"></i></a>
{#if showFav} {#if showFav}
<a href="/#/favourites" class="btn bg-primary">Favourites</a> <a href="/#/favourites" class="btn--slim bg-primary">Favourites</a>
{/if} {/if}
</section> </section>

View File

@ -45,17 +45,32 @@
</script> </script>
<style> <style lang="scss">
$mui-base-font-size:1rem;
$mui-dropdown-bg-color:#fff;
$mui-dropdown-border-radius:0.1;
$mui-base-line-height:1.6;
$mui-dropdown-link-font-color:#294c5d;
$mui-dropdown-link-font-color-hover:#294c5d;
$mui-dropdown-link-bg-color-hover:#dcc894;
$mui-dropdown-link-font-color-disabled:#ff00ff;
$mui-cursor-disabled:disabled;
@import "../css/global/dropdown.scss";
</style> </style>
<span class="mui-dropdown--right"> <span class="mui-dropdown mui-dropdown--right">
<label for={name}>{label}</label> <label for={name}>{label}</label>
<input autocomplete="off" {name} on:keyup={debouncedDoSearch} bind:value /> <input autocomplete="off" {name} on:keyup={debouncedDoSearch} bind:value />
{#if searchResults.length > 0} {#if searchResults.length > 0}
<ul class="mui-dropdown__menu mui--is-open"> <ul class="mui-dropdown__menu mui--is-open">
{#each searchResults as item, index} {#each searchResults as item, index}
<li><div on:click={selectItem} data-content="{item}">{item[1]} ({item[0]})</div></li> <!--<li><div on:click={selectItem} data-content="{item}">{item[1]} ({item[0]})</div></li>-->
<li><a on:click={selectItem} data-content="{item}">{item[1]} ({item[0]})</a></li>
{/each} {/each}
</ul> </ul>
{/if} {/if}

View File

@ -37,7 +37,7 @@
<div class="col-5">{item.startStation.name}</div> <div class="col-5">{item.startStation.name}</div>
<div class="col-1"><i class="fa fa-thick-arrow fa-1x mui--align-middle"></i></div> <div class="col-1"><i class="fa fa-thick-arrow fa-1x mui--align-middle"></i></div>
<div class="col-5">{item.destStation.name}</div> <div class="col-5">{item.destStation.name}</div>
<div class="col-1"><button class="btn btn-sm" on:click="{() => buttonsVisible = !buttonsVisible}"><i class="fa fa-menu"></i></button></div> <div class="col-1"><button class="btn btn-sm--slim" on:click="{() => buttonsVisible = !buttonsVisible}"><i class="fa fa-menu"></i></button></div>
</div> </div>

View File

@ -60,7 +60,7 @@
<div class="nrccAlert" style="padding:2px;"> <div class="nrccAlert" style="padding:2px;">
<ul> <ul>
{#each otherDetails.nrMessages as item} {#each otherDetails.nrMessages as item}
<li class="alert bg-danger"><i class="fa fa-info mui--align-middle"></i> {item.msg} <li class="alert bg-danger"><i class="fa fa-info align-middle"></i> {item.msg}
{#if item.link} {#if item.link}
<a href={item.link}>{item.linkText}</a> <a href={item.link}>{item.linkText}</a>
{/if} {/if}
@ -75,23 +75,24 @@
{#if list.length > 0} {#if list.length > 0}
{#each list as item, i (item.serviceIdUrlSafe)} {#each list as item, i (item.serviceIdUrlSafe)}
<div class="grid card mui--align-bottom" transition:fade|local> <div class="row card flex align-bottom" transition:fade|local>
<div class="col-5 mui--align-middle"> <div class="col-5 align-middle">
<span on:click={viewService(item.serviceIdUrlSafe)}>{item.location}</span> <span on:click={viewService(item.serviceIdUrlSafe)}>{item.location}</span>
<span class="mui--text-accent">{item.carriageCount}</span> <span class="text-accent">{item.carriageCount}</span>
<div> <div>
{#if item.via} {#if item.via}
<em class="mui--text-accent via">{item.via}</em> <!--<em class="text-accent via">{item.via}</em>-->
<span class="badge">{item.via}</span>
{/if} {/if}
</div> </div>
</div> </div>
<div class="col-2 text-center mui--align-middle time">{item.time}</div> <div class="col-2 text-center align-middle time">{item.time}</div>
{#if item.isCancelled} {#if item.isCancelled}
<div class="col-5 text-center mui--align-middle delayed"><i class="fa fa-alert fa-1x mui--align-middle"></i>{item.cancel}</div> <div class="col-5 text-center align-middle delayed"><i class="fa fa-alert fa-1x mui--align-middle"></i>{item.cancel}</div>
{:else} {:else}
<div class="col-3 text-center mui--align-middle {item.statusMode}">{item.status}</div> <div class="col-3 text-center align-middle {item.statusMode}">{item.status}</div>
<div class="col-2 text-center mui--align-middle">{item.platform}</div> <div class="col-2 text-right align-middle">{item.platform}</div>
{/if} {/if}
</div> </div>
{/each} {/each}

View File

@ -97,7 +97,7 @@
align-items: center; align-items: center;
padding: 0.7rem 0rem; padding: 0.7rem 0rem;
z-index: 1; z-index: 1;
width: 100%; width: 98%;
opacity: 0.9; opacity: 0.9;
margin-bottom: 0.4rem; margin-bottom: 0.4rem;
border-bottom-color: #666666; border-bottom-color: #666666;
@ -144,12 +144,12 @@
</style> </style>
<div class="columns TRcard"> <div class="row TRcard">
<div class='entry ml-1'> <div class='entry col-8 ml--1'>
<div>{startStationName}</div> <div>{startStationName}</div>
<div>{destStationName}</div> <div>{destStationName}</div>
</div> </div>
<div class='entry text-right'> <div class='entry col-4 text-center'>
<span class="btn {status}" on:click={onClick}>{displayTime}</span> <span class="btn {status}" on:click={onClick}>{displayTime}</span>
</div> </div>
</div> </div>

View File

@ -32,24 +32,25 @@
.avatar { .avatar {
max-width: 48px; max-width: 48px;
max-height: 48px; max-height: 48px;
object-fit: scale-down;
border-radius: 0.1rem; border-radius: 0.1rem;
} }
</style> </style>
{#if tweet} {#if tweet}
<div class="card"> <div class="card--slim">
<blockquote>
<div class="tweet-header"> <div class="tweet-header">
<div class="grid"> <div class="grid">
<img class='avatar col-2' src={viaImgCache(tweet.user.profile_image_url_https)} alt="@{tweet.user.screen_name}"/> <img class='avatar col-2' src={viaImgCache(tweet.user.profile_image_url_https)} alt="@{tweet.user.screen_name}"/>
<div class="col-10 ml-2"> <div class="col-10 ml-2">
<div class="text-subhead">{tweet.user.name}</div> <div class="text-subhead text-dark">{tweet.user.name}</div>
<div>@{tweet.user.screen_name}</div> <div class="badge">@{tweet.user.screen_name}</div>
</div> </div>
</div> </div>
</div> </div>
{#if inReply} {#if inReply}
<div> <div class="text-primary">
Replying to @{tweet.in_reply_to_screen_name} Replying to @{tweet.in_reply_to_screen_name}
</div> </div>
{/if} {/if}
@ -59,6 +60,6 @@
<div> <div>
<small class="text-highlight2">{tweet.created_at}</small> <small class="text-highlight2">{tweet.created_at}</small>
</div> </div>
</blockquote>
</div> </div>
{/if} {/if}

View File

@ -30,7 +30,7 @@
<div class="container "> <div class="container ">
<div class="text-dark text-subhead">Twitter</div> <div class="text-dark text-subhead">Twitter</div>
{#if mounted} {#if mounted}
<div class="grid-1"> <div class="grid-1 pad">
<div> <div>
<label class="label-body"> <label class="label-body">
<input type="checkbox" bind:checked={_following.nationalrailenq.follow}> <input type="checkbox" bind:checked={_following.nationalrailenq.follow}>

View File

@ -10,10 +10,10 @@
onMount(async () => { onMount(async () => {
await state.getTweets(); await state.getTweets();
serviceInterval = setInterval(async () => { /* serviceInterval = setInterval(async () => {
console.log('Twitter update') console.log('Twitter update')
await state.getTweets(); await state.getTweets();
}, 300000); }, 300000);*/
}); });
onDestroy(async () => { onDestroy(async () => {

View File

@ -11,6 +11,8 @@ import { writable, get } from 'svelte/store';
import localforage from 'localforage'; import localforage from 'localforage';
const baseUrl = (ENV === 'production') ? (`${location.protocol }//${ location.hostname}`) : 'http://localhost:8100'; const baseUrl = (ENV === 'production') ? (`${location.protocol }//${ location.hostname}`) : 'http://localhost:8100';
import Websocket from '../libs/websocket';
let started = false; let started = false;
const twitterAccounts = { const twitterAccounts = {
'nationalrailenq': { 'nationalrailenq': {
@ -199,10 +201,19 @@ const state = {
getBaseUrl() { getBaseUrl() {
return baseUrl; return baseUrl;
},
trigger(item) {
console.log('trigger', item);
if (item.hasOwnProperty('message') ) {
const msg = item.message;
}
} }
}; };
const webSocket = new Websocket(state);
localforage.getItem('twitterFollowing').then((value) => { localforage.getItem('twitterFollowing').then((value) => {
if (value !== null) state.twitterFollowing.set(value); if (value !== null) state.twitterFollowing.set(value);
else { else {
@ -273,6 +284,31 @@ state.twitterFollowing.subscribe((v) => {
state.twitterFollowingList.set(list); state.twitterFollowingList.set(list);
}); });
state.twitterFollowingList.subscribe((v) => {
if (v.length === 0) return;
console.log('twitterFollowingList', v.length, v);
v.forEach((item) => {
console.log(item);
const id = item[1].id;
webSocket.subscribe(`t-${id}`);
/*
for (let t = 0; t < v.length, t++;) {
console.log(t);
}
*/
});
});
state.tweetList.subscribe((v) => {
console.log('tweetList', v);
});
state.tweets.subscribe((v) => {
console.log('tweets', v);
});
// started = true; // started = true;
setTimeout(() => { setTimeout(() => {
started = true; started = true;