-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from MatsMoll/develop
[Feide.User] Added Feide login and other small improvements
- Loading branch information
Showing
8 changed files
with
93 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5.3 | ||
5.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
function deleteSubject() { | ||
function deleteSubject(subjectID) { | ||
|
||
var xhr = new XMLHttpRequest(); | ||
var url = "/api" + window.location.pathname.replace("creator/", ""); | ||
console.log(url); | ||
var url = "/api/subjects/" + subjectID | ||
xhr.open("DELETE", url, true); | ||
xhr.onreadystatechange = function () { | ||
if (this.readyState != 4) return; | ||
|
||
if (this.status == 200) { | ||
window.location.href = "../subjects"; | ||
window.location.href = "/subjects"; | ||
} | ||
}; | ||
|
||
xhr.send(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,31 @@ | ||
$("#edit-subject-description").summernote({ | ||
minHeight : 100, | ||
toolbar: [ | ||
// [groupName, [list of button]] | ||
['style', ['bold', 'italic', 'underline']], | ||
['font', ['strikethrough', 'superscript', 'subscript']], | ||
['para', ['ul', 'ol', 'paragraph']], | ||
['insert', ['link', 'hr']], | ||
['misc', ['undo', 'redo', 'help']] | ||
] | ||
}); | ||
|
||
|
||
function editSubject() { | ||
function editSubject(subjectID) { | ||
|
||
var xhr = new XMLHttpRequest(); | ||
var url = "/api" + window.location.pathname.replace("creator/", ""); | ||
xhr.open("PUT", url, true); | ||
xhr.setRequestHeader("Content-Type", "application/json"); | ||
xhr.onreadystatechange = function () { | ||
if (this.readyState != 4) return; | ||
|
||
if (this.status == 200) { | ||
window.location.reload(); | ||
let url = "/api/subjects/" + subjectID | ||
fetch(url, { | ||
method: "PUT", | ||
headers: { | ||
"Accept": "application/json, text/plain, */*", | ||
"Content-Type" : "application/json" | ||
}, | ||
body: createSubjectData() | ||
}) | ||
.then(function (response) { | ||
if (response.ok) { | ||
window.location.reload() | ||
} else if (response.status == 400) { | ||
throw new Error("Sjekk at all nødvendig info er fylt ut"); | ||
} else { | ||
throw new Error(response.statusText); | ||
} | ||
}) | ||
.catch(function (error) { | ||
$("#submitButton").attr("disabled", false); | ||
$("#error-massage").text(error.message); | ||
if ($("#error-div").css("display") == "block") { | ||
$("#error-div").shake(); | ||
} else { | ||
$("#error-div").fadeIn(); | ||
$("#error-div").removeClass("d-none"); | ||
} | ||
}; | ||
|
||
var name = $("#edit-subject-name").val(); | ||
var description = null; | ||
if (!$('#edit-subject-description').summernote("isEmpty")) { | ||
description = $("#edit-subject-description").summernote("code"); | ||
} | ||
var category = $("#create-subject-category").val(); | ||
var colorClass = $("#create-subject-color-class").val(); | ||
|
||
var data = JSON.stringify({ | ||
"name": name, | ||
"colorClass": colorClass, | ||
"description": description, | ||
"category": category, | ||
}); | ||
xhr.send(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function createSubjectData() { | ||
|
||
let name = $("#subject-name").val(); | ||
let description = subjectdescription.value(); | ||
if (description.lenght < 1) { | ||
description = null; | ||
} | ||
let category = $("#subject-category").val(); | ||
let colorClass = $('input[name=color-class]:checked').attr('id'); | ||
let code = $("#subject-code").val(); | ||
|
||
return JSON.stringify({ | ||
"name": name, | ||
"colorClass": colorClass, | ||
"description": description, | ||
"category": category, | ||
"code": code | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
function markPotensialSubjects() { | ||
|
||
let url = "/api/subjects/mark-potensial" | ||
|
||
let responses = Array.from(document.querySelectorAll(".rel-switch")).map(node => { | ||
return { | ||
id: parseInt(node.querySelector("input").getAttribute("id")), | ||
isActive: node.querySelector("input").checked | ||
} | ||
}) | ||
let data = JSON.stringify(responses) | ||
fetch(url, { | ||
method: "POST", | ||
headers: { | ||
"Accept": "application/json, text/plain, */*", | ||
"Content-Type" : "application/json" | ||
}, | ||
body: data | ||
}) | ||
.then(function (response) { | ||
if (response.ok) { | ||
window.location.reload(); | ||
} else if (response.status == 400) { | ||
throw new Error("Sjekk at all nødvendig info er fylt ut"); | ||
} else { | ||
throw new Error(response.statusText); | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters