package me.koba1.led.controller;

import me.koba1.led.Main;
import me.koba1.led.animations.BaseAnimation;
import me.koba1.led.animations.ColoredAnimation;
import me.koba1.led.managers.LedStripManager;
import me.koba1.led.model.LedStrip;
import me.koba1.led.model.colors.AnimationColor;
import me.koba1.led.model.colors.KobaGradient;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/ledstrips")
public class LedStripController {
    @GetMapping
    public List<LedStrip> getAll() {
        System.out.println("Kimenő ledstiprke: " + Main.getInstance().getLedStripManager().getLedStrips().values());
        return new ArrayList<>(Main.getInstance().getLedStripManager().getLedStrips().values());
    }

    @PostMapping("/update")
    public List<LedStrip> update(@RequestBody List<LedStrip> strips) throws IOException {
        // return Main.getInstance().getLedStripManager().update(strips);
//        System.out.println("Bejött strippek: " + strips);
        return Main.getInstance().getLedStripManager().update(strips);
    }

    @GetMapping("/new")
    public LedStrip createNew(@RequestParam String name) {
        return Main.getInstance().getLedStripManager().createNew(name);
    }
}
