Skip to content

Commit

Permalink
fix: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Jun 15, 2021
1 parent b9ce036 commit 1e9605b
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 153 deletions.
7 changes: 2 additions & 5 deletions packages/api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ export class MongoManager {
client: MongoClient

async start (uri?: string): Promise<Db | null> {
uri =
uri ||
process.env.MONGO_CLUSTER_URL ||
`mongodb://${process.env.MONGO_DATABASE_USERNAME}:${process.env.MONGO_DATABASE_PASSWORD}@${process.env.DB_HOSTNAME}:${process.env.MONGO_PORT}/${process.env.MONGO_INITDB_DATABASE}`
return this.connect(uri, process.env.MONGO_INITDB_DATABASE)
const mongoDbUri = `${uri || process.env.MONGO_URI}`
return this.connect(mongoDbUri, process.env.MONGO_INITDB_DATABASE)
}

async connect (uri: string, name: string): Promise<Db | null> {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createServer } from './server'

async function main () {
const mongoManager = new MongoManager()
const db = await mongoManager.start(process.env.MONGO_CLUSTER_URL)
const db = await mongoManager.start(process.env.MONGO_URI)
const server = await createServer(db)

server.listen().then(({ url }) => {
Expand Down
8 changes: 5 additions & 3 deletions packages/api/src/repository/Feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class FeedRepository {
}

async insert (feed: Omit<FeedDbObject, '_id'>) {
console.log('feed', feed)
const response = await this.collection.insertOne(feed)

return this._normalizeId(response.ops[0])
Expand All @@ -28,9 +29,10 @@ export class FeedRepository {
return this._normalizeId(response.value)
}

async get (feedId: string) {
const a = await this.collection.findOne({ _id: new ObjectId(feedId) })
return this._normalizeId(a)
async get (id: string) {
return this._normalizeId(
await this.collection.findOne({ _id: new ObjectId(id) })
)
}

private _normalizeId (feed: FeedDbObject) {
Expand Down
3 changes: 1 addition & 2 deletions packages/api/src/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const resolvers = {
},

feed: async (_parent, args, { feedRepository }: Context) => {
const { feedId } = args
return await feedRepository.get(feedId)
return await feedRepository.get(args.id)
}
},
Feed: {
Expand Down
3 changes: 3 additions & 0 deletions packages/api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { ResultRequestRepository } from './repository/ResultRequest'

// const resultRequest1 = await resultRequestRepository.insert({
// feedId: feed1._id.toString(),
// address: '0x00000000',
// result: '1000.0',
// label: '$',
// requestId: '1',
Expand All @@ -34,6 +35,7 @@ import { ResultRequestRepository } from './repository/ResultRequest'

// const resultRequest2 = await resultRequestRepository.insert({
// feedId: feed1._id.toString(),
// address: '0x00000000',
// result: '2000.0',
// label: '$',
// requestId: '1',
Expand All @@ -52,6 +54,7 @@ import { ResultRequestRepository } from './repository/ResultRequest'
// })
// const resultRequest3 = await resultRequestRepository.insert({
// feedId: feed1._id.toString(),
// address: '0x00000000',
// result: '3000.0',
// label: '$',
// requestId: '1',
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/typeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const typeDefs = gql`
type Query {
feeds: [Feed]!
feed(feedId: String!): Feed
feed(id: String!): Feed
}
`

Expand Down
6 changes: 3 additions & 3 deletions packages/api/test/feeds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ describe('feeds', function () {
const { _id } = result.ops[0]

const GET_FEED = gql`
query Feed($feedId: String!) {
feed(feedId: $feedId) {
query Feed($id: String!) {
feed(id: $id) {
id
name
address
Expand All @@ -188,7 +188,7 @@ describe('feeds', function () {
const result2 = await state.testClient.query({
query: GET_FEED,
variables: {
feedId: _id.toString()
id: _id.toString()
}
})

Expand Down
7 changes: 5 additions & 2 deletions packages/ui/apollo/queries/feed.gql
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
query feed($feedId: String!) {
feed(feedId: $feedId) {
query feed($id: String!) {
feed(id: $id) {
id
name
address
lastResult
requests {
feedId,
result,
drTxHash,
label,
address,
requestId,
timestamp,
}
Expand Down
76 changes: 38 additions & 38 deletions packages/ui/components/DataFeedDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ export default {
query: feed,
variables() {
return {
feedId: this.id,
id: this.id,
}
},
},
},
data() {
return {
name: 'btc/eur',
id: this.$route.params.id,
}
},
Expand All @@ -69,10 +68,10 @@ export default {
if (this.feed.requests.length > 0) {
return this.feed.requests.map((request) => {
return {
witnetLink: '0x9aa619d0afa25ddbf71db619d0afa25ddbf71dbf74',
etherscanLink: '0x9aa619d0afa25ddbf71db619d0afa25ddbf71dbf74',
witnetLink: request.drTxHash,
etherscanLink: request.address,
data: {
label: '$',
label: request.label,
value: request.result,
},
timestamp: request.timestamp,
Expand All @@ -89,48 +88,49 @@ export default {
<style lang="scss" scoped>
.content {
display: grid;
grid-template-rows: max-content max-content max-content 1fr;
grid-template-columns: 1fr;
grid-template: max-content max-content max-content 1fr / 1fr;
row-gap: 16px;
}
.contract-container {
margin: 16px;
margin-top: 150px;
.contract-address {
font-size: 24px;
padding: 24px;
display: block;
cursor: pointer;
color: var(--contract-address);
}
}
.chart {
height: 400px;
}
.section-header {
display: flex;
justify-content: center;
align-items: flex-end;
margin-top: 16px;
width: 100%;
.back-to-list {
position: absolute;
left: 120px;
.icon {
.contract-container {
margin-top: 150px;
.contract-address {
word-break: break-all;
font-size: 24px;
color: var(--text);
padding: 24px;
display: block;
cursor: pointer;
color: var(--contract-address);
}
&:hover {
}
.chart {
height: 400px;
}
.section-header {
display: flex;
justify-content: center;
align-items: flex-end;
margin-top: 16px;
width: 100%;
.back-to-list {
position: absolute;
left: 120px;
.icon {
color: var(--text-hover);
font-size: 24px;
color: var(--text);
}
&:hover {
.icon {
color: var(--text-hover);
}
}
}
}
}
@media (max-width: 1200px) {
.section-header {
.back-to-list {
left: 16px;
.content {
.section-header {
.back-to-list {
left: 16px;
}
}
}
}
Expand Down
13 changes: 7 additions & 6 deletions packages/ui/components/DataFeeds.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<div class="feeds-container">
<FeedCard
v-for="(feed, index) in feeds"
:key="index"
v-for="feed in feeds"
:key="feed.name + feed.network"
:details-path="feed.detailsPath"
:name="feed.name"
:img="feed.img"
Expand All @@ -28,10 +28,11 @@ export default {
<style>
.feeds-container {
display: grid;
column-gap: 24px;
row-gap: 24px;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
grid-template-rows: repeat(auto-fill, minmax(150px, 1fr));
grid-gap: 24px;
grid-template: repeat(auto-fill, minmax(150px, 1fr)) / repeat(
auto-fill,
minmax(300px, 1fr)
);
justify-items: center;
align-items: center;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/components/Fieldset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default {
.fieldset {
display: grid;
grid-template-rows: max-content max-content;
max-width: 100vw;
padding: 16px;
.title {
color: var(--fieldset-title);
font-weight: bold;
Expand Down
44 changes: 23 additions & 21 deletions packages/ui/components/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<div>
<div class="section-header">
<p class="section-title">{{ $t('data_feeds') }}</p>
<Select
<!-- <Select
:options="options"
:default-option="selected"
@update-selected="updateSelected"
/>
/> -->
</div>
<DataFeeds v-if="!$apollo.loading" :feeds="dataFeeds" class="data-feeds" />
</div>
Expand All @@ -25,18 +25,20 @@ export default {
data() {
return {
dataFeeds: [],
options: [
{ label: 'All' },
{ label: 'Rinkeby' },
{ label: 'Goerly' },
{ label: 'Mainnet' },
],
selected: { label: 'All' },
// options: [
// { label: 'All' },
// { label: 'Rinkeby' },
// { label: 'Goerly' },
// { label: 'Mainnet' },
// ],
// selected: { label: 'All' },
}
},
computed: {
allFeeds() {
console.log(this.feeds)
return this.feeds.map((feed) => {
console.log(feed)
return {
detailsPath: {
name: 'feeds-id',
Expand All @@ -57,18 +59,18 @@ export default {
mounted() {
this.dataFeeds = this.allFeeds
},
methods: {
updateSelected(selectedOption) {
this.selected = selectedOption
if (this.selected.label === 'All') {
this.dataFeeds = this.allFeeds
} else {
this.dataFeeds = this.allFeeds.filter((feed) => {
return feed.network === this.selected.label.toLowerCase()
})
}
},
},
// methods: {
// updateSelected(selectedOption) {
// this.selected = selectedOption
// if (this.selected.label === 'All') {
// this.dataFeeds = this.allFeeds
// } else {
// this.dataFeeds = this.allFeeds.filter((feed) => {
// return feed.network === this.selected.label.toLowerCase()
// })
// }
// },
// },
}
</script>

Expand Down
14 changes: 7 additions & 7 deletions packages/ui/components/MainSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
padding: 0 180px;
min-height: 100vh;
display: grid;
grid-template-rows: 110px 1fr;
grid-template-rows: 150px 1fr;
grid-template-columns: 1fr;
max-width: 1500px;
row-gap: 24px;
margin: 0 auto;
padding-bottom: 48px;
}
.theme-switch {
position: fixed;
bottom: 0;
z-index: 5;
right: 0;
.theme-switch {
position: fixed;
bottom: 0;
z-index: 5;
right: 0;
}
}
@media (max-width: 1200px) {
.main-section {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/components/SvgIcon.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<template>
<!-- We are using v-html assuming we never use user-provided content -->
<!-- eslint-disable-next-line vue/no-v-html -->
<div v-html="require(`~/assets/svg/${name}.svg?raw`)" />
</template>
Expand Down
Loading

0 comments on commit 1e9605b

Please sign in to comment.