Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • idatt2106-v23-10/smartmat-frontend
1 result
Show changes
Commits on Source (13)
Showing
with 1040 additions and 64 deletions
......@@ -25,7 +25,7 @@ unit-test-job:
stage: test
script:
- echo "Running unit tests..."
- npm run test:unit
- npx vitest --mode development
- echo "Finished running unit tests."
e2e-test-job:
......
......@@ -10,15 +10,19 @@
"dependencies": {
"@vuelidate/core": "^2.0.2",
"@vuelidate/validators": "^2.0.2",
"chart.js": "^4.3.0",
"element-plus": "^2.3.3",
"luxon": "^3.3.0",
"mitt": "^3.0.0",
"pinia": "^2.0.32",
"vue": "^3.2.47",
"vue-chartjs": "^5.2.0",
"vue-router": "^4.1.6"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.2.0",
"@types/jsdom": "^21.1.0",
"@types/luxon": "^3.3.0",
"@types/node": "^18.14.2",
"@vitejs/plugin-vue": "^4.0.0",
"@vue/eslint-config-prettier": "^7.1.0",
......@@ -610,6 +614,11 @@
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
"dev": true
},
"node_modules/@kurkle/color": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@kurkle/color/-/color-0.3.2.tgz",
"integrity": "sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw=="
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
......@@ -764,6 +773,12 @@
"@types/lodash": "*"
}
},
"node_modules/@types/luxon": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.0.tgz",
"integrity": "sha512-uKRI5QORDnrGFYgcdAVnHvEIvEZ8noTpP/Bg+HeUzZghwinDlIS87DEenV5r1YoOF9G4x600YsUXLWZ19rmTmg==",
"dev": true
},
"node_modules/@types/node": {
"version": "18.15.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
......@@ -2150,6 +2165,17 @@
"node": ">=8"
}
},
"node_modules/chart.js": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/chart.js/-/chart.js-4.3.0.tgz",
"integrity": "sha512-ynG0E79xGfMaV2xAHdbhwiPLczxnNNnasrmPEXriXsPJGjmhOBYzFVEsB65w2qMDz+CaBJJuJD0inE/ab/h36g==",
"dependencies": {
"@kurkle/color": "^0.3.0"
},
"engines": {
"pnpm": ">=7"
}
},
"node_modules/check-error": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
......@@ -4844,6 +4870,14 @@
"yallist": "^2.1.2"
}
},
"node_modules/luxon": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.3.0.tgz",
"integrity": "sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==",
"engines": {
"node": ">=12"
}
},
"node_modules/magic-string": {
"version": "0.25.9",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
......@@ -7212,6 +7246,15 @@
"@vue/shared": "3.2.47"
}
},
"node_modules/vue-chartjs": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/vue-chartjs/-/vue-chartjs-5.2.0.tgz",
"integrity": "sha512-d3zpKmGZr2OWHQ1xmxBcAn5ShTG917+/UCLaSpaCDDqT0U7DBsvFzTs69ZnHCgKoXT55GZDW8YEj9Av+dlONLA==",
"peerDependencies": {
"chart.js": "^4.1.1",
"vue": "^3.0.0-0 || ^2.7.0"
}
},
"node_modules/vue-eslint-parser": {
"version": "9.1.1",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-9.1.1.tgz",
......
......@@ -19,15 +19,19 @@
"dependencies": {
"@vuelidate/core": "^2.0.2",
"@vuelidate/validators": "^2.0.2",
"chart.js": "^4.3.0",
"element-plus": "^2.3.3",
"luxon": "^3.3.0",
"mitt": "^3.0.0",
"pinia": "^2.0.32",
"vue": "^3.2.47",
"vue-chartjs": "^5.2.0",
"vue-router": "^4.1.6"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.2.0",
"@types/jsdom": "^21.1.0",
"@types/luxon": "^3.3.0",
"@types/node": "^18.14.2",
"@vitejs/plugin-vue": "^4.0.0",
"@vue/eslint-config-prettier": "^7.1.0",
......
<template>
<div class="probability-bar" ref="barRef" @cange="console.log('mo')">
<div class="spacer"></div>
<div class="inner-bar" :style="{ height: inPercentage + '%' }">
<h2>{{ Math.round(inPercentage) }}%</h2>
</div>
</div>
<el-tooltip content="Gjennomsnittlig norsk husholdning">
<div class="normalHousehold" :style="{ marginTop: -marginBottom - 10 + 'px' }"></div>
<!-- 10px is half of the width of the triangle -->>
</el-tooltip>
</template>
<script lang="ts" setup>
import { computed, onMounted, ref } from "vue";
const props = defineProps<{
percentage: {
type: number;
required: true;
};
normalHousehold: {
type: number;
required: true;
};
}>();
const barRef = ref<HTMLElement | null>(null);
const barHeight = ref(0 as number);
onMounted(() => {
if (barRef.value) {
barHeight.value = barRef.value.clientHeight;
}
addEventListener("resize", () => {
if (barRef.value) {
barHeight.value = barRef.value.clientHeight;
}
});
});
const inPercentage = computed(() => (1 - props.percentage) * 100);
const marginBottom = computed(() => {
if (barHeight.value) {
return (1 - props.normalHousehold) * barHeight.value;
}
return 0;
});
</script>
<style scoped>
.probability-bar {
height: 100%;
padding: 0;
background-color: #84a98c;
border-radius: 10px;
display: flex;
flex-direction: column;
margin-left: 1rem;
width: calc(100% - 1rem);
}
.inner-bar {
width: 100%;
background-color: #354f52;
transition: height 0.6s ease-in-out;
border-radius: 10px;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
.normalHousehold {
position: absolute;
color: black;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid gray;
cursor: pointer;
}
</style>
<template>
<el-table :data="props.tableData" style="width: 100%" height="250" default-sort="amountWasted">
<el-table-column fixed prop="name" label="Vare" sortable />
<el-table-column prop="amountWasted" label="svinn per vare" sortable />
<el-table-column prop="countWasted" label="totalt" sortable />
</el-table>
</template>
<script lang="ts" setup>
const props = defineProps<{
tableData: {
name: string;
amountWasted: string;
countWasted: string;
}[];
}>();
</script>
<template>
<LineChartJS :options="options" :data="chartData" key="mo" />
</template>
<script lang="ts">
import {
CategoryScale,
Chart as ChartJS,
Legend,
LinearScale,
LineElement,
PointElement,
Title,
Tooltip,
} from "chart.js";
import { Line as LineChartJS } from "vue-chartjs";
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend);
/*Compostion api did not work on this component, so I had to use the old way of doing it*/
export default {
name: "LineChart",
components: {
LineChartJS,
},
data() {
return {
options: {
type: "line",
responsive: true,
pointStyle: false,
interaction: {
intersect: false,
},
maintainAspectRatio: false,
plugins: {
title: {
display: true,
text: "Bruk og svinn",
},
},
scales: {
y: {
beginAtZero: true,
max: 100,
},
},
},
};
},
props: {
chartData: {
type: Object,
required: true,
},
},
};
</script>
<template>
<div class="wrapper">
<el-tooltip content="Estimert godt">
<div class="success bar start" :style="{ width: props.successPercentage + '%' }">
<span v-if="props.successPercentage >= 10"> {{ props.successPercentage }}%</span>
</div>
</el-tooltip>
<el-tooltip content="Kan være dårlig">
<div class="warning bar" :style="{ width: props.warningPercentage + '%' }">
<span v-if="props.warningPercentage >= 10"> {{ props.warningPercentage }}%</span>
</div>
</el-tooltip>
<el-tooltip content="Bør brukes">
<div class="danger bar end" :style="{ width: props.dangerPercentage + '%' }">
<span v-if="props.dangerPercentage >= 10"> {{ props.dangerPercentage }}%</span>
</div>
</el-tooltip>
</div>
</template>
<script setup lang="ts">
const props = defineProps<{
dangerPercentage: {
type: number;
required: true;
};
warningPercentage: {
type: number;
required: true;
};
successPercentage: {
type: number;
required: true;
};
}>();
</script>
<style scoped>
.wrapper {
display: flex;
flex-direction: row;
width: 100%;
height: 2rem;
border-radius: 10px;
background-color: #f1f1f1;
}
.bar {
height: 100%;
width: 0;
padding-left: 0.3rem;
display: flex;
align-items: center;
color: white;
transition: width 0.4s ease-in-out;
text-after-overflow: ellipsis;
}
.success {
background-color: var(--el-color-success);
}
.warning {
background-color: var(--el-color-warning);
}
.end {
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
}
.start {
border-bottom-left-radius: 10px;
border-top-left-radius: 10px;
}
.danger {
background-color: var(--el-color-danger);
}
</style>
......@@ -44,7 +44,7 @@
</el-icon>
<span>Oversikt</span>
</el-menu-item>
<el-menu-item disabled index="/statistics">
<el-menu-item index="/statistics">
<el-icon>
<DataAnalysis />
</el-icon>
......
......@@ -11,20 +11,17 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import globalAxios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from "axios";
import { Configuration } from "../configuration";
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, BaseAPI, COLLECTION_FORMATS, RequestArgs, RequiredError } from "../base";
import {
CreateUser,
Household,
InlineResponse200,
LoginUser,
UpdateUser,
UserFull,
} from "../models";
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from "../base";
import { CreateUser } from "../models";
import { Household } from "../models";
import { InlineResponse200 } from "../models";
import { LoginUser } from "../models";
import { UpdateUser } from "../models";
import { UserFull } from "../models";
/**
* AccountApi - axios parameter creator
* @export
......@@ -858,7 +855,6 @@ export class AccountApi extends BaseAPI {
.createUser(body, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Deletes a user
* @summary Delete user
......@@ -872,7 +868,6 @@ export class AccountApi extends BaseAPI {
.deleteUser(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Gets a list of households of a given user
* @summary Get a user's households
......@@ -889,7 +884,6 @@ export class AccountApi extends BaseAPI {
.getHouseholds(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Returns the details of the logged in user, the details are extracted from the jwt token cookie.
* @summary Get the user details from the jwt token cookie
......@@ -902,7 +896,6 @@ export class AccountApi extends BaseAPI {
.getLoggedInUser(options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Returns a single user by email
* @summary Get user by email
......@@ -919,7 +912,6 @@ export class AccountApi extends BaseAPI {
.getUserByEmail(email, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Returns a single user
* @summary Get user by id
......@@ -936,7 +928,6 @@ export class AccountApi extends BaseAPI {
.getUserById(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Logs in a user
* @summary Login user
......@@ -953,7 +944,6 @@ export class AccountApi extends BaseAPI {
.loginUser(body, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Logs out a user
* @summary Logout user
......@@ -966,7 +956,6 @@ export class AccountApi extends BaseAPI {
.logoutUser(options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Updates a user
* @summary Update user
......
......@@ -11,20 +11,18 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import globalAxios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from "axios";
import { Configuration } from "../configuration";
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, BaseAPI, COLLECTION_FORMATS, RequestArgs, RequiredError } from "../base";
import {
CreateHousehold,
Household,
HouseholdMember,
IdUsersBody,
InlineResponse2001,
UpdateHouseholdUserType,
} from "../models";
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from "../base";
import { CreateHousehold } from "../models";
import { Household } from "../models";
import { HouseholdMember } from "../models";
import { IdUsersBody } from "../models";
import { InlineResponse2001 } from "../models";
import { InventoryWasteResponse } from "../models";
import { UpdateHouseholdUserType } from "../models";
/**
* HouseholdApi - axios parameter creator
* @export
......@@ -360,6 +358,144 @@ export const HouseholdApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions,
};
},
/**
* Returns lists of household waste
* @summary Returns a list of household waste
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months back to get wasted items from
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
householdIdInventoryWasteGet: async (
id: number,
numMonths: number,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new RequiredError(
"id",
"Required parameter id was null or undefined when calling householdIdInventoryWasteGet."
);
}
// verify required parameter 'numMonths' is not null or undefined
if (numMonths === null || numMonths === undefined) {
throw new RequiredError(
"numMonths",
"Required parameter numMonths was null or undefined when calling householdIdInventoryWasteGet."
);
}
const localVarPath = `/household/{id}/inventory/waste`.replace(
`{${"id"}}`,
encodeURIComponent(String(id))
);
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, "https://example.com");
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions: AxiosRequestConfig = {
method: "GET",
...baseOptions,
...options,
};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (numMonths !== undefined) {
localVarQueryParameter["num_months"] = numMonths;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = new URLSearchParams(query).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
* Gets a list of average amount wasted per month
* @summary Gets a list of average amount wasted per month
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months backward to process. The returned list starts at the current month for index 0, the previous month for index 1 etc...
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
householdIdInventoryWastePerMonthGet: async (
id: number,
numMonths: number,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new RequiredError(
"id",
"Required parameter id was null or undefined when calling householdIdInventoryWastePerMonthGet."
);
}
// verify required parameter 'numMonths' is not null or undefined
if (numMonths === null || numMonths === undefined) {
throw new RequiredError(
"numMonths",
"Required parameter numMonths was null or undefined when calling householdIdInventoryWastePerMonthGet."
);
}
const localVarPath = `/household/{id}/inventory/waste-per-month`.replace(
`{${"id"}}`,
encodeURIComponent(String(id))
);
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, "https://example.com");
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions: AxiosRequestConfig = {
method: "GET",
...baseOptions,
...options,
};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (numMonths !== undefined) {
localVarQueryParameter["num_months"] = numMonths;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = new URLSearchParams(query).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
* Removes a user from a household. Can only be done by a superuser or the user themselves
* @summary Remove a user from a household
......@@ -710,6 +846,58 @@ export const HouseholdApiFp = function (configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
* Returns lists of household waste
* @summary Returns a list of household waste
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months back to get wasted items from
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async householdIdInventoryWasteGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<
(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<InventoryWasteResponse>>
> {
const localVarAxiosArgs = await HouseholdApiAxiosParamCreator(
configuration
).householdIdInventoryWasteGet(id, numMonths, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs: AxiosRequestConfig = {
...localVarAxiosArgs.options,
url: basePath + localVarAxiosArgs.url,
};
return axios.request(axiosRequestArgs);
};
},
/**
* Gets a list of average amount wasted per month
* @summary Gets a list of average amount wasted per month
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months backward to process. The returned list starts at the current month for index 0, the previous month for index 1 etc...
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async householdIdInventoryWastePerMonthGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<
(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<Array<number>>>
> {
const localVarAxiosArgs = await HouseholdApiAxiosParamCreator(
configuration
).householdIdInventoryWastePerMonthGet(id, numMonths, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs: AxiosRequestConfig = {
...localVarAxiosArgs.options,
url: basePath + localVarAxiosArgs.url,
};
return axios.request(axiosRequestArgs);
};
},
/**
* Removes a user from a household. Can only be done by a superuser or the user themselves
* @summary Remove a user from a household
......@@ -888,6 +1076,40 @@ export const HouseholdApiFactory = function (
.getUsers(id, options)
.then((request) => request(axios, basePath));
},
/**
* Returns lists of household waste
* @summary Returns a list of household waste
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months back to get wasted items from
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async householdIdInventoryWasteGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<AxiosResponse<InventoryWasteResponse>> {
return HouseholdApiFp(configuration)
.householdIdInventoryWasteGet(id, numMonths, options)
.then((request) => request(axios, basePath));
},
/**
* Gets a list of average amount wasted per month
* @summary Gets a list of average amount wasted per month
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months backward to process. The returned list starts at the current month for index 0, the previous month for index 1 etc...
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async householdIdInventoryWastePerMonthGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<AxiosResponse<Array<number>>> {
return HouseholdApiFp(configuration)
.householdIdInventoryWastePerMonthGet(id, numMonths, options)
.then((request) => request(axios, basePath));
},
/**
* Removes a user from a household. Can only be done by a superuser or the user themselves
* @summary Remove a user from a household
......@@ -967,7 +1189,6 @@ export class HouseholdApi extends BaseAPI {
.addUser(id, body, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Creates a household
* @summary Create a household
......@@ -984,7 +1205,6 @@ export class HouseholdApi extends BaseAPI {
.createHousehold(body, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Deletes a household. Can only be done by superusers.
* @summary Delete a household
......@@ -1001,7 +1221,6 @@ export class HouseholdApi extends BaseAPI {
.deleteHousehold(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Returns a single household
* @summary Get household by id
......@@ -1018,7 +1237,6 @@ export class HouseholdApi extends BaseAPI {
.getHouseholdById(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Gets a list of households of a given user
* @summary Get a user's households
......@@ -1035,7 +1253,6 @@ export class HouseholdApi extends BaseAPI {
.getHouseholds(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Gets all the users that are member of a household
* @summary Get household users
......@@ -1052,7 +1269,42 @@ export class HouseholdApi extends BaseAPI {
.getUsers(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Returns lists of household waste
* @summary Returns a list of household waste
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months back to get wasted items from
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof HouseholdApi
*/
public async householdIdInventoryWasteGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<AxiosResponse<InventoryWasteResponse>> {
return HouseholdApiFp(this.configuration)
.householdIdInventoryWasteGet(id, numMonths, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Gets a list of average amount wasted per month
* @summary Gets a list of average amount wasted per month
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months backward to process. The returned list starts at the current month for index 0, the previous month for index 1 etc...
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof HouseholdApi
*/
public async householdIdInventoryWastePerMonthGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<AxiosResponse<Array<number>>> {
return HouseholdApiFp(this.configuration)
.householdIdInventoryWastePerMonthGet(id, numMonths, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Removes a user from a household. Can only be done by a superuser or the user themselves
* @summary Remove a user from a household
......@@ -1071,7 +1323,6 @@ export class HouseholdApi extends BaseAPI {
.removeUserFromHousehold(id, userId, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Updates the household's attributes. Can only be done by a superuser
* @summary Update household
......@@ -1090,7 +1341,6 @@ export class HouseholdApi extends BaseAPI {
.updateHousehold(id, body, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Updates the role of a user withing a given household. Can only be done by a superuser
* @summary Update household member role of user
......
......@@ -11,13 +11,16 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import globalAxios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from "axios";
import { Configuration } from "../configuration";
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, BaseAPI, COLLECTION_FORMATS, RequestArgs, RequiredError } from "../base";
import { IdInventoryBody, InventoryItems, Item, UpdateItem } from "../models";
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from "../base";
import { IdInventoryBody } from "../models";
import { InventoryItems } from "../models";
import { InventoryWasteResponse } from "../models";
import { Item } from "../models";
import { UpdateItem } from "../models";
/**
* InventoryApi - axios parameter creator
* @export
......@@ -276,6 +279,144 @@ export const InventoryApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions,
};
},
/**
* Returns lists of household waste
* @summary Returns a list of household waste
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months back to get wasted items from
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
householdIdInventoryWasteGet: async (
id: number,
numMonths: number,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new RequiredError(
"id",
"Required parameter id was null or undefined when calling householdIdInventoryWasteGet."
);
}
// verify required parameter 'numMonths' is not null or undefined
if (numMonths === null || numMonths === undefined) {
throw new RequiredError(
"numMonths",
"Required parameter numMonths was null or undefined when calling householdIdInventoryWasteGet."
);
}
const localVarPath = `/household/{id}/inventory/waste`.replace(
`{${"id"}}`,
encodeURIComponent(String(id))
);
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, "https://example.com");
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions: AxiosRequestConfig = {
method: "GET",
...baseOptions,
...options,
};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (numMonths !== undefined) {
localVarQueryParameter["num_months"] = numMonths;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = new URLSearchParams(query).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
* Gets a list of average amount wasted per month
* @summary Gets a list of average amount wasted per month
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months backward to process. The returned list starts at the current month for index 0, the previous month for index 1 etc...
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
householdIdInventoryWastePerMonthGet: async (
id: number,
numMonths: number,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'id' is not null or undefined
if (id === null || id === undefined) {
throw new RequiredError(
"id",
"Required parameter id was null or undefined when calling householdIdInventoryWastePerMonthGet."
);
}
// verify required parameter 'numMonths' is not null or undefined
if (numMonths === null || numMonths === undefined) {
throw new RequiredError(
"numMonths",
"Required parameter numMonths was null or undefined when calling householdIdInventoryWastePerMonthGet."
);
}
const localVarPath = `/household/{id}/inventory/waste-per-month`.replace(
`{${"id"}}`,
encodeURIComponent(String(id))
);
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, "https://example.com");
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions: AxiosRequestConfig = {
method: "GET",
...baseOptions,
...options,
};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
if (numMonths !== undefined) {
localVarQueryParameter["num_months"] = numMonths;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = new URLSearchParams(query).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
* Alters an item in inventory. Either the state or the remaining amount can be changed.
* @summary Alters an item in inventory
......@@ -451,6 +592,58 @@ export const InventoryApiFp = function (configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
* Returns lists of household waste
* @summary Returns a list of household waste
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months back to get wasted items from
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async householdIdInventoryWasteGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<
(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<InventoryWasteResponse>>
> {
const localVarAxiosArgs = await InventoryApiAxiosParamCreator(
configuration
).householdIdInventoryWasteGet(id, numMonths, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs: AxiosRequestConfig = {
...localVarAxiosArgs.options,
url: basePath + localVarAxiosArgs.url,
};
return axios.request(axiosRequestArgs);
};
},
/**
* Gets a list of average amount wasted per month
* @summary Gets a list of average amount wasted per month
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months backward to process. The returned list starts at the current month for index 0, the previous month for index 1 etc...
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async householdIdInventoryWastePerMonthGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<
(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<Array<number>>>
> {
const localVarAxiosArgs = await InventoryApiAxiosParamCreator(
configuration
).householdIdInventoryWastePerMonthGet(id, numMonths, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs: AxiosRequestConfig = {
...localVarAxiosArgs.options,
url: basePath + localVarAxiosArgs.url,
};
return axios.request(axiosRequestArgs);
};
},
/**
* Alters an item in inventory. Either the state or the remaining amount can be changed.
* @summary Alters an item in inventory
......@@ -554,6 +747,40 @@ export const InventoryApiFactory = function (
.getInventoryItems(id, options)
.then((request) => request(axios, basePath));
},
/**
* Returns lists of household waste
* @summary Returns a list of household waste
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months back to get wasted items from
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async householdIdInventoryWasteGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<AxiosResponse<InventoryWasteResponse>> {
return InventoryApiFp(configuration)
.householdIdInventoryWasteGet(id, numMonths, options)
.then((request) => request(axios, basePath));
},
/**
* Gets a list of average amount wasted per month
* @summary Gets a list of average amount wasted per month
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months backward to process. The returned list starts at the current month for index 0, the previous month for index 1 etc...
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async householdIdInventoryWastePerMonthGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<AxiosResponse<Array<number>>> {
return InventoryApiFp(configuration)
.householdIdInventoryWastePerMonthGet(id, numMonths, options)
.then((request) => request(axios, basePath));
},
/**
* Alters an item in inventory. Either the state or the remaining amount can be changed.
* @summary Alters an item in inventory
......@@ -599,7 +826,6 @@ export class InventoryApi extends BaseAPI {
.addInventoryItem(id, body, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Takes a list of entries, each entry contains an item type id and count. These item types are added as suggestions to the inventory.
* @summary Add suggestion to inventory
......@@ -618,7 +844,6 @@ export class InventoryApi extends BaseAPI {
.addInventorySuggestion(id, body, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Delete an item from inventory of a household.
* @summary Delete item from inventory
......@@ -637,7 +862,6 @@ export class InventoryApi extends BaseAPI {
.deleteInventoryItem(id, itemId, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Gets all items of a specific inventory
* @summary Gets all items from inventory
......@@ -654,7 +878,42 @@ export class InventoryApi extends BaseAPI {
.getInventoryItems(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Returns lists of household waste
* @summary Returns a list of household waste
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months back to get wasted items from
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof InventoryApi
*/
public async householdIdInventoryWasteGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<AxiosResponse<InventoryWasteResponse>> {
return InventoryApiFp(this.configuration)
.householdIdInventoryWasteGet(id, numMonths, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Gets a list of average amount wasted per month
* @summary Gets a list of average amount wasted per month
* @param {number} id ID of household to get waste from
* @param {number} numMonths The number of months backward to process. The returned list starts at the current month for index 0, the previous month for index 1 etc...
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof InventoryApi
*/
public async householdIdInventoryWastePerMonthGet(
id: number,
numMonths: number,
options?: AxiosRequestConfig
): Promise<AxiosResponse<Array<number>>> {
return InventoryApiFp(this.configuration)
.householdIdInventoryWastePerMonthGet(id, numMonths, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Alters an item in inventory. Either the state or the remaining amount can be changed.
* @summary Alters an item in inventory
......
......@@ -11,13 +11,12 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import globalAxios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from "axios";
import { Configuration } from "../configuration";
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, BaseAPI, COLLECTION_FORMATS, RequestArgs, RequiredError } from "../base";
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from "../base";
import { ItemType } from "../models";
/**
* ItemTypeApi - axios parameter creator
* @export
......
/* tslint:disable */
/* eslint-disable */
/**
* Freshify API Documentation
* An API for creating and managing a household inventory and shopping list. The API is written in Java using the Spring Boot framework. The API uses a MySQL database. The API is documented using Swagger. The API is hosted using Apache. Some useful links: - [The GitLab repository](https://gitlab.stud.idi.ntnu.no/idatt2106-v23-10/smartmat-backend)
*
* OpenAPI spec version: 1.0.0
* Contact: vkbugge@hotmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from "axios";
import { Configuration } from "../configuration";
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from "../base";
import { Recipe } from "../models";
import { RecipeRequest } from "../models";
/**
* RecipesApi - axios parameter creator
* @export
*/
export const RecipesApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
* Creates a new recipe and saves to backend.
* @summary Create a new recipe
* @param {RecipeRequest} body Recipe object to be created and saved.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
createRecipe: async (
body: RecipeRequest,
options: AxiosRequestConfig = {}
): Promise<RequestArgs> => {
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new RequiredError(
"body",
"Required parameter body was null or undefined when calling createRecipe."
);
}
const localVarPath = `/recipes`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, "https://example.com");
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions: AxiosRequestConfig = {
method: "POST",
...baseOptions,
...options,
};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarHeaderParameter["Content-Type"] = "application/json";
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = new URLSearchParams(query).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {
...localVarHeaderParameter,
...headersFromBaseOptions,
...options.headers,
};
const needsSerialization =
typeof body !== "string" ||
localVarRequestOptions.headers["Content-Type"] === "application/json";
localVarRequestOptions.data = needsSerialization
? JSON.stringify(body !== undefined ? body : {})
: body || "";
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
};
};
/**
* RecipesApi - functional programming interface
* @export
*/
export const RecipesApiFp = function (configuration?: Configuration) {
return {
/**
* Creates a new recipe and saves to backend.
* @summary Create a new recipe
* @param {RecipeRequest} body Recipe object to be created and saved.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async createRecipe(
body: RecipeRequest,
options?: AxiosRequestConfig
): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<Recipe>>> {
const localVarAxiosArgs = await RecipesApiAxiosParamCreator(configuration).createRecipe(
body,
options
);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs: AxiosRequestConfig = {
...localVarAxiosArgs.options,
url: basePath + localVarAxiosArgs.url,
};
return axios.request(axiosRequestArgs);
};
},
};
};
/**
* RecipesApi - factory interface
* @export
*/
export const RecipesApiFactory = function (
configuration?: Configuration,
basePath?: string,
axios?: AxiosInstance
) {
return {
/**
* Creates a new recipe and saves to backend.
* @summary Create a new recipe
* @param {RecipeRequest} body Recipe object to be created and saved.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async createRecipe(
body: RecipeRequest,
options?: AxiosRequestConfig
): Promise<AxiosResponse<Recipe>> {
return RecipesApiFp(configuration)
.createRecipe(body, options)
.then((request) => request(axios, basePath));
},
};
};
/**
* RecipesApi - object-oriented interface
* @export
* @class RecipesApi
* @extends {BaseAPI}
*/
export class RecipesApi extends BaseAPI {
/**
* Creates a new recipe and saves to backend.
* @summary Create a new recipe
* @param {RecipeRequest} body Recipe object to be created and saved.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof RecipesApi
*/
public async createRecipe(
body: RecipeRequest,
options?: AxiosRequestConfig
): Promise<AxiosResponse<Recipe>> {
return RecipesApiFp(this.configuration)
.createRecipe(body, options)
.then((request) => request(this.axios, this.basePath));
}
}
......@@ -11,13 +11,14 @@
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import globalAxios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
import globalAxios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from "axios";
import { Configuration } from "../configuration";
// Some imports not used depending on template conditions
// @ts-ignore
import { BASE_PATH, BaseAPI, COLLECTION_FORMATS, RequestArgs, RequiredError } from "../base";
import { CreateShoppingListEntry, ShoppingListEntry, UpdateShoppingListEntry } from "../models";
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from "../base";
import { CreateShoppingListEntry } from "../models";
import { ShoppingListEntry } from "../models";
import { UpdateShoppingListEntry } from "../models";
/**
* ShoppingListApi - axios parameter creator
* @export
......@@ -582,7 +583,6 @@ export class ShoppingListApi extends BaseAPI {
.addItem(id, body, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Delete an item from shopping list of a household, both ItemType and count of the item should be passed
* @summary Delete item from shopping list
......@@ -601,7 +601,6 @@ export class ShoppingListApi extends BaseAPI {
.deleteShoppingListEntry(id, listEntryId, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Gets a shopping list with item id from shopping list
* @summary Get the shopping list of a household
......@@ -618,7 +617,6 @@ export class ShoppingListApi extends BaseAPI {
.getShoppingList(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Mark items as bought. Items are removed from shopping list.
* @summary Mark items as bought
......@@ -635,7 +633,6 @@ export class ShoppingListApi extends BaseAPI {
.markItemsAsBought(id, options)
.then((request) => request(this.axios, this.basePath));
}
/**
* Updates an entry in the shopping list of a household
* @summary Update shopping list entry
......
/* tslint:disable */
/* eslint-disable */
/**
* Freshify API Documentation
* An API for creating and managing a household inventory and shopping list. The API is written in Java using the Spring Boot framework. The API uses a MySQL database. The API is documented using Swagger. The API is hosted using Apache. Some useful links: - [The GitLab repository](https://gitlab.stud.idi.ntnu.no/idatt2106-v23-10/smartmat-backend)
*
* OpenAPI spec version: 1.0.0
* Contact: vkbugge@hotmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/**
*
* @export
* @interface AllergenRequest
*/
export interface AllergenRequest {
/**
*
* @type {number}
* @memberof AllergenRequest
*/
id?: number;
/**
*
* @type {string}
* @memberof AllergenRequest
*/
name?: string;
}
/* tslint:disable */
/* eslint-disable */
/**
* Freshify API Documentation
* An API for creating and managing a household inventory and shopping list. The API is written in Java using the Spring Boot framework. The API uses a MySQL database. The API is documented using Swagger. The API is hosted using Apache. Some useful links: - [The GitLab repository](https://gitlab.stud.idi.ntnu.no/idatt2106-v23-10/smartmat-backend)
......
/* tslint:disable */
/* eslint-disable */
/**
* Freshify API Documentation
* An API for creating and managing a household inventory and shopping list. The API is written in Java using the Spring Boot framework. The API uses a MySQL database. The API is documented using Swagger. The API is hosted using Apache. Some useful links: - [The GitLab repository](https://gitlab.stud.idi.ntnu.no/idatt2106-v23-10/smartmat-backend)
......
/* tslint:disable */
/* eslint-disable */
/**
* Freshify API Documentation
* An API for creating and managing a household inventory and shopping list. The API is written in Java using the Spring Boot framework. The API uses a MySQL database. The API is documented using Swagger. The API is hosted using Apache. Some useful links: - [The GitLab repository](https://gitlab.stud.idi.ntnu.no/idatt2106-v23-10/smartmat-backend)
......
/* tslint:disable */
/* eslint-disable */
/**
* Freshify API Documentation
* An API for creating and managing a household inventory and shopping list. The API is written in Java using the Spring Boot framework. The API uses a MySQL database. The API is documented using Swagger. The API is hosted using Apache. Some useful links: - [The GitLab repository](https://gitlab.stud.idi.ntnu.no/idatt2106-v23-10/smartmat-backend)
......
......@@ -14,7 +14,6 @@
import { HouseholdMemberKey } from "./household-member-key";
import { HouseholdUserType } from "./household-user-type";
import { UserFull } from "./user-full";
/**
*
* @export
......