package id.co.gtc.erhacam;

import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;

import static Config.SomeCodes.ValidString;

public class UploadProgress {
    @FXML
    private Label labelfile;

    @FXML
    private Label labelstatus;

    @FXML
    private ProgressBar progressbar;

    @FXML
    public void initialize(){


    }

    /**
     * Set the filename to be displayed
     * @param filename the filename to be displayed
     */
    public void SetFile(String filename){
        if (ValidString(filename)){
            labelfile.setText(filename);
        }
    }

    /**
     * Set the status to be displayed
     * @param status the status to be displayed
     */
    public void SetStatus(String status){
        if (ValidString(status)){
            labelstatus.setText(status);
        }
    }

    /**
     * Set the progress of the upload
     * @param current the current progress in Bytes
     * @param total the total progress in Bytes
     */
    public void SetProgress(long current, long total){
        if (total > 0){
            progressbar.setProgress((double)current / (double)total);
        }
    }

}
