Commit abbecafb authored by guillecxb's avatar guillecxb
Browse files

download json

parent 179ba1ef
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import {
  DialogContent,
  DialogActions
} from '@mui/material';
import DownloadIcon from '@mui/icons-material/Download';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import Ajv from 'ajv';

@@ -247,6 +248,23 @@ const ConfigCapif = () => {
    return words.join(" ");
  };

  const handleDownloadJson = () => {
    if (!editableConfig) {
      alert("There is no configuration available for download.");
      return;
    }
  
    const jsonString = JSON.stringify(editableConfig, null, 2);
    const blob = new Blob([jsonString], { type: "application/json" });
    const link = document.createElement("a");
    link.href = URL.createObjectURL(blob);
    link.download = "configuration.json";
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  };
  
  


  return (
@@ -254,10 +272,20 @@ const ConfigCapif = () => {
      {/* Cuadro principal con datos generales y secciones desplegables */}
      <Grid item xs={12}>
        <Card>
          <CardHeader title="General Configuration" />
          <CardHeader 
            title={
              <Box display="flex" justifyContent="space-between" alignItems="center">
                <Typography variant="h6">General Configuration</Typography>
                <Button variant="contained" color="secondary" startIcon={<DownloadIcon />} onClick={handleDownloadJson}>
                  Download JSON config
                </Button>
              </Box>
            } 
          />

          <CardContent>
            {/* General Configuration */}
            <Box display="flex" alignItems="center" mb={2}>
            <Box display="flex" alignItems="center" mb={2} mt={4}>
              <Typography variant="subtitle1" sx={{ flex: 1 }}>Configuration Name</Typography>
              <TextField 
                sx={{ width: '700px' }}