Merge pull request #5 from wulkanowy/feature/deleted_messages
Add deleted and sent messages to UI
This commit is contained in:
commit
25af24a917
2 changed files with 80 additions and 13 deletions
|
@ -18,6 +18,7 @@ const getGrades = () => {
|
|||
}).then(response => response.json()).then(data => {
|
||||
const allGrades = data.data.Oceny
|
||||
const content = document.getElementById("content")
|
||||
content.innerHTML = ""
|
||||
const container = document.getElementsByClassName("gradeModals")[0]
|
||||
|
||||
allGrades.forEach((grade) => {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const received_ = document.querySelector('#received_');
|
||||
const sent_ = document.querySelector('#sent_');
|
||||
const deleted_ = document.querySelector('#deleted_');
|
||||
const content = document.getElementById("content")
|
||||
|
||||
const getReceivedMessages = () => {
|
||||
content.innerHTML = ""
|
||||
cookies_data = sessionStorage.getItem('cookies_data');
|
||||
csrfcookie_ = sessionStorage.getItem('csrfcookie');
|
||||
fetch(url = '../api/messages/received', {
|
||||
|
@ -14,9 +16,7 @@ const getReceivedMessages = () => {
|
|||
},
|
||||
body: cookies_data
|
||||
}).then(response => response.json()).then(data => {
|
||||
content = document.getElementById("content")
|
||||
console.log(data)
|
||||
wiadomosci = data.data
|
||||
const wiadomosci = data.data
|
||||
|
||||
table = document.createElement("table")
|
||||
table.className = "striped"
|
||||
|
@ -36,28 +36,26 @@ const getReceivedMessages = () => {
|
|||
wiadomosci.forEach((wiadomosc) => {
|
||||
const tbody = document.getElementsByTagName("tbody")[0]
|
||||
|
||||
console.log(tbody)
|
||||
|
||||
wiadomoscRow = tbody.insertRow()
|
||||
|
||||
temat = wiadomoscRow.insertCell()
|
||||
temat.innerText = wiadomosc.Temat
|
||||
temat.innerHTML = `<span id="${wiadomosc.Id}">${wiadomosc.Temat}</span>`
|
||||
wiadomoscRow.appendChild(temat)
|
||||
|
||||
nadawca = wiadomoscRow.insertCell()
|
||||
nadawca.innerText = wiadomosc.Nadawca.Name
|
||||
nadawca.innerHTML = `<span>${wiadomosc.Nadawca.Name}</span>`
|
||||
wiadomoscRow.appendChild(nadawca)
|
||||
|
||||
|
||||
dataWyslania = wiadomoscRow.insertCell()
|
||||
dataWyslania.innerText = wiadomosc.Data
|
||||
dataWyslania.innerHTML = `<span>${wiadomosc.Data}</span>`
|
||||
wiadomoscRow.appendChild(dataWyslania)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const getSentMessages = () => {
|
||||
document.querySelector('#content').innerHTML = 'Here is sent messages (in my imagination)';
|
||||
content.innerHTML = ""
|
||||
cookies_data = sessionStorage.getItem('cookies_data');
|
||||
csrfcookie_ = sessionStorage.getItem('csrfcookie');
|
||||
fetch(url = '../api/messages/sent', {
|
||||
|
@ -69,12 +67,46 @@ const getSentMessages = () => {
|
|||
},
|
||||
body: cookies_data
|
||||
}).then(response => response.json()).then(data => {
|
||||
console.log(data);
|
||||
const wiadomosci = data.data // haha spaghetti code goes brrr
|
||||
|
||||
table = document.createElement("table")
|
||||
table.className = "striped"
|
||||
table.innerHTML = "<thead>\n" +
|
||||
" <tr>\n" +
|
||||
" <th>Temat</th>\n" +
|
||||
" <th>Adresat</th>\n" +
|
||||
" <th>Data</th>\n" +
|
||||
" </tr>\n" +
|
||||
" </thead>" +
|
||||
" <tbody>" +
|
||||
" " +
|
||||
" </tbody>"
|
||||
|
||||
content.append(table)
|
||||
|
||||
wiadomosci.forEach((wiadomosc) => {
|
||||
const tbody = document.getElementsByTagName("tbody")[0]
|
||||
|
||||
wiadomoscRow = tbody.insertRow()
|
||||
|
||||
temat = wiadomoscRow.insertCell()
|
||||
temat.innerHTML = `<span id="${wiadomosc.Id}">${wiadomosc.Temat}</span>`
|
||||
wiadomoscRow.appendChild(temat)
|
||||
|
||||
nadawca = wiadomoscRow.insertCell()
|
||||
nadawca.innerHTML = `<span>${wiadomosc.Adresaci[0]}</span>`
|
||||
wiadomoscRow.appendChild(nadawca)
|
||||
|
||||
|
||||
dataWyslania = wiadomoscRow.insertCell()
|
||||
dataWyslania.innerHTML = `<span>${wiadomosc.Data}</span>`
|
||||
wiadomoscRow.appendChild(dataWyslania)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const getDeletedMessages = () => {
|
||||
document.querySelector('#content').innerHTML = 'Here is deleted messages (in my imagination)';
|
||||
content.innerHTML = ""
|
||||
cookies_data = sessionStorage.getItem('cookies_data');
|
||||
csrfcookie_ = sessionStorage.getItem('csrfcookie');
|
||||
fetch(url = '../api/messages/deleted', {
|
||||
|
@ -86,7 +118,41 @@ const getDeletedMessages = () => {
|
|||
},
|
||||
body: cookies_data
|
||||
}).then(response => response.json()).then(data => {
|
||||
console.log(data);
|
||||
const wiadomosci = data.data
|
||||
|
||||
table = document.createElement("table")
|
||||
table.className = "striped"
|
||||
table.innerHTML = "<thead>\n" +
|
||||
" <tr>\n" +
|
||||
" <th>Temat</th>\n" +
|
||||
" <th>Nadawca</th>\n" +
|
||||
" <th>Data</th>\n" +
|
||||
" </tr>\n" +
|
||||
" </thead>" +
|
||||
" <tbody>" +
|
||||
" " +
|
||||
" </tbody>"
|
||||
|
||||
content.append(table)
|
||||
|
||||
wiadomosci.forEach((wiadomosc) => {
|
||||
const tbody = document.getElementsByTagName("tbody")[0]
|
||||
|
||||
wiadomoscRow = tbody.insertRow()
|
||||
|
||||
temat = wiadomoscRow.insertCell()
|
||||
temat.innerHTML = `<span id="${wiadomosc.Id}">${wiadomosc.Temat}</span>`
|
||||
wiadomoscRow.appendChild(temat)
|
||||
|
||||
nadawca = wiadomoscRow.insertCell()
|
||||
nadawca.innerHTML = `<span>${wiadomosc.Nadawca.Name}</span>`
|
||||
wiadomoscRow.appendChild(nadawca)
|
||||
|
||||
|
||||
dataWyslania = wiadomoscRow.insertCell()
|
||||
dataWyslania.innerHTML = `<span>${wiadomosc.Data}</span>`
|
||||
wiadomoscRow.appendChild(dataWyslania)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue