Skip to content

Commit

Permalink
add minimal gui that lists proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
lilioid committed Feb 29, 2024
1 parent 40b83c1 commit c892c70
Show file tree
Hide file tree
Showing 18 changed files with 1,202 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/mafiasi_kultur_gui/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default defineAppConfig({
mafiasi: {
openidScopes: "openid"
openidScopes: "openid profile"
}
})
17 changes: 8 additions & 9 deletions src/mafiasi_kultur_gui/composables/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Configuration} from "~/utils/apiClient";
import {AgsApi, Configuration, MediumsApi} from "~/utils/apiClient";

async function useApiConfig(): Promise<Configuration> {
const appConfig = useRuntimeConfig();
Expand All @@ -12,11 +12,10 @@ async function useApiConfig(): Promise<Configuration> {
})
}

/*
* Construct api clients like this:
*
* import {StuffApi} from "~/utils/apiClient";
* export async function useStuffApi(): Promise<StuffApi> {
* return new StuffApi(await useApiConfig());
* }
*/
export async function useAgApi(): Promise<AgsApi> {
return new AgsApi(await useApiConfig())
}

export async function useMediumApi(): Promise<MediumsApi> {
return new MediumsApi(await useApiConfig())
}
35 changes: 35 additions & 0 deletions src/mafiasi_kultur_gui/pages/ag/[[id]]/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script lang="ts" setup>
import type {AG, MediumViewset} from "~/utils/apiClient";
definePageMeta({
name: "ag_index",
middleware: ["authenticated"],
})
const route = useRoute();
const agApi = await useAgApi();
const mediumApi = await useMediumApi();
const ag = ref<AG | null>(null);
const proposals = ref<MediumViewset[]>([]);
onMounted(async () => {
ag.value = await agApi.agsRetrieve({
id: route.params.id as string
})
proposals.value = await Promise.all(
ag.value.openProposals.map((id) => mediumApi.mediumsRetrieve({
id: id,
}))
)
})
</script>

<template>
<div v-if="ag !== null">
<h1>{{ ag.name }}</h1>
<h2>Proposals</h2>
<ul>
<li v-for="proposal in proposals">{{ proposal.name }} (proposed by {{ proposal.proposal.proposedBy }})</li>
</ul>
</div>
</template>
19 changes: 17 additions & 2 deletions src/mafiasi_kultur_gui/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
<script lang="ts" setup>
import {useAgApi} from "~/composables/api";
import type {AG} from "~/utils/apiClient";
definePageMeta({
name: "index"
name: "index",
middleware: ["authenticated"],
})
useSeoMeta({
title: "Mafiasi Kulturgenießer"
})
const agApi = await useAgApi();
const ags = ref<AG[]>([]);
onMounted(async () => {
ags.value = await agApi.agsList();
});
</script>

<template>
<div>
<h1 class="text-xl">Congratulations, you've got a Mafiasi App up and running</h1>
<ul>
<li v-for="ag in ags">
<NuxtLink :to="{ name: 'ag_index', params: { id: ag.id } }">{{ ag.name }}</NuxtLink>
</li>
</ul>
</div>
</template>
23 changes: 23 additions & 0 deletions src/mafiasi_kultur_gui/utils/apiClient/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
12 changes: 12 additions & 0 deletions src/mafiasi_kultur_gui/utils/apiClient/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.openapi-generator-ignore
apis/AgsApi.ts
apis/MediumsApi.ts
apis/index.ts
index.ts
models/AG.ts
models/CastVoteRequest.ts
models/MediumViewset.ts
models/Proposal.ts
models/Viewing.ts
models/index.ts
runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0
86 changes: 86 additions & 0 deletions src/mafiasi_kultur_gui/utils/apiClient/apis/AgsApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* tslint:disable */
/* eslint-disable */
/**
* Mafiasi Kulturgenießer API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';
import type {
AG,
} from '../models/index';
import {
AGFromJSON,
AGToJSON,
} from '../models/index';

export interface AgsRetrieveRequest {
id: string;
}

/**
*
*/
export class AgsApi extends runtime.BaseAPI {

/**
*/
async agsListRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<AG>>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/api/ags/`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(AGFromJSON));
}

/**
*/
async agsList(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<AG>> {
const response = await this.agsListRaw(initOverrides);
return await response.value();
}

/**
*/
async agsRetrieveRaw(requestParameters: AgsRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AG>> {
if (requestParameters.id === null || requestParameters.id === undefined) {
throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling agsRetrieve.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/api/ags/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => AGFromJSON(jsonValue));
}

/**
*/
async agsRetrieve(requestParameters: AgsRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AG> {
const response = await this.agsRetrieveRaw(requestParameters, initOverrides);
return await response.value();
}

}
142 changes: 142 additions & 0 deletions src/mafiasi_kultur_gui/utils/apiClient/apis/MediumsApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/* tslint:disable */
/* eslint-disable */
/**
* Mafiasi Kulturgenießer API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';
import type {
CastVoteRequest,
MediumViewset,
} from '../models/index';
import {
CastVoteRequestFromJSON,
CastVoteRequestToJSON,
MediumViewsetFromJSON,
MediumViewsetToJSON,
} from '../models/index';

export interface MediumsCastVoteCreateRequest {
id: string;
castVoteRequest: CastVoteRequest;
}

export interface MediumsListRequest {
ag?: string;
unvotedOnly?: boolean;
}

export interface MediumsRetrieveRequest {
id: string;
}

/**
*
*/
export class MediumsApi extends runtime.BaseAPI {

/**
*/
async mediumsCastVoteCreateRaw(requestParameters: MediumsCastVoteCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MediumViewset>> {
if (requestParameters.id === null || requestParameters.id === undefined) {
throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling mediumsCastVoteCreate.');
}

if (requestParameters.castVoteRequest === null || requestParameters.castVoteRequest === undefined) {
throw new runtime.RequiredError('castVoteRequest','Required parameter requestParameters.castVoteRequest was null or undefined when calling mediumsCastVoteCreate.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

headerParameters['Content-Type'] = 'application/json';

const response = await this.request({
path: `/api/mediums/{id}/cast_vote/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: CastVoteRequestToJSON(requestParameters.castVoteRequest),
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => MediumViewsetFromJSON(jsonValue));
}

/**
*/
async mediumsCastVoteCreate(requestParameters: MediumsCastVoteCreateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MediumViewset> {
const response = await this.mediumsCastVoteCreateRaw(requestParameters, initOverrides);
return await response.value();
}

/**
*/
async mediumsListRaw(requestParameters: MediumsListRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<MediumViewset>>> {
const queryParameters: any = {};

if (requestParameters.ag !== undefined) {
queryParameters['ag'] = requestParameters.ag;
}

if (requestParameters.unvotedOnly !== undefined) {
queryParameters['unvoted_only'] = requestParameters.unvotedOnly;
}

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/api/mediums/`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(MediumViewsetFromJSON));
}

/**
*/
async mediumsList(requestParameters: MediumsListRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<MediumViewset>> {
const response = await this.mediumsListRaw(requestParameters, initOverrides);
return await response.value();
}

/**
*/
async mediumsRetrieveRaw(requestParameters: MediumsRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MediumViewset>> {
if (requestParameters.id === null || requestParameters.id === undefined) {
throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling mediumsRetrieve.');
}

const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/api/mediums/{id}/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => MediumViewsetFromJSON(jsonValue));
}

/**
*/
async mediumsRetrieve(requestParameters: MediumsRetrieveRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MediumViewset> {
const response = await this.mediumsRetrieveRaw(requestParameters, initOverrides);
return await response.value();
}

}
4 changes: 4 additions & 0 deletions src/mafiasi_kultur_gui/utils/apiClient/apis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* tslint:disable */
/* eslint-disable */
export * from './AgsApi';
export * from './MediumsApi';
5 changes: 5 additions & 0 deletions src/mafiasi_kultur_gui/utils/apiClient/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* tslint:disable */
/* eslint-disable */
export * from './runtime';
export * from './apis/index';
export * from './models/index';
Loading

0 comments on commit c892c70

Please sign in to comment.