Skip to content

Commit

Permalink
Add hiddenOnPage
Browse files Browse the repository at this point in the history
  • Loading branch information
saikksub committed Jan 13, 2019
1 parent 91f1a9b commit 12ebb2c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 14 deletions.
8 changes: 7 additions & 1 deletion src/renderer/app.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

const DEFAULT_THREAD_COUNT = 2

export default {
ENDPOINTS: {
addBlock: 'api/2.0/dbfs/add-block',
Expand All @@ -11,5 +14,8 @@ export default {
put: 'api/2.0/dbfs/put',
read: 'api/2.0/dbfs/read'
},
defaultThreadCount: 4
defaultThreadCount: DEFAULT_THREAD_COUNT,
defaultSettings: [
{ key: 'thread-count', value: DEFAULT_THREAD_COUNT }
]
}
26 changes: 20 additions & 6 deletions src/renderer/components/Layouts/ApplicationBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
v-for="item in buttons.right"
:key="item.id">
<v-btn
v-if="checkPlatform(item)"
v-if="checkPlatform(item) && hiddenOnPage(item)"
class="drag-safe btn"
small
icon
Expand Down Expand Up @@ -80,7 +80,8 @@ export default {
icon: 'fa-download',
callback: () => { this.toggleDialog({ name: 'transferState' }) },
platforms: ['darwin', 'win32', 'linux'],
tooltip: 'Download/Upload Activity'
tooltip: 'Download/Upload Activity',
hiddenOnPages: []
}
],
right: [
Expand All @@ -90,24 +91,26 @@ export default {
icon: 'fa-cog',
callback: () => { this.openDialog({ name: 'settings' }) },
platforms: ['darwin', 'win32', 'linux'],
tooltip: 'Settings'
tooltip: 'Settings',
hiddenOnPages: ['auth']
},
{
id: 'id-app-about',
text: 'About',
icon: 'fa-star',
callback: () => { this.openDialog({ name: 'about' }) },
platforms: ['darwin', 'win32', 'linux'],
tooltip: 'About'
},
tooltip: 'About',
hiddenOnPages: []
}/* ,
{
id: 'id-app-logout',
text: 'Logout',
icon: 'fa-power-off',
callback: () => { console.log(this.isLoggedIn()) },
platforms: ['darwin', 'win32', 'linux'],
tooltip: 'Logout'
}
} */
]
}
}
Expand All @@ -125,6 +128,17 @@ export default {
},
checkPlatform: function (item) {
return (item.platforms.findIndex(x => x === this.getPlatform()) > -1)
},
hiddenOnPage: function (item) {
if (item && item.hiddenOnPages &&
item.hiddenOnPages.constructor === [].constructor &&
item.hiddenOnPages.length > 0) {
console.log(item)
if (item.hiddenOnPages.indexOf(this.routeName) > -1) {
return false
}
}
return true
}
}
}
Expand Down
31 changes: 24 additions & 7 deletions src/renderer/store/modules/config/actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ipcRenderer } from 'electron'
import { platform } from 'os'
import appConfig from '@/app.config.js'

const uniqid = require('uniqid')

Expand Down Expand Up @@ -60,13 +61,29 @@ export default {
return new Promise((resolve, reject) => {
const settings = context.getters.getSettings
if (settings && settings.constructor === [].constructor) {
const index = settings.findIndex(
x => x.key === key
)
if (index > -1) {
console.log('setting value', settings[index].value)
resolve({
value: parseInt(settings[index].value)
if (settings.length > 0) {
const index = settings.findIndex(
x => x.key === key
)
if (index > -1) {
resolve({
value: parseInt(settings[index].value)
})
} else {
// Resolve default value
resolve({
value: appConfig.defaultThreadCount
})
}
} else {
// Settings not found in the database
// Create new settings from app.config.js
console.log('DEBUG:111')
const settings = Object.assign([], appConfig.defaultSettings)
settings.forEach((item) => {
if (item && item.constructor === {}.constructor) {
item.key && context.dispatch('updateSettings', item)
}
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/store/modules/navigator/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ const base64 = require('file-base64')

export default {
initTransferActivity: function (context) {
console.log('initTransferActivity')
context.dispatch('getSetting', {
key: 'thread-count'
}).then(({ value }) => {
console.log(value)
transferActivity = new TransferActivity({
threadCount: value
})
Expand Down

0 comments on commit 12ebb2c

Please sign in to comment.