Settings from backend
This commit is contained in:
parent
b3964b3a97
commit
370df82259
@ -77,7 +77,7 @@ def get_fuzzy_response(request_params, objects_list):
|
|||||||
car.combustion,
|
car.combustion,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if min(comparator) > settings.COMPARATOR:
|
if comparator and min(comparator) > settings.COMPARATOR:
|
||||||
end_object_list.append(car)
|
end_object_list.append(car)
|
||||||
|
|
||||||
return end_object_list
|
return end_object_list
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import re
|
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
from django.conf import settings
|
||||||
from .fuzzy_logic import get_fuzzy_response
|
from .fuzzy_logic import get_fuzzy_response
|
||||||
from .models import Car
|
from .models import Car
|
||||||
from .serializers import CarSerializer
|
from .serializers import CarSerializer
|
||||||
@ -23,3 +23,13 @@ class SettingsAPIView(APIView):
|
|||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
set_settings_values(request.data)
|
set_settings_values(request.data)
|
||||||
return Response("Settings changed")
|
return Response("Settings changed")
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
return Response({
|
||||||
|
'production_year':settings.PRODUCTION_YEAR,
|
||||||
|
'mileage':settings.MILEAGE,
|
||||||
|
'engine_capacity':settings.ENGINE_CAPACITY,
|
||||||
|
'combustion':settings.COMBUSTION,
|
||||||
|
'comparator':settings.COMPARATOR,
|
||||||
|
|
||||||
|
})
|
@ -13,7 +13,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
import axios from "axios";
|
||||||
export default {
|
export default {
|
||||||
name: "Table",
|
name: "Table",
|
||||||
|
|
||||||
@ -52,22 +52,34 @@ export default {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
comparator: {
|
comparator: {
|
||||||
label: "Stopień przynależności",
|
label: "Stopień przynależności",
|
||||||
items: [
|
items: [{ label: "", value: 0.75 }],
|
||||||
{ label: "",
|
},
|
||||||
value: 0.75
|
|
||||||
}
|
|
||||||
],
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {},
|
||||||
|
created() {
|
||||||
|
this.getSettings();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeSettings() {
|
changeSettings() {
|
||||||
axios.post('http://localhost:8000/settings', this.settings)
|
axios.post("http://localhost:8000/settings", this.settings);
|
||||||
}
|
},
|
||||||
}
|
setValuesToSettings(label, data) {
|
||||||
|
this.settings[label].items[0].value = data[label].low.join(',')
|
||||||
|
this.settings[label].items[1].value = data[label].mid.join(',')
|
||||||
|
this.settings[label].items[2].value = data[label].high.join(',')
|
||||||
|
},
|
||||||
|
async getSettings() {
|
||||||
|
const response = await axios.get("http://localhost:8000/settings");
|
||||||
|
const data = response.data;
|
||||||
|
this.settings.comparator.items[0].value = data.comparator
|
||||||
|
this.setValuesToSettings('production_year', data)
|
||||||
|
this.setValuesToSettings('mileage', data)
|
||||||
|
this.setValuesToSettings('combustion', data)
|
||||||
|
this.setValuesToSettings('engine_capacity', data)
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user