Skip to content

Commit

Permalink
settings with defaults made
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilli committed Jul 25, 2017
1 parent f14148d commit dd56136
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 9 deletions.
4 changes: 3 additions & 1 deletion tangle-explorer-web/src/components/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
</div>
<div class='right'>
<div class="bar-button">
<ceri-icon class="icon" name="fa-gear"></ceri-icon>
<router-link :to="{ name: 'Settings' }">
<ceri-icon class="icon" name="fa-gear"></ceri-icon>
</router-link>
</div>
<div class='search'>
<search-field></search-field>
Expand Down
17 changes: 17 additions & 0 deletions tangle-explorer-web/src/pages/Settings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template lang="html">

</template>

<script>
export default {
data() {
settings = store.get('settings') || {}
return {
settings
}
}
}
</script>

<style lang="css">
</style>
20 changes: 13 additions & 7 deletions tangle-explorer-web/src/router/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Vue from 'vue';
import Router from 'vue-router';
import Home from '@/pages/Home';
import Transaction from '@/pages/Transaction';
import Address from '@/pages/Address';
import Search from '@/pages/Search';
import Bundle from '@/pages/Bundle';
import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/Home'
import Transaction from '@/pages/Transaction'
import Address from '@/pages/Address'
import Search from '@/pages/Search'
import Bundle from '@/pages/Bundle'
import Settings from '@/pages/Settings'

Vue.use(Router);

Expand All @@ -30,6 +31,11 @@ export default new Router({
name: 'Home',
component: Home,
},
{
path: '/settings',
name: 'Settings',
component: Settings,
},
{
path: '/search/:query',
name: 'Search',
Expand Down
3 changes: 2 additions & 1 deletion tangle-explorer-web/src/utils/iota-node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const log = require('@/utils/log')
const settings = require('@/utils/settings.js').default

// The global object for node info etc.
var obj = {
Expand All @@ -25,7 +26,7 @@ var obj = {

// Create IOTA instance directly with provider
var iota = new IOTA({
'provider': 'https://n1.iota.nu:443'
'provider': settings.get().nodeUrl
});
obj.iota = iota

Expand Down
13 changes: 13 additions & 0 deletions tangle-explorer-web/src/utils/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const store = require('store')
const defaultSettings = {
nodeUrl: 'https://n1.iota.nu:443'
}

export default {
set(settings) {
store.set('settings', settings)
},
get() {
return Object.assign({}, defaultSettings, store.get('settings'))
}
}

0 comments on commit dd56136

Please sign in to comment.