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.
Nothing/src/app/services/plan.service.ts

48 lines
1020 B

import { Injectable } from '@angular/core';
import { invoke } from '@tauri-apps/api';
import { from, map } from 'rxjs';
import { Plan } from '../models/plan';
@Injectable({
providedIn: 'root'
})
export class PlanService {
currentPlan?: Plan;
planStore: string[] = [];
constructor() {
this.getPreviousPlans();
}
loadPlan(path: string) {
return from(invoke<Plan>('load_plan', { path })).pipe(
map(plan => {
this.currentPlan = plan;
return plan
})
);
}
loadPlanNoSave(path: string) {
return from(invoke<Plan>('load_plan', { path })).pipe(
);
}
loadBasePlan() {
return from(invoke<Plan>('base_plan'));
}
savePlan(path: string, plan: Plan) {
plan.plan.forEach(elem => {
if (!elem.notes) { elem.notes = "" }
})
return from(invoke<boolean>('save_plan', { path, plan })).subscribe(status => {
});
}
getPreviousPlans() {
from(invoke<string[]>('load_stored_plans')).subscribe(plans => this.planStore = plans);
}
}