|
|
|
@ -5,6 +5,8 @@
|
|
|
|
|
<!-- header -->
|
|
|
|
|
<tiny-sidebar-form-header title="New" close={ (event) => { handleClose(event) }}></tiny-sidebar-form-header>
|
|
|
|
|
|
|
|
|
|
<div class="sidebar__form">
|
|
|
|
|
|
|
|
|
|
<!-- body -->
|
|
|
|
|
<form class="form" novalidate method="post" onsubmit={ (event) => ( state.validator.submit(event) ) }>
|
|
|
|
|
<div class="sidebar__body">
|
|
|
|
@ -23,7 +25,7 @@
|
|
|
|
|
command*
|
|
|
|
|
<div class="field-input-group">
|
|
|
|
|
<input class="field-text" type="text" name="command" value="{ state.current.command ? state.current.command : '' }" />
|
|
|
|
|
<button class="button m-bottom-0" type="button" onclick={ handleSelectProgram }>
|
|
|
|
|
<button class="button button--hover-icon-contrast m-bottom-0" type="button" onclick={ handleSelectProgram }>
|
|
|
|
|
<svg class="icon">
|
|
|
|
|
<use xlink:href="symbol-defs.svg#icon-folder" />
|
|
|
|
|
</svg>
|
|
|
|
@ -38,7 +40,7 @@
|
|
|
|
|
<div class="field-group">
|
|
|
|
|
<label class="field-label">
|
|
|
|
|
tags
|
|
|
|
|
<potato-field-tags name="tags" value={ state.current.tags ? state.current.tags : '' }></potato-field-tags>
|
|
|
|
|
<potato-field-tags name="tags"></potato-field-tags>
|
|
|
|
|
</label>
|
|
|
|
|
<field-error name="tags[]"></field-error>
|
|
|
|
|
</div>
|
|
|
|
@ -54,24 +56,24 @@
|
|
|
|
|
<!-- media -->
|
|
|
|
|
<div class="field-group">
|
|
|
|
|
<label class="field-label">
|
|
|
|
|
<button class="button button--upload m-top-3 w-100" type="button" onclick={ (event) => { handleSelectMedia(event) }}>
|
|
|
|
|
Add Image
|
|
|
|
|
<svg class="icon m-left-3">
|
|
|
|
|
Thumbnail<br />
|
|
|
|
|
<button class="button button--hover-icon-contrast m-top-3" type="button" onclick={ (event) => { handleSelectThumbnail(event) }}>
|
|
|
|
|
<svg class="icon">
|
|
|
|
|
<use xlink:href="symbol-defs.svg#icon-image" />
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</label>
|
|
|
|
|
<div class="field-media" if={ state.current.media }>
|
|
|
|
|
<button class="button button--small" type="button" onclick={ (event) => { handleRemoveMedia(event) }}>
|
|
|
|
|
<svg class="icon">
|
|
|
|
|
<use xlink:href="symbol-defs.svg#icon-delete" />
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
<div class="field-media" if={ state.current.thumbnail }>
|
|
|
|
|
<div class="field-media__img">
|
|
|
|
|
<img src={ toImage(state.current.media) } />
|
|
|
|
|
<button class="button button--hover-icon-contrast" type="button" onclick={ (event) => { handleRemoveThumbnail(event) }}>
|
|
|
|
|
<svg class="icon">
|
|
|
|
|
<use xlink:href="symbol-defs.svg#icon-delete" />
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
<img class="w-100" src={ toImage(state.current.thumbnail) } />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<field-error name="media"></field-error>
|
|
|
|
|
<field-error name="thumbnail"></field-error>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<tiny-loading active={ state.loading }></tiny-loading>
|
|
|
|
@ -80,6 +82,7 @@
|
|
|
|
|
<!-- footer -->
|
|
|
|
|
<tiny-sidebar-form-footer id={ state.current.id ? state.current.id : false } loading={ state.loading }></tiny-sidebar-form-footer>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -97,6 +100,9 @@
|
|
|
|
|
// store for sidebar
|
|
|
|
|
import appsStore from './../stores/apps.js'
|
|
|
|
|
|
|
|
|
|
// store for tags
|
|
|
|
|
import tagsStore from './../stores/tags.js'
|
|
|
|
|
|
|
|
|
|
// validator
|
|
|
|
|
import FormValidator from '@tiny-components/validator/src/formValidator.js'
|
|
|
|
|
|
|
|
|
@ -118,12 +124,20 @@
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
async onMounted() {
|
|
|
|
|
onMounted() {
|
|
|
|
|
|
|
|
|
|
// adding event for open sidebar
|
|
|
|
|
formStore.on('open', () => {
|
|
|
|
|
this.state.open = true
|
|
|
|
|
this.update()
|
|
|
|
|
formStore.on('open', (id) => {
|
|
|
|
|
|
|
|
|
|
// if id is send, load apps from pouchdb
|
|
|
|
|
if (id) {
|
|
|
|
|
Neutralino.extensions.dispatch('js.neutralino.pouchdb', 'pouchdb.apps.findOne', {
|
|
|
|
|
'id': id
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.state.open = true
|
|
|
|
|
this.update()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// creating formValidator
|
|
|
|
@ -144,6 +158,27 @@
|
|
|
|
|
this.handleSuccess(event, data)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// receive from extensions database
|
|
|
|
|
Neutralino.events.on('pouchdb.apps.success', (event) => {
|
|
|
|
|
|
|
|
|
|
appsStore.trigger('updated')
|
|
|
|
|
|
|
|
|
|
// stop loading
|
|
|
|
|
this.state.loading = false
|
|
|
|
|
this.update()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// receive from extensions database
|
|
|
|
|
Neutralino.events.on('pouchdb.apps.readyOne', (event) => {
|
|
|
|
|
|
|
|
|
|
this.state.current = event.detail
|
|
|
|
|
tagsStore.trigger('update', this.state.current.tags)
|
|
|
|
|
|
|
|
|
|
// stop loading
|
|
|
|
|
this.state.loading = false
|
|
|
|
|
this.update()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -160,7 +195,19 @@
|
|
|
|
|
'defaultPath': '/home/'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.current.command = entry
|
|
|
|
|
this.state.current.command = entry
|
|
|
|
|
this.update()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
handleRemoveThumbnail(event) {
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
|
|
|
|
|
this.state.current.thumbnail = null
|
|
|
|
|
this.update()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
@ -176,20 +223,11 @@
|
|
|
|
|
this.state.loading = true
|
|
|
|
|
this.update()
|
|
|
|
|
|
|
|
|
|
// receive from extensions database
|
|
|
|
|
Neutralino.events.on('pouchdb.apps.success', (event) => {
|
|
|
|
|
|
|
|
|
|
appsStore.trigger('updated')
|
|
|
|
|
|
|
|
|
|
// stop loading
|
|
|
|
|
this.state.loading = false
|
|
|
|
|
this.update()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
data.media = this.state.current.media
|
|
|
|
|
// adding thumbnail
|
|
|
|
|
data.thumbnail = this.state.current.thumbnail
|
|
|
|
|
|
|
|
|
|
// send to extensions database
|
|
|
|
|
Neutralino.extensions.dispatch('js.neutralino.database', 'pouchdb.apps.create', data)
|
|
|
|
|
Neutralino.extensions.dispatch('js.neutralino.pouchdb', 'pouchdb.apps.create', data)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -218,16 +256,20 @@
|
|
|
|
|
this.update()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
toImage(media) {
|
|
|
|
|
return 'data:image/png;base64,' + media
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param {object} media
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
toImage(media) {
|
|
|
|
|
return 'data:image/png;base64,' + media
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reset() {
|
|
|
|
|
this.state.current = {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|