Skip to content

Commit fb6263e

Browse files
committed
Complete redesign of the app. Add store, changed the flow.
1 parent 374eb91 commit fb6263e

File tree

6 files changed

+448
-501
lines changed

6 files changed

+448
-501
lines changed

quasar.conf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ module.exports = function (ctx) {
6161
'QBanner',
6262
'QSpace',
6363
'QTooltip',
64-
'QChatMessage'
64+
'QChatMessage',
65+
'QForm'
6566
],
6667

6768
directives: [

src/css/app.styl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
.blink {
77
animation: blinker 1s linear infinite;
88
}
9-
109
@keyframes blinker {
1110
50% {
1211
opacity: 0;
1312
}
1413
}
14+
.background-gradient {
15+
background-image: linear-gradient(to bottom right, #00F7A9, #A000FD);
16+
}
17+
1518
// app global css
1619
.bg-vgrey {
1720
background: #CECFD0;

src/pages/Index.vue

Lines changed: 319 additions & 478 deletions
Large diffs are not rendered by default.

src/pages/Login.vue

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
<q-layout>
33
<q-page-container>
44
<q-page class="bg-vblack">
5-
<q-icon name="fas fa-angle-right" class="text-vgreen fixed-center" style="font-size: 5rem;" />
65
<div class="row">
7-
<div class="col bg-vblack window-height q-pa-xl text-center">
8-
<q-img src="statics/icons/icon-512x512.png" spinner-color="vgrey" style="height: 150px; max-width: 150px" />
9-
<div class="text-h5 text-vgrey"><span class="text-weight-bolder">vDexNode</span> dashboard</div>
10-
<div class="text-subtitle1 text-vgrey">Rent your computer to earn VTX</div>
6+
<div class="col background-gradient q-pa-xl text-center window-height">
7+
<q-img src="statics/icons/icon-512x512.png" spinner-color="vdark" style="height: 150px; max-width: 150px" />
8+
<div class="text-h5 text-vdark"><span class="text-weight-bolder">vDexNode</span> dashboard</div>
9+
<div class="text-subtitle1 text-vdark">Rent your computer to earn VTX</div>
1110
</div>
12-
<div class="col bg-vgrey window-height q-pa-xl">
11+
<div class="col bg-white q-pa-xl window-height">
1312
<div class="text-h5">Import private key</div>
1413
<div class="text-subtitle2">Please enter your private key below to start working with vDexNode Dashboard. We will never save or transmit your your key.</div>
15-
<q-input dense v-model="privateKey" :type="isPwd ? 'password' : 'text'" counter color="vdark" ref="input" @keyup.enter="updatePrivate" >
16-
<template v-slot:append>
17-
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer" @click="isPwd = !isPwd" />
18-
</template>
19-
</q-input>
20-
<q-btn color="black" unelevated rounded outline class="full-width q-mt-md" label="Continue" @click="login" />
14+
<q-form @submit="login()">
15+
<q-input dense v-model="privateKey" :type="isPwd ? 'password' : 'text'" counter color="vdark" ref="input" @keyup.enter="login" label="Your private key" :rules="[ val => val && val.length <= 51 || 'Wrong key']">
16+
<template v-slot:append>
17+
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer" @click="isPwd = !isPwd" />
18+
</template>
19+
</q-input>
20+
<q-btn color="black" :disabled="privateKey ? false: true" unelevated rounded outline class="full-width q-mt-md" label="Continue" type="submit" />
21+
</q-form>
2122
</div>
2223
</div>
2324
</q-page>

src/store/index.js

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ Vue.use(Vuex)
1212
function initialState () {
1313
return {
1414
loggedIn: false,
15-
identity: {}
15+
identity: {
16+
voted_i: [],
17+
voted_for: []
18+
}
1619
}
1720
}
1821

@@ -27,17 +30,46 @@ const store = new Vuex.Store({
2730
logout: (state) => {
2831
Object.assign(state, initialState())
2932
},
30-
login: (state, privateKey) => {
33+
setPrivateKey: (state, privateKey) => {
3134
state.identity.privateKey = privateKey
3235
},
36+
setPublicKey: (state, publicKey) => {
37+
state.identity.publicKey = publicKey
38+
},
39+
setAccountName: (state, accountName) => {
40+
state.identity.accountName = accountName
41+
},
3342
setLoggedIn: state => {
3443
state.loggedIn = true
44+
},
45+
setBalance: (state, balance) => {
46+
state.identity.balance = balance
47+
},
48+
setRank: (state, rank) => {
49+
state.identity.rank = rank
50+
},
51+
setTotalRanks: (state, total) => {
52+
state.identity.totalRanks = total
53+
},
54+
setUptime: (state, uptime) => {
55+
state.identity.uptime = uptime
56+
},
57+
setEarned: (state, earned) => {
58+
state.identity.earned = earned
59+
},
60+
setVotedI: (state, data) => {
61+
state.identity.voted_i = data
62+
},
63+
setVotedFor: (state, data) => {
64+
state.identity.voted_for = data
3565
}
3666
},
3767
actions: {
38-
login ({ commit }, privateKey) {
68+
login ({ commit }, data) {
3969
return new Promise((resolve, reject) => {
40-
commit('login', privateKey)
70+
commit('setPrivateKey', data.privateKey)
71+
commit('setPublicKey', data.publicKey)
72+
commit('setAccountName', data.accountName)
4173
commit('setLoggedIn')
4274
resolve()
4375
})

src/util/utils.js

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
import Vue from 'vue'
12
import { shell } from 'electron'
3+
import EosWrapper from '@/util/EosWrapper'
4+
import { userError } from '@/util/errorHandler'
5+
import { userResult } from '@/util/resultHandler'
6+
import axios from 'axios'
27
import store from '@/store'
38
import router from '@/router'
9+
const { app, dialog } = require('electron').remote
10+
const fs = require('fs')
411

512
/**
613
* Function returns an array with removed duplicates by any field in the object
@@ -67,11 +74,38 @@ function formatBytes (bytes, decimals) {
6774
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
6875
}
6976

70-
function login (privateKey) {
71-
store.dispatch('login', { privateKey }).then(() => {
77+
async function login (privateKey) {
78+
try {
79+
var eos = new EosWrapper(privateKey)
80+
Vue.prototype.$eos = eos
81+
} catch (error) {
82+
userError(error, 'Login action: instance of EosWrapper')
83+
throw error
84+
}
85+
86+
try {
87+
var publicKey = eos.privateToPublic(privateKey)
88+
} catch (error) {
89+
userError(error, 'Login action: get public key')
90+
throw error
91+
}
92+
93+
try {
94+
let accounts = await eos.getAccounts(publicKey)
95+
var accountName = accounts.account_names[0] ? accounts.account_names[0] : ''
96+
if (!accountName) {
97+
userError('Seems like you don\'t have an EOS account. An account is required to work with a vDexNode. Please create one using your public key.', 'Login action: get account name')
98+
throw new Error('EOS account is required')
99+
}
100+
} catch (error) {
101+
userError(error, 'Login action: get account name')
102+
throw error
103+
}
104+
105+
store.dispatch('login', { privateKey, publicKey, accountName }).then(() => {
72106
router.push('/')
73-
}).catch(err => {
74-
console.log(err)
107+
}).catch(error => {
108+
userError(error, 'Login action: Saving')
75109
})
76110
}
77111

@@ -81,12 +115,47 @@ function logout () {
81115
})
82116
}
83117

118+
function getInstaller () {
119+
let way = process.env.NODE_WAY
120+
if (way.includes('readme')) {
121+
require('electron').shell.openExternal(process.env.README)
122+
} else if (way.includes('installer')) {
123+
axios({
124+
method: 'get',
125+
url: process.env.INSTALLER,
126+
responseType: 'arraybuffer'
127+
}).then(response => {
128+
forceFileDownload(response)
129+
}).catch((error) => {
130+
userError(error, 'Get Installer action')
131+
throw error
132+
})
133+
}
134+
}
135+
136+
function forceFileDownload (response) {
137+
var options = {
138+
title: 'Save installer',
139+
defaultPath: 'installer',
140+
buttonLabel: 'Save',
141+
142+
filters: [
143+
{ name: 'sh', extensions: ['sh'] }
144+
]
145+
}
146+
147+
dialog.showSaveDialog(options, (filename) => {
148+
fs.writeFileSync(filename, response.data, 'utf-8')
149+
})
150+
}
151+
84152
export {
85153
getUnique,
86154
sortByKey,
87155
openExternal,
88156
formatBytes,
89157
getUniqueLocations,
90158
login,
91-
logout
159+
logout,
160+
getInstaller
92161
}

0 commit comments

Comments
 (0)