Unable to get access token using Spotify API

I am trying to implement Spotify API in my web site.

First I am redirecting user to:

>! const authEndpoint = "https://accounts.spotify.com/authorize";
>! const clientID= {my client id}         
>! const redirectUri = "http://localhost:3000/dashboard";
>! const scopes = ["user-library-read"];
>! 
>! export const loginEndpoint = `${authEndpoint}?          client_id=${clientID}&redirect_uri=${redirectUri}&scope=${scopes.join(
>!     '%20'
>! )}&response_type=code&code_challenge_method=S256&code_challenge=your-generated-code-challenge`;

and then extracting the code:

>! useEffect(() => {
>! const fetchToken = async () => {
>! const hash = window.location.hash;
>! const code = hash.split("=")[1];
>! 
>! if (code) {
>! const response = await getToken(code);
>! const accessToken = response.access_token;
>! 
>! setToken(accessToken);
>! setClientToken(accessToken);
>!         }
>!     };

and then passing code to the function to get token:

>! export const getToken = async (code) => {
>! const tokenEndpoint = 'https://accounts.spotify.com/api/token';
>! 
>! const response = await axios.post(
>! tokenEndpoint,
>! new URLSearchParams({
>! code: code,
>! redirect_uri: redirectUri,
>! grant_type: 'authorization_code'
>!         }),
>!         {
>! headers: {
>!             'Content-Type': 'application/x-www-form-urlencoded',
>!         },
>!       }
>!     );
>! console.log(response)
>! 
>! return response.data;
>! };

But I am not getting the token and it is giving axios error 400.

Can someone help me.

Trying to get access token from Spotify API but getting 400 error

Hide section on condition

I am building a flexdashboard in R shiny with several sections. Some sections should only be shown under certain conditions and stay hidden otherwise. In this example, I would like to hide the valuebox when its value is 0.

Expected result:

value = 0value > 0

And here is what I tried so far:

---
title: "Test"
output: 
  flexdashboard::flex_dashboard:
    vertical_layout: scroll
runtime: shiny
---

```{r setup, include=FALSE}
library(flexdashboard)

### Table

```{r}
data <- reactiveValues(df = NULL)
value <- reactiveValues(value = sample(c(0,1), 1))
renderTable({
  df <- data.frame(a = rnorm(5), b = rnorm(5))
  data$df <- df
})

### Valuebox {.value-box}

```{r, eval=T}
observe({
  if(value$value > 0){
    renderValueBox({
      valueBox(value$value)
    })
  }
})

### Plot

```{r}
renderPlot({
  plot(data$df$a, data$df$b)
})

Which yields the current result:

enter image description here

Any help or pointers are much appreciated!

Javascript need to output HEX instead of RGB (getImageData, drawImage)

Just to clarify im not very good at javascript and still learning.

I found this pieace of code on the internet, it takes an image and makes it to small span cells to get a pixelated image.
The code works perfect but the only problem I have is i want it to output as a HEX value instead of RGB

image of final output

<body>
    <canvas id="canvas" style="visibility: hidden;"></canvas>
    <div id="final-image" style="line-height: 7px;letter-spacing: -3px;"></div>
    <script>
        const canvas = document.getElementById("canvas");
        const ctx = canvas.getContext("2d");
        const imgUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/Radisson_SAS_Scandinavia_voldgrav.JPG/800px-Radisson_SAS_Scandinavia_voldgrav.JPG";
        const img = new Image();
        const imgWidth = 41;

        let html = "";
        img.crossOrigin = "Anonymous";
        img.onload = function() {
            canvas.width = imgWidth;
            canvas.height = (this.height * canvas.width) / this.width;
            ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
            for (let i = 0; i < canvas.height; i++) {
                for (let j = 0; j < canvas.width; j++) {
                    add(ctx.getImageData(j, i, 1, 1).data);
                }
                html += "<br />";
            }
            document.getElementById("final-image").innerHTML = html;
            canvas.parentNode.removeChild(canvas);
        };

        img.src = imgUrl;

        function add(c) {
            html += `<span style="color: rgb(${c[0]}, ${c[1]}, ${c[2]});">&#9632;</span>`;
        }
    </script>
</body>

I have bin looking for it for quite a while now and I must admit I cant fix the solution by myself.
I found this snippet that i though would help me but I could figure it out putting it together.

function componentToHex(c) {
  var hex = c.toString(16);
  return hex.length == 1 ? "0" + hex : hex;
}

function rgbToHex(r, g, b) {
  return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}

alert(rgbToHex(0, 51, 255)); // #0033ff

I’ve tried to figure out how to get return hex value instead of rgb but dont have the expertise to it

Microsoft SSO login is not working as intended in react app

I am trying to do a microsoft SSO login in my react application using dynamic credentials for SSO login of client id, tenant id. The problem is that it is not working. It will just open a popup page and when I click on the user account it will just simple redirect to redirect url in the same page instead of closing up and returning me the result.

This happens when I am getting same credentials from database but when i am using them hardcoded it is working perfectly as it needs to be.

I have checked the data which I get from database and it is working fine there so trying to resolve it but I have no idea why it is behaving in this way.

here is my code below

function LoginButton() {
  const { instance } = useMsal();

  const handleLogin = async() => {
    instance.loginPopup().then((response) => {
      console.log(response);
    }).catch((error) => {
      console.log(error);
    });
  }

  return <button type="button" onClick={handleLogin} className="btn btn-primary">Login</button>;
}

function App() {
  const [msalConfig, setMsalConfig] = useState<Configuration | null>(null);
  const [isLoading, setIsLoading] = useState(true);
  
  useEffect(() => {
    const MFTLogin = async () => {
      const subdomain = window.location.hostname.split('.')[0];
      const storedConfig = localStorage.getItem('msalConfig');

      if (storedConfig) {
        setMsalConfig(JSON.parse(storedConfig));
        setIsLoading(false);
      } else if (subdomain) {
        // Fetch and set MSAL configuration
        const request = await axios.get(`http://localhost:5000/outlook/organization/${subdomain}`);
        if (request && request.data) {
          const data: Configuration = {
            auth: {
              clientId: request.data.data.outlook_client_id_mfo,
              authority: `https://login.microsoftonline.com/${request.data.data.outlook_tenant_id_mfo}`,
              redirectUri: "http://localhost:3000",
            }
          };
          localStorage.setItem('msalConfig', JSON.stringify(data));
          setMsalConfig(data);
        }
        setIsLoading(false);
      }
    };

    MFTLogin();
  }, []);

  if (isLoading) {
    return <div>Loading...</div>;
  }

  if (!msalConfig) {
    return <div>Configuration Error</div>;
  }

  const msalInstance = new PublicClientApplication(msalConfig);

  return (
    <MsalProvider instance={msalInstance}>
      <div className="App">
        <LoginButton />
      </div>
    </MsalProvider>
  );
}

export default App;

Static chunks are not generated in bulid mode in Vite

I faced up with problem in which static files are not generated in build mode. I use Vite and I configured configuration file in a correct way, importing in my html also correct. In a dev mode esbuild builds successfully but in a production mode rollup does not build. It generate only html file without any js, css chunks. I attached the images that can display folder structure, Vite configuration file and html file.[[Screens of files](https://i.stack.imgur.com/VhqIL.png)](https://i.stack.imgur.com/b6y3T.png)

I tried to configure Vite rollupOptions property and printed the argument of manualChunks method and it printed only html file. I tried to delete the last changes in my code to make sure that last changes does not affect for building process. But it did not solve the problem. Because before last changes in my code it built all static js and css chunksAfter building

Using SignalR and SqlDependency with Asp.Net Core 8.0 N-Tier Architecture

I am developing an Asp.Net Core 8.0 API project.

There are 5 layers in my project,

  • EntityLayer (Class Library)
  • DataAccessLayer(Class Library)
  • Business Layer (Class Library)
  • DtosLayer(Class Library)
  • ApiLayer (Core 8.0 API)
  • UI Layer (Core 8.0 MVC)

I want to receive data simultaneously using SignalR and SqlDependency in my project.

In my project, I want to keep interfaces and repositories in the DataAccessLayer layer.
My Hub class must be in the Api layer.
And in the MVC layer, I need to consume the API and display the values in the view.

I have seen many examples of this, but I could not adapt it to N-Tier Architecture. Everyone who explained it only performed the operations in the UI part.

An example link:

https://learn.microsoft.com/en-us/answers/questions/1159844/implementing-signalr-in-asp-net-core-web-app-(mvc)

My first question is, can I use it with entity framework or dapper ORM?

Secondly, how can I use it in N-Tier Architecture?

Thank for your support.
Thanks.

Unable to duplicate slideshow on the same HTML page

I need assistance in creating multiple slideshows, precisely three, from the following slideshow type:

Slideshow Link:
https://codepen.io/bcarvalho/pen/WXmwBq

I’ve successfully integrated this specific slideshow into my web application, and it functions properly as an individual slideshow. However, when attempting to duplicate it for multiple instances, I encounter issues. Despite changing the slideshow ID and adjusting the corresponding JavaScript code, I haven’t been able to achieve success (Coudn’t identify what is the missing point).

I attempted to replicate the code and the slideshow div, but it didn’t function correctly.

Any help or guidance on resolving this issue would be greatly appreciated. Thank you!

HTML

<div id="wrapper">
  <section class="slideshow" id="js-header">
    
    <div class="slideshow__slide js-slider-home-slide is-current" data-slide="1">
        <div class="slideshow__slide-background-parallax background-absolute js-parallax" data-speed="-1" data-position="top" data-target="#js-header">
            <div class="slideshow__slide-background-load-wrap background-absolute">
                <div class="slideshow__slide-background-load background-absolute">
                    <div class="slideshow__slide-background-wrap background-absolute">
                        <div class="slideshow__slide-background background-absolute">
                            <div class="slideshow__slide-image-wrap background-absolute">
                                <div class="slideshow__slide-image background-absolute" style="background-image: url('https://images.pexels.com/photos/190537/pexels-photo-190537.jpeg?auto=compress&cs=tinysrgb&h=1080&w=1920');"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="slideshow__slide-caption">
            <div class="slideshow__slide-caption-text">
                <div class="container js-parallax" data-speed="2" data-position="top" data-target="#js-header">
                    <h1 class="slideshow__slide-caption-title">Everything broken can be repaired</h1>
                    <a class="slideshow__slide-caption-subtitle -load o-hsub -link" href="#">
                        <span class="slideshow__slide-caption-subtitle-label">See how</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
    
    <div class="slideshow__slide js-slider-home-slide is-next" data-slide="2">
        <div class="slideshow__slide-background-parallax background-absolute js-parallax" data-speed="-1" data-position="top" data-target="#js-header">
            <div class="slideshow__slide-background-load-wrap background-absolute">
                <div class="slideshow__slide-background-load background-absolute">
                    <div class="slideshow__slide-background-wrap background-absolute">
                        <div class="slideshow__slide-background background-absolute">
                            <div class="slideshow__slide-image-wrap background-absolute">
                                <div class="slideshow__slide-image background-absolute" style="background-image: url('https://images.pexels.com/photos/110649/pexels-photo-110649.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=1080&w=1920');"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="slideshow__slide-caption">
            <div class="slideshow__slide-caption-text">
                <div class="container js-parallax" data-speed="2" data-position="top" data-target="#js-header">
                    <h1 class="slideshow__slide-caption-title">See through the field</h1>
                    <a class="slideshow__slide-caption-subtitle -load o-hsub -link" href="#">
                        <span class="slideshow__slide-caption-subtitle-label">Learn more about</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
    
    <div class="slideshow__slide js-slider-home-slide is-prev" data-slide="3">
        <div class="slideshow__slide-background-parallax background-absolute js-parallax" data-speed="-1" data-position="top" data-target="#js-header">
            <div class="slideshow__slide-background-load-wrap background-absolute">
                <div class="slideshow__slide-background-load background-absolute">
                    <div class="slideshow__slide-background-wrap background-absolute">
                        <div class="slideshow__slide-background background-absolute">
                            <div class="slideshow__slide-image-wrap background-absolute">
                                <div class="slideshow__slide-image background-absolute" style="background-image: url('https://images.pexels.com/photos/196666/pexels-photo-196666.jpeg?auto=compress&cs=tinysrgb&h=1080&w=1920');"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="slideshow__slide-caption">
            <div class="slideshow__slide-caption-text">
                <div class="container js-parallax" data-speed="2" data-position="top" data-target="#js-header">
                    <h1 class="slideshow__slide-caption-title">Hey, take a time to relax!</h1>
                    <a class="slideshow__slide-caption-subtitle -load o-hsub -link" href="#">
                        <span class="slideshow__slide-caption-subtitle-label">Everybody needs</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
    
    <div class="c-header-home_footer">
        <div class="o-container">
            <div class="c-header-home_controls -nomobile o-button-group">
                <div class="js-parallax is-inview" data-speed="1" data-position="top" data-target="#js-header">
                    <button class="o-button -white -square -left js-slider-home-button js-slider-home-prev" type="button">
                        <span class="o-button_label">
                            <svg class="o-button_icon" role="img"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#arrow-prev"></use></svg>
                        </span>
                    </button>
                    <button class="o-button -white -square js-slider-home-button js-slider-home-next" type="button">
                        <span class="o-button_label">
                            <svg class="o-button_icon" role="img"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#arrow-next"></use></svg>
                        </span>
                    </button>
                </div>
            </div>
        </div>
    </div>
   
    
  </section>
<div>
  
<svg xmlns="http://www.w3.org/2000/svg">
    <symbol viewBox="0 0 18 18" id="arrow-next">
        <path id="arrow-next-arrow.svg" d="M12.6,9L4,17.3L4.7,18l8.5-8.3l0,0L14,9l0,0l-0.7-0.7l0,0L4.7,0L4,0.7L12.6,9z"/>
    </symbol>
    <symbol viewBox="0 0 18 18" id="arrow-prev">
        <path id="arrow-prev-arrow.svg" d="M14,0.7L13.3,0L4.7,8.3l0,0L4,9l0,0l0.7,0.7l0,0l8.5,8.3l0.7-0.7L5.4,9L14,0.7z"/>
    </symbol>
</svg>

JavaScript

const $window = $(window);
const $body = $('body');

class Slideshow {
    constructor (userOptions = {}) {
    const defaultOptions = {
      $el: $('.slideshow'),
      showArrows: false,
      showPagination: true,
      duration: 10000,
      autoplay: true
    }
    
    let options = Object.assign({}, defaultOptions, userOptions);
    
        this.$el = options.$el;
        this.maxSlide = this.$el.find($('.js-slider-home-slide')).length;
    this.showArrows = this.maxSlide > 1 ? options.showArrows : false;
    this.showPagination = options.showPagination;
        this.currentSlide = 1;
        this.isAnimating = false;
        this.animationDuration = 1200;
        this.autoplaySpeed = options.duration;
        this.interval;
        this.$controls = this.$el.find('.js-slider-home-button');
    this.autoplay = this.maxSlide > 1 ? options.autoplay : false;

        this.$el.on('click', '.js-slider-home-next', (event) => this.nextSlide());
        this.$el.on('click', '.js-slider-home-prev', (event) => this.prevSlide());
    this.$el.on('click', '.js-pagination-item', event => {
      if (!this.isAnimating) {
        this.preventClick();
  this.goToSlide(event.target.dataset.slide);
      }
    });

        this.init();
    }
  
  init() {
    this.goToSlide(1);
    if (this.autoplay) {
      this.startAutoplay();
    }
    
    if (this.showPagination) {
      let paginationNumber = this.maxSlide;
      let pagination = '<div class="pagination"><div class="container">';
      
      for (let i = 0; i < this.maxSlide; i++) {
        let item = `<span class="pagination__item js-pagination-item ${ i === 0 ? 'is-current' : ''}" data-slide=${i + 1}>${i + 1}</span>`;
        pagination  = pagination + item;
      }
      
      pagination = pagination + '</div></div>';
      
      this.$el.append(pagination);
    }
  }
  
  preventClick() {
        this.isAnimating = true;
        this.$controls.prop('disabled', true);
        clearInterval(this.interval);

        setTimeout(() => {
            this.isAnimating = false;
            this.$controls.prop('disabled', false);
      if (this.autoplay) {
              this.startAutoplay();
      }
        }, this.animationDuration);
    }

    goToSlide(index) {    
    this.currentSlide = parseInt(index);
    
    if (this.currentSlide > this.maxSlide) {
      this.currentSlide = 1;
    }
    
    if (this.currentSlide === 0) {
      this.currentSlide = this.maxSlide;
    }
    
    const newCurrent = this.$el.find('.js-slider-home-slide[data-slide="'+ this.currentSlide +'"]');
    const newPrev = this.currentSlide === 1 ? this.$el.find('.js-slider-home-slide').last() : newCurrent.prev('.js-slider-home-slide');
    const newNext = this.currentSlide === this.maxSlide ? this.$el.find('.js-slider-home-slide').first() : newCurrent.next('.js-slider-home-slide');
    
    this.$el.find('.js-slider-home-slide').removeClass('is-prev is-next is-current');
    this.$el.find('.js-pagination-item').removeClass('is-current');
    
        if (this.maxSlide > 1) {
      newPrev.addClass('is-prev');
      newNext.addClass('is-next');
    }
    
    newCurrent.addClass('is-current');
    this.$el.find('.js-pagination-item[data-slide="'+this.currentSlide+'"]').addClass('is-current');
  }
  
  nextSlide() {
    this.preventClick();
    this.goToSlide(this.currentSlide + 1);
    }
   
    prevSlide() {
    this.preventClick();
    this.goToSlide(this.currentSlide - 1);
    }

    startAutoplay() {
        this.interval = setInterval(() => {
            if (!this.isAnimating) {
                this.nextSlide();
            }
        }, this.autoplaySpeed);
    }

    destroy() {
        this.$el.off();
    }
}

(function() {
    let loaded = false;
    let maxLoad = 3000;  
  
    function load() {
        const options = {
      showPagination: true
    };

    let slideShow = new Slideshow(options);
    }
  
    function addLoadClass() {
        $body.addClass('is-loaded');

        setTimeout(function() {
            $body.addClass('is-animated');
        }, 600);
    }
  
    $window.on('load', function() {
        if(!loaded) {
            loaded = true;
            load();
        }
    });
  
    setTimeout(function() {
        if(!loaded) {
            loaded = true;
            load();
        }
    }, maxLoad);

    addLoadClass();
})();

Uploading excel file and then transforming to add to database

After some guidance on ways to hopefully help automate a very manual process. At the moment we receive excel “brief” files from 90% of our client’s. These excel files vary in layout and content but all of them have the same 10 – 20 fields, albeit in a different column/row.

I want to be able to allow the client to upload a spreadsheet and then for it to be converted and put into a standard format, then once converted add it to a database.

Breaking this down i think there are a few areas to review

  • Website building software for the front end, feature to upload the spreadsheet and then return the database results. we currently use a no code builder, is there any third party software that can do the step below and then return the data.

  • Code/program to allow us to script in the “default” layouts per client, mapping the excel fields and then turning this into the standard formats. For ease of use if there is a third party integration that can be used and then send the data back to the website, something like exceljs.

At this stage i am just scoping for proof of concept so i can research the options and then get a rough budget for a developer to write the required bits.

We have used excel vba in the past to take the spreadsheet and convert it into a standard format, however we now need to move to an online portal and an online data structure.

Not sure if there is any way to potentially let the client upload a spreadsheet and for it to then still be done in excel vba and uploaded to the website, (power automate).

Adress SVG Tags with special tag names with jquery [duplicate]

I use a great software “Curve”, formerly “Vectornator” to create SVG images. Within the images, the elements are named:

vectornator:layerName="TRoom"

However, I can not a address this element using:

$("svg path[vectornator:layername='TRoom']")

I tried

$("svg path[vectornator:layername='TRoom']")
$("svg path[:vectornator:layername='TRoom']")

none of them worked. Only solution so far is to strip the “vectornator:” part prior to uploading the file, but it adds other problems.

So what could be a way to address elements preserving namespace attributes?

Why is the transition not working when I am adding the element?

I am creating an element each time when the function is called, but the transition is not always working. I wanted a message coming from the top of the screen but it is adding the element instantly without applying the transition.

JavaScript:

let bottomCount = 160
let d3IdCount = 3
let svgIdCount = 4
let messagesCount = 1
let d3ST1 = null
let d3ST2 = null
let d3ST3 = null
let d3AlreadyExists = false

async function errorMessageUI(message){

    const d3 = document.createElement("div")
    
    d3.classList.add("d3")
    d3.id = "d3"
    
    const d3Exists = document.querySelector(".d3")

if(d3Exists){

      messagesCount++
      bottomCount += 60
      d3IdCount += 1
      svgIdCount += 1
      d3AlreadyExists = true
}

else if(!d3Exists){
  messagesCount = 1
  bottomCount = 160
  d3IdCount = 3
  svgIdCount = 4
  d3AlreadyExists = false
}

  d3.id = `${d3IdCount}`

  d1.append(d3)
    
    d3.style.left = d3AlreadyExists? "-10%": "0%"

    d3.innerHTML = `${message} <p class="p3" id="p3">  ${messagesCount > 1? "x" : ''}${messagesCount > 1? messagesCount : ''} </p> <svg style="opacity: 60%" class="svg4" id="svg${svgIdCount}" width="8%" height="54%" viewBox="0 0 16 16"><path class="path4" id="path4" d="m4.12 6.137 1.521-1.52 7 7-1.52 1.52z"/><path class="path4" id="path4" d="m4.12 11.61 7.001-7 1.52 1.52-7 7z"/></svg>`

    d3ST1 = setTimeout(() => {
      d3.style.transform = `translateY(${bottomCount}%)`
    }, 0)
    
d3ST2 = setTimeout(() => {


d3.style.transform = "translateY(-300%)"
clearTimeout(d3ST1)
clearTimeout(d3ST2)

5000)

setTimeout(() => {
d3.remove()
5201)

    const crossSVG = document.getElementById(`svg${svgIdCount}`)

    d3.addEventListener("mouseover", () => {

      crossSVG.style.opacity = "100%"

    })

    d3.addEventListener("mouseout", () => {
      
      crossSVG.style.opacity = "60%"

    })

    crossSVG.addEventListener('click', () =>{

      clearTimeout(d3ST1)
      clearTimeout(d3ST2)

      setTimeout(() => {
        d3.remove()
      }, 201)

      d3.style.transform = "translateY(-300%)"

    })
  }

CSS:

.d3{

  position: absolute;
    font-family: sans-serif;
    transform: translateY(-300%);
    transition: transform 200ms ease-in-out !important;
    display: flex;
    background: rgba(239, 87, 87, 0.83);
    width: 78%;
    min-height: 10%;
    text-align: center;
    border-radius: 5px;
    border-left: 4px solid #af0e0edb;
    color: #990e0e;
    font-size: 1.07rem;
    justify-content: center;
    align-items: center;

}

I excepted that the transition will work always when an element is added, but the transition is not always working.

Angular PUT Request Issue – “Required request body is missing”

I am facing an issue with an Angular application where I am trying to send a PUT request to my server, but I’m getting the error message “Required request body is missing.” Below is the relevant code snippet:
**Child Component (ChambreFormComponent):

** <div class="h-screen md:flex">
  <div
    class="relative overflow-hidden md:flex w-1/2 bg-gradient-to-tr from-blue-800 to-purple-700 i justify-around items-center hidden"
  >
    >
    <img class="h-40 w-96 mr-40" src="{{ image }}" />
    <div
      class="absolute -bottom-32 -left-40 w-80 h-80 border-4 rounded-full border-opacity-30 border-t-8"
    ></div>
    <div
      class="absolute -bottom-40 -left-20 w-80 h-80 border-4 rounded-full border-opacity-30 border-t-8"
    ></div>
    <div
      class="absolute -top-40 -right-0 w-80 h-80 border-4 rounded-full border-opacity-30 border-t-8"
    ></div>
    <div
      class="absolute -top-20 -right-20 w-80 h-80 border-4 rounded-full border-opacity-30 border-t-8"
    ></div>
  </div>
  <div class="flex md:w-1/2 justify-center py-10 items-center bg-white">
    <form class="bg-white" (ngSubmit)="onSubmit()">
      <h1 class="text-black font-bold text-2xl mb-1">{{ titre }}</h1>
      <!-- <p class="text-sm font-normal text-gray-600 mb-7">Welcome Back</p> -->
      <div class="flex items-center border-2 py-2 px-3 rounded-2xl mb-4">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          class="h-5 w-5 text-gray-400"
          viewBox="0 0 20 20"
          fill="currentColor"
        >
          <path
            fill-rule="evenodd"
            d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z"
            clip-rule="evenodd"
          />
        </svg>
        <input
          class="pl-2 outline-none border-none"
          type="text"
          name=""
          id=""
          [(ngModel)]="formData.numeroChambre"
          placeholder="{{ roomnumber }}"
          [ngModelOptions]="{ standalone: true }"
        />
      </div>
      <div class="flex items-center border-2 py-2 px-3 rounded-2xl mb-4">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          class="h-5 w-5 text-gray-400"
          fill="none"
          viewBox="0 0 24 24"
          stroke="currentColor"
        >
          <path
            stroke-linecap="round"
            stroke-linejoin="round"
            stroke-width="2"
            d="M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"
          />
        </svg>
        <input
          class="pl-2 outline-none border-none"
          type="text"
          name=""
          id=""
          [(ngModel)]="formData.typeC"
          placeholder="{{ typeRoom }}"
          [ngModelOptions]="{ standalone: true }"
        />
      </div>

      <button
        type="submit"
        class="block w-full bg-indigo-600 mt-4 py-2 rounded-2xl text-white font-semibold mb-2"
      >
        {{buttonText}}
      </button>
    </form>
  </div>
</div>

.ts

` import {
  Component,
  EventEmitter,
  Input,
  Output,
  ViewChild,
} from '@angular/core';
import { ChambreFormUpdateComponent } from '../chambre-form-update/chambre-form-update.component';

@Component({
  selector: 'app-chambre-form',
  templateUrl: './chambre-form.component.html',
  styleUrls: ['./chambre-form.component.css'],
})
export class ChambreFormComponent {
  @Input() image = '';
  @Input() buttonText = '';

  @Input() titre = '';
  @Input() roomnumber = 0;
  @Input() typeRoom = '';
  @Input() formData: any;
  @Output() submitForm = new EventEmitter<any>();

  constructor() {
    console.log('Chambre Form Update titre' + this.titre);
  }

  onSubmit() {
    // Emit the form data when the form is submitted
    this.submitForm.emit();
  }
}`

**Parent Component (ChambreFormUpdateComponent):

`**   <app-chambre-form
  [image]="image"
  [titre]="title"
  [buttonText]="buttonText"
  [typeRoom]="type"
  [roomnumber]="roomNum"
  [formData]="updateForm.value"
  (submitForm)="updateRoom(updateForm.value.idChambre, $event)"
></app-chambre-form>`

**.ts : **

`import { Component, ViewChild } from '@angular/core';
import { ChambreFormComponent } from '../chambre-form/chambre-form.component';
import { environment } from 'src/environments/environment.development';
import { HttpClient } from '@angular/common/http';
import { FormBuilder } from '@angular/forms';
import { Router } from '@angular/router';

@Component({
  selector: 'app-chambre-form-update',
  templateUrl: './chambre-form-update.component.html',
  styleUrls: ['./chambre-form-update.component.css'],
})
export class ChambreFormUpdateComponent {
  rooms: any[] = [];
  image = './assets/chambres/updateRoom.png';
  title = 'Update Room';
  buttonText = 'Update Room';
  constructor(
    private http: HttpClient,
    private fb: FormBuilder,
    private router: Router
  ) {
    console.log('valueeeee' + this.updateForm.value);
  }
  updateForm: any = {
    value: {
      numeroChambre: 0,
      typeC: '',
    },
  };
  type = this.updateForm.value.type;
  roomNum = this.updateForm.value.numero;

  updateRoom(roomId: number, updatedRoom: any) {
    const apiUrl = environment.BaseUrl + 'chambre/modifierchambre';
    this.http.put<any>(apiUrl, updatedRoom).subscribe({
      next: (data) => {
        console.log('Room updated successfully:', data);

        const index = this.rooms.findIndex((room) => room.idChambre === roomId);
        if (index !== -1) {
          this.rooms[index] = data;
        }
      },
    });
  }

  openUpdateForm(room: any) {
    room.showUpdateForm = true;
    this.updateForm.value = { ...room };
  }
}`

When making the PUT request, I receive a “Required request body is missing” error. I suspect the issue may be related to how I am handling the form data or constructing the request body.

**Can someone please help me identify what might be causing this issue? How should I properly construct and send the request body in my Angular application?

Any guidance or suggestions would be greatly appreciated. Thank you!**

IOS WebClip WebApp How to keep fullscreen?

I packaged my website into a WebClip App, but I found that only the homepage can be full screen. Once I use to jump to other pages (still this site), Safari will have toolbars and Url, and full screen will be Invalid.
This string of code has Add
<meta name="apple-mobile-web-app-capable" content="yes" />
Where is the problem? Is there any way besides using iframe?

Hopefully this provides all of the necessary information needed to understand the problem

How to set 2 fixed decimal places for number in Vue 2

I am using v-model.number to bind data properties, here is the snippet

new Vue({
  el: "#app",
  data: {
    entries: [{
        text: "Rate 1",
        rate: 1.7
      },
      {
        text: "Rate 2",
        rate: 2.00
      },
      {
        text: "Rate 3",
        rate: 3.50
      }
    ]
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.10/vue.js"></script>
<div id="app">
  <div v-for="(entry,index) in entries">
    <h2>{{ entry.text }}</h2>
    <input type="number" step="0.01" class="form-control" v-model.number="entry.rate">
  </div>
</div>

I am stuck at setting decimal values with 2 fixed decimals e.g. 3.5 as 3.50 and 2 as 2.00