Skip to content

Commit

Permalink
Show local ip in settings page (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainMarty authored May 14, 2019
2 parents 63868b5 + c54e0a3 commit 6a98e9f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"electron-log": "^3.0.5",
"electron-updater": "^4.0.6",
"express": "^4.16.4",
"ip": "^1.1.5",
"material-icons": "^0.3.1",
"morgan": "^1.9.1",
"printer": "^0.2.2",
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<span class="md-list-item-text">Printers</span>
</md-list-item>

<!-- <md-list-item to="/settings">
<md-list-item to="/settings">
<md-icon>settings</md-icon>
<span class="md-list-item-text">Settings</span>
</md-list-item> -->
</md-list-item>
</md-list>

<p class="made-with-love">Made with <span class="heart">❤</span> by GUIDAP</p>
Expand Down Expand Up @@ -71,6 +71,7 @@
.md-drawer {
width: 230px;
max-width: calc(100vw - 125px);
min-height: 100vh;
}
.md-content.md-app-content {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<md-icon>refresh</md-icon>
</md-button>
</md-subheader>
<md-card v-for="pr in printers" :key="pr.name">
<md-card v-for="pr in printers" :key="pr.name" md-with-hover>
<md-card-header>
<md-card-media>
<md-icon class="md-size-3x">print</md-icon>
Expand Down
38 changes: 38 additions & 0 deletions src/renderer/components/Settings.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,52 @@
<template>
<div>
<md-card md-with-hover>
<md-card-header>
<md-card-media>
<md-icon class="md-size-3x">router</md-icon>
</md-card-media>

<md-card-header-text>
<div class="md-title">
{{ ip }} &nbsp;<md-button class="md-dense md-icon-button md-primary" @click="copyIp()"><md-icon>content_copy</md-icon></md-button>
</div>
<div class="md-subhead">Local IP</div>
</md-card-header-text>
</md-card-header>
</md-card>

<md-snackbar md-position="center" :md-duration="4000" :md-active.sync="showSnackbar" md-persistent>
<span>Local IP copied in your clipboard!</span>
</md-snackbar>
</div>
</template>

<script>
import ip from 'ip'
import Vue from 'vue'
import { MdCard, MdSnackbar } from 'vue-material/dist/components'
Vue.use(MdCard)
Vue.use(MdSnackbar)
export default {
name: 'settings',
data: function () {
return {
ip: ip.address(),
showSnackbar: false
}
},
methods: {
copyIp: function () {
const el = document.createElement('textarea')
el.value = this.ip
document.body.appendChild(el)
el.select()
document.execCommand('copy')
document.body.removeChild(el)
this.showSnackbar = true
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export default new Router({
name: 'home',
component: require('@/components/Home').default
},
// {
// path: '/settings',
// name: 'settings',
// component: require('@/components/Settings').default
// },
{
path: '/settings',
name: 'settings',
component: require('@/components/Settings').default
},
{
path: '*',
redirect: '/'
Expand Down

0 comments on commit 6a98e9f

Please sign in to comment.