@action fetchAlertHistory(serviceName, operationName, type, from, interval) { this.historyPromiseState = fromPromise( axios .get(`/api/alert/${encodeURIComponent(serviceName)}/${encodeURIComponent(operationName)}/${type}/history?from=${from}&interval=${interval}`) .then((result) => { this.alertHistory = result.data; }) .catch((result) => { AlertDetailsStore.handleError(result); }) ); }
action(event => { const userID = event.target.value; for (let i = 0; i < this.props.ctx.users.users.length; i++) { if (this.props.ctx.users.users[i]._id === userID) { this.order.owner = this.props.ctx.users.users[i]; return; } } this.order.owner = { _id: "guest", name: "Guest" }; //Guest user })
action(() => { this.firstCoursesPanels.splice(this.firstCoursesPanels.indexOf(key), 1); for (let i = 0; i < this.menu.firstCourse.items.length; i++) { if (this.menu.firstCourse.items[i].key === key) { this.menu.firstCourse.items.splice(i, 1) break; } } })
action((fc) => { this.menu.firstCourse.items.push({ key: this.firstCoursesPanels.length, value: fc.value, condiments: JSON.parse(JSON.stringify(fc.condiments)) }); this.firstCoursesPanels.push(this.firstCoursesPanels.length); })
@action submitData(newItem) { if (newItem.id) { this.data[this.data.indexOf(this.getById(newItem.id))] = newItem; } else { newItem.id = generateId(); this.data.push(newItem); } if (this.data.length > 1) this.sortData(); }
@action async getArticleList(params) { this.articleListIsLoaded = false; const result = await Service.get(this.URL, params); if (result) { this.articleList = result.data.articles.map(article => new ArticleModel(article)); this.articleListIsLoaded = true; } }
action(event => { const sd = event.target.value, pos = this.order.secondCourse.sideDishes.indexOf(sd); if (pos < 0) { this.order.secondCourse.sideDishes.push(sd) } else { this.order.secondCourse.sideDishes.splice(pos, 1); } this.order.firstCourse = {}; })
@action async remove(contactId) { this.isLoading = true; const response = await Api.delete(`${this.path}/${contactId}`); const status = await response.status; if (status === 200) { this.isLoading = false; this.fetchAll(); } }
action((value) => { if (value) { this.autorefreshInterval = setInterval(() => this.fetch(), 8000); } else { clearInterval(this.autorefreshInterval); } this.autorefresh = value; })
@action async updateUser({user}) { try { const { data } = await Service.authPut('/user', {user}); this.setCurrentUser(data.user); return data.user } catch (err) { throw err; } }
// demo only, model in UI @action plusOne() { this.demoNumber++; // increment the number. just setting the var re-renders if(this.demoNumber>2){ this.demoNumber=2; } }
@action async updateArticle(slug, article) { const { data } = await Service.authPut(`${this.URL}/${slug}`, article) this.currentArticle = new ArticleModel(data.article); }
@action async logout() { this.currentUser = null; destroyToken(); }
@action async getFeed(params) { this.articleListIsLoaded = false; const result = await Service.authGet(`${this.URL}/feed`, { params }); if (result) { this.articleList = result.data.articles.map(article => new ArticleModel(article)); this.articleListIsLoaded = true; } }
@action setAddingError() { this.addingError = true; this.isAdding = false; }