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

114 lines
2.1 KiB

2 years ago
/**
* Store for apps
2 years ago
*
* @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
2 years ago
*
*/
2 years ago
import AppsDatabase from './../database/apps.js'
import tagsStore from './../stores/tags.js'
2 years ago
import observable from '@riotjs/observable'
2 years ago
2 years ago
export default observable({
2 years ago
parameters: {
sort: 'name',
tags: []
},
/**
* getting all apps
*
*/
2 years ago
get() {
const appsDatabase = new AppsDatabase()
appsDatabase.find(this.parameters).then((data) => {
2 years ago
this.trigger('ready', data)
})
},
/**
* getting single apps
*
* @param {uuid} id
*
*/
2 years ago
getOne(id) {
const appsDatabase = new AppsDatabase()
appsDatabase.findOneById(id).then((data) => {
this.trigger('readyOne', data)
})
},
/**
* create new app
*
* @param {object} data
*
*/
2 years ago
post(data) {
const appsDatabase = new AppsDatabase()
appsDatabase.create(data).then((data) => {
this.trigger('success', data)
tagsStore.get()
2 years ago
})
},
/**
* update app
*
* @param {object} data
*
*/
2 years ago
put(data) {
const appsDatabase = new AppsDatabase()
appsDatabase.update(data).then((data) => {
this.trigger('success', data)
tagsStore.get()
2 years ago
})
},
/**
* update app
*
* @param {object} data
*
*/
remove(data) {
const appsDatabase = new AppsDatabase()
appsDatabase.remove(data).then(() => {
this.trigger('close')
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()
2 years ago
}
})