Commit a80eaa34 authored by Hannes Warnestad's avatar Hannes Warnestad
Browse files

New

parent 4d40d621
......@@ -16,7 +16,7 @@
<h1>Form1</h1>
<form-1></form-1>
<h1>Form2</h1>
<!-- <h1>Form2</h1>
<form-2></form-2>
<h1>Form3</h1>
<form-3></form-3>
......@@ -27,13 +27,13 @@
<h1>Form6</h1>
<form-6></form-6>
<input type="submit" value="Skicka in"
style="border-radius: 5px;background-color: #f64c4f;text-align: center; color: white; vertical-align: middle;font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;line-height: 50px;height: 50px;width:100px">
style="border-radius: 5px;background-color: #f64c4f;text-align: center; color: white; vertical-align: middle;font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;line-height: 50px;height: 50px;width:100px"> -->
<h1>Resultat - transport</h1>
<result-transport></result-transport>
<h1>Resultat - Hälsa</h1>
<!-- <h1>Resultat - Hälsa</h1>
<result-health></result-health>
<h1>Resultat - Konsumption</h1>
<result-consumption></result-consumption>
<result-consumption></result-consumption> -->
</body>
</html>
\ No newline at end of file
......@@ -5,6 +5,10 @@
<packaging>war</packaging>
<version>1.0.0</version>
<name>Redpill-Linpro Forms and result</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<!-- Inserting maven compiler. -->
<plugins>
......
import HTTP from "owp.http"
const url = ""
const url = "http://rplp-forms-service-conventionswe.apps.redpill-linpro.com/rest/rest/users"
const postUrl = "http://rplp-forms-service-conventionswe.apps.redpill-linpro.com/rest/rest/postUsers"
export function writeToServer(myData) {
const promise = HTTP.post(url, { data: myData });
const promise = HTTP.post(postUrl, { data: myData });
console.log("------Writing data----------");
console.log(myData)
promise
.then(res => {
console.info("Success!");
console.info("Success! " + res);
return true;
})
.catch(err => console.error("ERROR WRITING: " + err));
}
export function readFromServer() {
const promise = HTTP.get(url);
console.log("------Reading data----------");
promise
.then(res => {
console.info("Success!");
return res.data;
})
.catch(err => console.error("ERROR WRITING: " + err));
export function readFromServer(_form) {
const headers = { Origin: "http://rest-api-service-conventionswe.apps.redpill-linpro.com/" };
const params = {form: _form};
const promise = HTTP.jsonp(url, {headers, params});
return promise;
}
......@@ -2,117 +2,117 @@
const dataService = {
form11: new Promise(resolve => resolve({
xNames: ["Bil", "Båt", "Cykel", "Buss", "Samåkning", "Promenad"],
data: [33, 2, 12, 14, 3, 17]
data: "form11"
}
)),
form12: new Promise(resolve => resolve({
xNames: ["0-1 km", "1-5 km", "5-10km", "10-20 km", ">20 km"],
data: [7, 31, 21, 14, 1]
data: "form12"
}
)),
form13: new Promise(resolve => resolve({
xNames: ["6", "6-7", "7-8", "8-9", "Senare än 9"],
data: [7, 11, 45, 14, 1]
data: "form13"
}
)),
form14: new Promise(resolve => resolve({
xNames: ["1 dag/veckan", "2 dag/veckan", "3 dag/veckan", "4 dag/veckan", "5 dag/veckan"],
data: [37, 24, 11, 14, 5]
data: "form14"
}
)),
form15: new Promise(resolve => resolve({
xNames: ["Ja", "Nej"],
data: [37, 24]
data: "form21"
}
)),
form16: new Promise(resolve => resolve({
xNames: ["Morot", "Piska"],
data: [37, 37]
data: "form22"
}
)),
form17: new Promise(resolve => resolve({
xNames: ["<10 min", "10-20 min", "20-30 min", "30-60 min", "> 60 min"],
data: [37, 24, 11, 14, 5]
data: "form23"
}
)),
form18: new Promise(resolve => resolve({
xNames: ["Ja", "Nej", "Ja - med rätt sällskap"],
data: [37, 24, 11]
data: "form24"
}
)),
form21: new Promise(resolve => resolve({
xNames: ["Ja", "Nej"],
data: [47, 30]
data: "form31"
}
)),
form22: new Promise(resolve => resolve({
xNames: ["Ja", "Nej"],
data: [70, 7]
data: "form32"
}
)),
form23: new Promise(resolve => resolve({
xNames: ["Ja", "Nej"],
data: [33, 34]
data: "form33"
}
)),
form24: new Promise(resolve => resolve({
xNames: ["Ja", "Nej"],
data: [60, 17]
data: "form34"
}
)),
form25: new Promise(resolve => resolve({
xNames: ["Ja", "Nej"],
data: [37, 24]
data: "form41"
}
)),
form26: new Promise(resolve => resolve({
xNames: ["Ja", "Nej"],
data: [37, 24]
data: "form42"
}
)),
form27: new Promise(resolve => resolve({
xNames: ["Ja", "Nej", "Om jag får något tillbaka"],
data: [37, 17, 10]
data: "form43"
}
)),
form28: new Promise(resolve => resolve({
xNames: ["Ja", "Nej", "Om jag får något tillbaka"],
data: [37, 34, 1]
data: "form44"
}
)),
form31: new Promise(resolve => resolve({
xNames: ["Nytt", "Begagnat"],
data: [47, 30]
data: "form51"
}
)),
form32: new Promise(resolve => resolve({
xNames: ["Vet inte", "Tillgänglighet", "Hygien", "Pris", "Design/Mode"],
data: [20, 7, 20, 10]
data: "form52"
}
)),
form33: new Promise(resolve => resolve({
xNames: ["Kläder", "Porslin", "Möbler", "Leksaker", "Fritidsprylar", "Fordon", "Digitala Prylar"],
data: [33, 34, 10, 45, 17, 55, 3]
data: "form53"
}
)),
form34: new Promise(resolve => resolve({
xNames: ["Tillgänglighet", "Incitament", "Piska", "Bra pris", "Insats för miljön"],
data: [5, 4, 1, 50, 30]
data: "form54"
}
)),
form35: new Promise(resolve => resolve({
xNames: ["< 30", "31-50", "51-65", "> 65"],
data: [7, 40, 23, 3]
data: "form61"
}
)),
form36: new Promise(resolve => resolve({
xNames: ["Slänger", "Skänker", "Säljer till bekanta", "Säljer på nätet", "Säljer på loppis", "Olika"],
data: [3, 7, 5, 9, 2, 37]
data: "form62"
}
)),
form37: new Promise(resolve => resolve({
xNames: ["Tillgänglighet", "Pris", "Incitament"],
data: [37, 17, 10]
data: "form63"
}
))
......
......@@ -20,7 +20,7 @@ class form1 extends formBase {
dataMethod: filterServiceData.form13
},
{
title: "Hur ofta jobbar du hemma eller på annan plats än din arbetsplats",
title: "Hur ofta jobbar du hemma eller på annan plats än din arbetsplats?",
name: "form14",
dataMethod: filterServiceData.form14
}
......
......@@ -17,7 +17,8 @@ class form5 extends formBase {
{
title: "Vad kan du tänka dig att köpa begagnat (flervalsalternativ)?",
name: "form53",
dataMethod: filterServiceData.form53
dataMethod: filterServiceData.form53,
multi : true
},
{
title: "Vad skulle kunna få dig att köpa mer begagnat?",
......
......@@ -29,6 +29,7 @@ class formBase extends WC {
else {
const temp = document.createElement("multi-radio-button-select");
console.log(allQuestionsInfo[i].name, "name is here");
temp.setAttribute("name", allQuestionsInfo[i].name);
temp.setAttribute("title", allQuestionsInfo[i].title);
tempDiv.appendChild(temp);
......@@ -57,23 +58,23 @@ class formBase extends WC {
let i = 0;
el.radioButtons.forEach(rb => {
if (rb.button.checked) {
console.log("rb is", rb)
foundChecked = true;
selectedIndexes.push(i);
selectedIndexes.push({value: i, form: rb.button.getAttribute("name")});
}
i++;
})
if (!foundChecked)
cont = false;
})
if (!cont)
window.alert("Alla frågor är inte ifyllda. Var god fyll i alla.")
else {
this.getData(rbArr, selectedIndexes);
writeToServer("")
.then(() => {
window.alert("Ditt svar är nu inskickat! Du kan nu stänga sidan.")
})
.catch(window.alert("Något gick fel när svaren skulle skickas in. Försök igen!"));
selectedIndexes.forEach(res =>{
writeToServer(res);
})
}
});
......@@ -81,28 +82,6 @@ class formBase extends WC {
}
getData(rbArr, selectedIndexes) {
//console.log(com.rplp.mypackage.testSum(1,2))
// var user = new package.com.rplp.mypackage.User;
let jsonUser = {
questions: [
]
}
for (let i = 0; i < rbArr.length; i++) {
jsonUser.questions.push({
form: rbArr[i].getAttribute("name"),
value: selectedIndexes[i]
})
}
return "Hello";
}
}
export default formBase;
......@@ -28,7 +28,9 @@ class multiRadioButtonSelect extends WC {
attributeChanged(name, oldVal, newVal) {
if (oldVal !== newVal) {
if (name === "name") {
this.name = name;
console.log("HERE")
console.log(newVal)
this.name = newVal;
this.radioButtons.forEach((rb) => {
rb.setAttribute("name", newVal);
})
......
import Highcharts from "highcharts"
import WC from "webcomponentcreator"
import {readFromServer} from "./client/callServer"
import { readFromServer } from "./client/callServer"
class resultBase extends WC {
/**
......@@ -17,18 +17,35 @@ class resultBase extends WC {
let allCharts = [];
allCharts[i] = Highcharts.chart(tempDiv, {
chart: {
type: "column"
type: "column",
events: {
load: function () {
allChartsInfo[i].dataMethod.then(res => {
console.log(res)
this.xAxis.categories = res.xNames;
console.log("BEfore read")
readFromServer(res.data).then(data => {
console.log("after read");
console.log(data);
// this.addSeries();
});
this.reflow();
});
}
}
},
tooltip:{
formatter: function(){
return '<b>'+this.x+':</b> ' + this.y;
tooltip: {
formatter: function () {
return '<b>' + this.x + ':</b> ' + this.y;
}
},
credits: {
enabled: false
},
legend:{
legend: {
enabled: false
},
title: {
......@@ -43,9 +60,10 @@ class resultBase extends WC {
column: {
colorByPoint: true
}
}
},
});
// allChartsInfo[i].dataMethod.then(res => {
// allCharts[i].addSeries({
// data: res.data
......@@ -59,9 +77,8 @@ class resultBase extends WC {
// })
}
readFromServer().then(() =>{
console.log("In result base, reading...!")
});
// console.log(readFromServer());
}
}
export default resultBase;
\ No newline at end of file
No preview for this file type
#Generated by Maven
#Thu Nov 19 17:52:25 CET 2020
#Mon Nov 23 15:23:33 CET 2020
groupId=com.rplp.forms
artifactId=rplp-forms
version=1.0.0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment