Skip to content

Commit

Permalink
hotfix detail and table
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Mar 7, 2023
1 parent d8f8044 commit f68c988
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/components/detail/DetailPayToRelay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
</span>
</span>
<br />

<a v-if="result?.info?.payments_url" class="mt-6 inline-block button text-md bg-black/80 hover:bg-black/90 text-white font-bold py-2 px-4 rounded" :href="result.info.payments_url">
<a v-if="this.result?.info?.limitation?.payment_required && this.result?.info?.payments_url" class="mt-6 inline-block button text-md bg-black/80 hover:bg-black/90 text-white font-bold py-2 px-4 rounded" :href="this.result?.info?.payments_url">
<svg id="Layer_1" class="w-5 h-5 align-center inline-block" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" v-if="isPayToRelay(relay)">
<circle style="fill:#f8991d" class="cls-1" cx="180" cy="180" r="179"/>
<rect class="fill-white dark:fill-black" x="201.48" y="37.16" width="23.49" height="40.14" transform="translate(21.82 -52.79) rotate(14.87)"/>
Expand Down
14 changes: 7 additions & 7 deletions src/components/relays/blocks/RelaysResultTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,13 @@
</td>

<!-- no editor -->
<td v-if="(!store.layout.editorIsExpanded || !isLoggedIn()) && !store.prefs.isFirstVisit" class="w-16 content-center text-center hidden md:table-cell lg:table-cell xl:table-cell" :key="generateKey(relay, 'check.connect')">
<!-- <td v-if="(!store.layout.editorIsExpanded || !isLoggedIn()) && !store.prefs.isFirstVisit" class="w-16 content-center text-center hidden md:table-cell lg:table-cell xl:table-cell" :key="generateKey(relay, 'check.connect')">
<span class="m-auto block" :class="getCheckIndicator(relay, 'connect')">
&nbsp;
</span>
</td>
</td> -->

<td v-if="(!store.layout.editorIsExpanded || !isLoggedIn()) && !store.prefs.isFirstVisit" class="w-16 content-center text-center hidden md:table-cell lg:table-cell xl:table-cell" :key="generateKey(relay, 'check.read')">
<!-- <td v-if="(!store.layout.editorIsExpanded || !isLoggedIn()) && !store.prefs.isFirstVisit" class="w-16 content-center text-center hidden md:table-cell lg:table-cell xl:table-cell" :key="generateKey(relay, 'check.read')">
<span class="m-auto block align-middle" :class="getCheckIndicator(relay, 'read')">
<span class="align-middle h-max" v-if="isLoggedIn() && store.user.kind3?.[relay]?.read">
<svg class="inline-block " :class="getCheckIndicatorPolicy" fill="none" stroke="rgba(0,0,0,0.5)" stroke-width="3" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
Expand All @@ -313,9 +313,9 @@
</span>
<span v-else>&nbsp;</span>
</span>
</td>
</td> -->

<td v-if="(!store.layout.editorIsExpanded || !isLoggedIn()) && !store.prefs.isFirstVisit" class="w-16 content-center text-center hidden md:table-cell lg:table-cell xl:table-cell" :key="generateKey(relay, 'check.write')">
<!-- <td v-if="(!store.layout.editorIsExpanded || !isLoggedIn()) && !store.prefs.isFirstVisit" class="w-16 content-center text-center hidden md:table-cell lg:table-cell xl:table-cell" :key="generateKey(relay, 'check.write')">
<span class="m-auto block align-middle" :class="getCheckIndicator(relay, 'write')" v-if="!isPayToRelay(relay)">
<span class="align-middle" v-if="isLoggedIn() && store.user.kind3?.[relay]?.write">
<svg class="inline-block" :class="getCheckIndicatorPolicy" fill="none" stroke="rgba(0,0,0,0.5)" stroke-width="3" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
Expand All @@ -329,7 +329,7 @@
:href="this.store.results.get(relay)?.validP2R ? this.store.results.get(relay).info.payments_url : null"
class="block align-center" target="_blank">
<svg id="Layer_1" class="w-5 h-5 align-center inline-block" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 360" v-if="isPayToRelay(relay)">
<!-- <circle :style="this.store.results.get(relay).validP2R ? 'fill:#f8991d' : 'fill:red'" class="cls-1" cx="180" cy="180" r="179"/> -->
<circle style="fill:#f8991d" class="cls-1" cx="180" cy="180" r="179"/>
<rect class="fill-white dark:fill-black" x="201.48" y="37.16" width="23.49" height="40.14" transform="translate(21.82 -52.79) rotate(14.87)"/>
<rect class="fill-white dark:fill-black" x="135.03" y="287.5" width="23.49" height="40.14" transform="translate(83.82 -27.36) rotate(14.87)"/>
Expand All @@ -338,7 +338,7 @@
<rect class="fill-white dark:fill-black" x="152.89" y="156.52" width="23.49" height="167.49" transform="translate(439.1 142.78) rotate(104.87)"/>
</svg>
</a>
</td>
</td> -->

<!-- editor -->
<td v-if="store.jobs.getActiveSlug != 'user/list/contacts'
Expand Down
12 changes: 8 additions & 4 deletions src/components/relays/jobs/JobQueue.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<span class="inline-block mr-12 pt-1.5">
<span class="text-white/40 lg:text-sm mx-2 text-xs font-bold">
<MigrationsJob
/>
<div v-if="this.isSingle">

<CheckGeo
Expand Down Expand Up @@ -56,15 +58,15 @@
v-if="store.prefs.clientSideProcessing
&& !isSingle
" />

<UserRelayList />

<RelayOperatorJob
v-if="isSingle" />

