You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
potato-launcher/src/js/stores/apps.js

99 lines
1.8 KiB

/**
* Store for apps
*
* @author Björn Hase
* @license hhttps://www.gnu.org/licenses/gpl-3.0.en.html GPL-3
* @link https://gitea.node001.net/HerrHase/potato-launcher.git
*
*/
import AppsDatabase from './../database/apps.js'
import tagsStore from './../stores/tags.js'
import observable from '@riotjs/observable'
export default observable({
parameters: {
sort: 'name',
tags: []
},
/**
* getting all apps
*
*/
get() {
const appsDatabase = new AppsDatabase()
appsDatabase.find(this.parameters).then((data) => {
this.trigger('ready', data)
})
},
/**
* getting single apps
*
* @param {uuid} id
*
*/
getOne(id) {
const appsDatabase = new AppsDatabase()
appsDatabase.findOneById(id).then((data) => {
this.trigger('readyOne', data)
})
},
/**
* create new app
*
* @param {object} data
*
*/
post(data) {
const appsDatabase = new AppsDatabase()
appsDatabase.create(data).then((data) => {
this.trigger('success', data)
tagsStore.get()
})
},
/**
* update app
*
* @param {object} data
*
*/
put(data) {
const appsDatabase = new AppsDatabase()
appsDatabase.update(data).then((data) => {
this.trigger('success', data)
tagsStore.get()
})
},
/**
* orderBy and run get
*
* @param {string} orderBy
*
*/
sort(column) {
this.parameters.sort = column
this.get()
},
/**
* filter and run get
*
* @param {array} tags
*
*/
filter(tags) {
this.parameters.tags = tags
this.get()
}
})