<div v-if="this.store.prefs.isFirstVisit">
<FirstVisit
v-if="this.store.prefs.isFirstVisit
&&
this.store.jobs.getLastUpdate('relays/seed')
v-if="this.store.jobs.getLastUpdate('relays/seed')
&& !isSingle"/>
</div>

Expand Down Expand Up @@ -96,6 +98,7 @@ import GetTopics from './GetTopics.vue'
import CheckP2R from './CheckP2R.vue'
import RelayOperatorJob from './RelayOperatorJob.vue'
import FirstVisit from './FirstVisit.vue'
import MigrationsJob from './MigrationsJob.vue'
export default defineComponent({
name: "JobQueue",
Expand All @@ -114,7 +117,8 @@ export default defineComponent({
GetTopics,
CheckP2R,
RelayOperatorJob,
FirstVisit
FirstVisit,
MigrationsJob
},
data(){
return {
Expand Down
89 changes: 89 additions & 0 deletions src/components/relays/jobs/MigrationsJob.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<template>
<!-- {{ store.prefs.migration }} -->
<span
v-if="this.store.jobs.getActiveSlug === slug"
class="text-inherit">
<span class="text-inherit">Welcome</span>
</span>
</template>

<style scoped>
</style>

<script>
import { defineComponent } from 'vue'
import { setupStore } from '@/store'
import RelayMethods from '@/shared/relays-lib.js'
import SharedComputed from '@/shared/computed.js'
export default defineComponent({
name: 'MigrationsJob',
components: {},
data() {
return {
slug: 'migrations', //REMEMBER TO CHANGE!!!
currentMigration: 1
}
},
setup(){
return {
store : setupStore()
}
},
created(){
clearInterval(this.interval)
},
unmounted(){
clearInterval(this.interval)
},
beforeMount(){},
mounted(){
this.Migrations(this.name)
},
updated(){},
computed: Object.assign(SharedComputed, {}),
methods: Object.assign({
Migrations(force){
const self = this
console.log('invalidate:', self.store.prefs.migration >= this.currentMigration)
if( self.store.prefs.migration >= this.currentMigration && !force )
return
this.queueJob(
self.slug,
async () => {
console.log('is function', !(self?.[`migration${this.currentMigration}`] instanceof Function))
if( !(self?.[`migration${this.currentMigration}`] instanceof Function) )
return
await self[`migration${this.currentMigration}`]()
this.store.jobs.completeJob(this.slug)
},
true
)
},
async migration1(){
await this.storageClearAll()
},
timeUntilRefresh(){
return this.timeSince(Date.now()-(this.store.jobs.getLastUpdate(this.slug)+this.store.prefs.duration-Date.now()))
},
timeSinceRefresh(){
return this.timeSince(this.store.jobs.getLastUpdate(this.slug)) || Date.now()
},
}, RelayMethods),
props: {},
})
</script>
<style scoped>
#refresh { font-size: 12pt; color:#666; margin-bottom:15px }
#refresh button { cursor: pointer; border-radius: 3px; border: 1px solid #a0a0a0; color:#333 }
#refresh button:hover {color:#000;}
#refresh button[disabled] {color:#999 !important; border-color:#e0e0e0}
</style>
2 changes: 1 addition & 1 deletion src/components/relays/jobs/RefreshJob.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const localMethods = {
queueOpts: function(){
return {
maxQueues: 2, //this.store.prefs.firstVisit? 4: 5,
concurrency: 11, //this.store.prefs.firstVisit? 5: 10,
concurrency: 6, //this.store.prefs.firstVisit? 5: 10,
fastTimeout: 30000, //this.store.prefs.firstVisit? 5000: 10000,
throttleMillis: 1000,
RelayChecker: this.checkerOpts()
Expand Down
5 changes: 4 additions & 1 deletion src/components/relays/pages/RelaysDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,25 @@
<DetailLatencyBlock :result="result" />


<div class="bg-yellow-300/50 dark:bg-yellow-300/10 text-black/80 dark:text-white/70 border border-white/10 py-4 px-8 rounded-md">
<div v-if="pulses" class="bg-yellow-300/50 dark:bg-yellow-300/10 text-black/80 dark:text-white/70 border border-white/10 py-4 px-8 rounded-md">
Historical connection, read and write latency are experimental, interpret data with a grain of salt. This data is constantly being improved.
</div>


<DetailHistory
v-if="pulses"
label="Connectability"
ability="connect"
:result="result" />

<DetailHistory
v-if="pulses"
label="Readability"
ability="read"
:result="result" />

<DetailHistory
v-if="pulses"
label="Writability"
ability="write"
:result="result" />
Expand Down
16 changes: 16 additions & 0 deletions src/shared/relays-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,22 @@ export default {
return this.$storage.removeStorageSync(key)
},

async storageClearAll(tries){
if(!tries)
tries = 0
Object.keys(this.store).forEach( store => this.store[store].$reset )
localStorage.clear()
if(tries < 3)
this.storageClearAll(tries++)
else
await new Promise( resolve =>
setTimeout( () => {
this.$forceUpdate
resolve()
}, 100)
)
},

getAggregate: function(result) {

if(!result?.latency?.connect)
Expand Down
3 changes: 2 additions & 1 deletion src/store/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineStore } from 'pinia'

export const usePrefsStore = defineStore('prefs', {
state: () => ({
migration: 0,
firstVisit: true,
refresh: true,
duration: 6*60*60*1000,
Expand Down Expand Up @@ -30,7 +31,7 @@ export const usePrefsStore = defineStore('prefs', {
connectTimeout: 15*1000,
writeTimeout: 15*1000,
readTimeout: 15*1000,
runtimeGeo: true
runtimeGeo: true,
}),
getters: {
get: state => key => state?.[key],
Expand Down

0 comments on commit f68c988

Please sign in to comment.