From 981c64ac210c3350cf87797f731e8f013f1b913b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20G=C3=B6bel?= <dgoebel@techfak.uni-bielefeld.de>
Date: Wed, 27 Jul 2022 14:50:53 +0200
Subject: [PATCH] Update API Client and deactivate closing modal with js

#5
---
 src/client/core/OpenAPI.ts                    |  2 +-
 src/client/models/BucketOut.ts                |  2 +-
 src/client/models/BucketPermission.ts         |  4 +-
 src/client/models/S3Key.ts                    |  2 +-
 src/client/models/User.ts                     |  4 --
 .../services/BucketPermissionsService.ts      | 32 +++++++-------
 src/client/services/KeyService.ts             | 32 +++++++-------
 src/client/services/UserService.ts            | 44 +++++++++----------
 src/components/CreateBucketComponent.vue      | 13 ++++--
 9 files changed, 68 insertions(+), 67 deletions(-)

diff --git a/src/client/core/OpenAPI.ts b/src/client/core/OpenAPI.ts
index 4ca423b..d4685b4 100644
--- a/src/client/core/OpenAPI.ts
+++ b/src/client/core/OpenAPI.ts
@@ -19,7 +19,7 @@ export type OpenAPIConfig = {
 };
 
 export const OpenAPI: OpenAPIConfig = {
-    BASE: import.meta.env.VITE_API_BASE_URL != null ? import.meta.env.VITE_API_BASE_URL : 'http://localhost:9999/api',
+    BASE: '/api',
     VERSION: '1.0.0',
     WITH_CREDENTIALS: false,
     CREDENTIALS: 'include',
diff --git a/src/client/models/BucketOut.ts b/src/client/models/BucketOut.ts
index d3c6851..b1bb787 100644
--- a/src/client/models/BucketOut.ts
+++ b/src/client/models/BucketOut.ts
@@ -19,7 +19,7 @@ export type BucketOut = {
      */
     created_at: string;
     /**
-     * Username of the owner
+     * UID of the owner
      */
     owner: string;
 };
diff --git a/src/client/models/BucketPermission.ts b/src/client/models/BucketPermission.ts
index 7867959..32d7d00 100644
--- a/src/client/models/BucketPermission.ts
+++ b/src/client/models/BucketPermission.ts
@@ -25,9 +25,9 @@ export type BucketPermission = {
      */
     permission?: (PermissionEnum | string);
     /**
-     * Name of User
+     * UID of the grantee
      */
-    username: string;
+    uid: string;
     /**
      * Name of Bucket
      */
diff --git a/src/client/models/S3Key.ts b/src/client/models/S3Key.ts
index 5b3d790..5a1aa25 100644
--- a/src/client/models/S3Key.ts
+++ b/src/client/models/S3Key.ts
@@ -7,7 +7,7 @@
  */
 export type S3Key = {
     /**
-     * Username of the user of that access key
+     * UID of the user of that access key
      */
     user: string;
     /**
diff --git a/src/client/models/User.ts b/src/client/models/User.ts
index 58137cd..0af7691 100644
--- a/src/client/models/User.ts
+++ b/src/client/models/User.ts
@@ -10,10 +10,6 @@ export type User = {
      * ID of the user
      */
     uid: string;
-    /**
-     * Username of the user
-     */
-    username: string;
     /**
      * Full Name of the user
      */
diff --git a/src/client/services/BucketPermissionsService.ts b/src/client/services/BucketPermissionsService.ts
index 871549b..5fbf147 100644
--- a/src/client/services/BucketPermissionsService.ts
+++ b/src/client/services/BucketPermissionsService.ts
@@ -17,20 +17,20 @@ export class BucketPermissionsService {
      * The owner of the bucket and the grantee of the permission can view it.
      *
      * @param bucketName Name of bucket
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns BucketPermission Successful Response
      * @throws ApiError
      */
     public static bucketPermissionsGetPermissionForBucket(
         bucketName: string,
-        username: string,
+        uid: string,
     ): CancelablePromise<BucketPermission> {
         return __request(OpenAPI, {
             method: 'GET',
-            url: '/permissions/bucket/{bucket_name}/user/{username}',
+            url: '/permissions/bucket/{bucket_name}/user/{uid}',
             path: {
                 'bucket_name': bucketName,
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -45,22 +45,22 @@ export class BucketPermissionsService {
      * Update a bucket permission
      * Update a permission for a bucket and user.
      *
-     * @param username Username of a user
+     * @param uid UID of a user
      * @param bucketName Name of bucket
      * @param requestBody
      * @returns BucketPermission Successful Response
      * @throws ApiError
      */
     public static bucketPermissionsUpdatePermission(
-        username: string,
+        uid: string,
         bucketName: string,
         requestBody: BucketPermissionParameters,
     ): CancelablePromise<BucketPermission> {
         return __request(OpenAPI, {
             method: 'PUT',
-            url: '/permissions/bucket/{bucket_name}/user/{username}',
+            url: '/permissions/bucket/{bucket_name}/user/{uid}',
             path: {
-                'username': username,
+                'uid': uid,
                 'bucket_name': bucketName,
             },
             body: requestBody,
@@ -81,20 +81,20 @@ export class BucketPermissionsService {
      * The owner of the bucket and the grantee of the permission can delete it.
      *
      * @param bucketName Name of bucket
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns void
      * @throws ApiError
      */
     public static bucketPermissionsDeletePermissionForBucket(
         bucketName: string,
-        username: string,
+        uid: string,
     ): CancelablePromise<void> {
         return __request(OpenAPI, {
             method: 'DELETE',
-            url: '/permissions/bucket/{bucket_name}/user/{username}',
+            url: '/permissions/bucket/{bucket_name}/user/{uid}',
             path: {
                 'bucket_name': bucketName,
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -135,18 +135,18 @@ export class BucketPermissionsService {
      * Get all permissions for a user.
      * List all the bucket permissions for the given user.
      *
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns BucketPermission Successful Response
      * @throws ApiError
      */
     public static bucketPermissionsListPermissionsPerUser(
-        username: string,
+        uid: string,
     ): CancelablePromise<Array<BucketPermission>> {
         return __request(OpenAPI, {
             method: 'GET',
-            url: '/permissions/user/{username}',
+            url: '/permissions/user/{uid}',
             path: {
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
diff --git a/src/client/services/KeyService.ts b/src/client/services/KeyService.ts
index 6f69578..26e68c0 100644
--- a/src/client/services/KeyService.ts
+++ b/src/client/services/KeyService.ts
@@ -13,18 +13,18 @@ export class KeyService {
      * Get the S3 Access keys from a user
      * Get all the S3 Access keys for a specific user.
      *
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns S3Key Successful Response
      * @throws ApiError
      */
     public static keyGetUserKeys(
-        username: string,
+        uid: string,
     ): CancelablePromise<Array<S3Key>> {
         return __request(OpenAPI, {
             method: 'GET',
-            url: '/users/{username}/keys',
+            url: '/users/{uid}/keys',
             path: {
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -39,18 +39,18 @@ export class KeyService {
      * Create a Access key for a user
      * Create a S3 Access key for a specific user.
      *
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns S3Key Successful Response
      * @throws ApiError
      */
     public static keyCreateUserKey(
-        username: string,
+        uid: string,
     ): CancelablePromise<S3Key> {
         return __request(OpenAPI, {
             method: 'POST',
-            url: '/users/{username}/keys',
+            url: '/users/{uid}/keys',
             path: {
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -66,20 +66,20 @@ export class KeyService {
      * Get a specific S3 Access Key for a specific user.
      *
      * @param accessId ID of the S3 access key
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns S3Key Successful Response
      * @throws ApiError
      */
     public static keyGetUserKey(
         accessId: string,
-        username: string,
+        uid: string,
     ): CancelablePromise<S3Key> {
         return __request(OpenAPI, {
             method: 'GET',
-            url: '/users/{username}/keys/{access_id}',
+            url: '/users/{uid}/keys/{access_id}',
             path: {
                 'access_id': accessId,
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -95,20 +95,20 @@ export class KeyService {
      * Delete a specific S3 Access key for a specific user.
      *
      * @param accessId ID of the S3 access key
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns void
      * @throws ApiError
      */
     public static keyDeleteUserKey(
         accessId: string,
-        username: string,
+        uid: string,
     ): CancelablePromise<void> {
         return __request(OpenAPI, {
             method: 'DELETE',
-            url: '/users/{username}/keys/{access_id}',
+            url: '/users/{uid}/keys/{access_id}',
             path: {
                 'access_id': accessId,
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
diff --git a/src/client/services/UserService.ts b/src/client/services/UserService.ts
index fd37cb6..8a14675 100644
--- a/src/client/services/UserService.ts
+++ b/src/client/services/UserService.ts
@@ -30,21 +30,21 @@ export class UserService {
     }
 
     /**
-     * Get a user by its username
-     * Return the user with the specific username. A user can only view himself.
+     * Get a user by its uid
+     * Return the user with the specific uid. A user can only view himself.
      *
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns User Successful Response
      * @throws ApiError
      */
     public static userGetUser(
-        username: string,
+        uid: string,
     ): CancelablePromise<User> {
         return __request(OpenAPI, {
             method: 'GET',
-            url: '/users/{username}',
+            url: '/users/{uid}',
             path: {
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -59,18 +59,18 @@ export class UserService {
      * Get the S3 Access keys from a user
      * Get all the S3 Access keys for a specific user.
      *
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns S3Key Successful Response
      * @throws ApiError
      */
     public static keyGetUserKeys(
-        username: string,
+        uid: string,
     ): CancelablePromise<Array<S3Key>> {
         return __request(OpenAPI, {
             method: 'GET',
-            url: '/users/{username}/keys',
+            url: '/users/{uid}/keys',
             path: {
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -85,18 +85,18 @@ export class UserService {
      * Create a Access key for a user
      * Create a S3 Access key for a specific user.
      *
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns S3Key Successful Response
      * @throws ApiError
      */
     public static keyCreateUserKey(
-        username: string,
+        uid: string,
     ): CancelablePromise<S3Key> {
         return __request(OpenAPI, {
             method: 'POST',
-            url: '/users/{username}/keys',
+            url: '/users/{uid}/keys',
             path: {
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -112,20 +112,20 @@ export class UserService {
      * Get a specific S3 Access Key for a specific user.
      *
      * @param accessId ID of the S3 access key
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns S3Key Successful Response
      * @throws ApiError
      */
     public static keyGetUserKey(
         accessId: string,
-        username: string,
+        uid: string,
     ): CancelablePromise<S3Key> {
         return __request(OpenAPI, {
             method: 'GET',
-            url: '/users/{username}/keys/{access_id}',
+            url: '/users/{uid}/keys/{access_id}',
             path: {
                 'access_id': accessId,
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
@@ -141,20 +141,20 @@ export class UserService {
      * Delete a specific S3 Access key for a specific user.
      *
      * @param accessId ID of the S3 access key
-     * @param username Username of a user
+     * @param uid UID of a user
      * @returns void
      * @throws ApiError
      */
     public static keyDeleteUserKey(
         accessId: string,
-        username: string,
+        uid: string,
     ): CancelablePromise<void> {
         return __request(OpenAPI, {
             method: 'DELETE',
-            url: '/users/{username}/keys/{access_id}',
+            url: '/users/{uid}/keys/{access_id}',
             path: {
                 'access_id': accessId,
-                'username': username,
+                'uid': uid,
             },
             errors: {
                 400: `Error decoding JWT Token`,
diff --git a/src/components/CreateBucketComponent.vue b/src/components/CreateBucketComponent.vue
index c0c2185..da0a506 100644
--- a/src/components/CreateBucketComponent.vue
+++ b/src/components/CreateBucketComponent.vue
@@ -1,9 +1,11 @@
 <script setup lang="ts">
 import { BucketService } from "@/client";
 import type { BucketIn } from "@/client";
-import { reactive, ref } from "vue";
+import { reactive } from "vue";
+/*
 import { onMounted } from "vue";
 import { Modal } from "bootstrap";
+*/
 
 const emit = defineEmits(["bucketCreated"]);
 const bucket = reactive({ name: "", description: "" } as BucketIn);
@@ -16,18 +18,21 @@ const formState = reactive({
   bucketNameTaken: boolean;
   loading: boolean;
 });
-let theModal: Modal | null = null;
-const modal = ref(null as Element | null);
 
 defineProps<{
   modalid: string;
   modallabel: string;
 }>();
 
+/*
+let theModal: Modal | null = null;
+const modal = ref(null as Element | null);
+
 onMounted(() => {
   // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
   theModal = Modal.getOrCreateInstance(modal.value!);
 });
+ */
 
 function createBucket() {
   formState.validated = true;
@@ -39,7 +44,7 @@ function createBucket() {
     BucketService.bucketCreateBucket(bucket)
       .then((createdBucket) => {
         emit("bucketCreated", createdBucket);
-        console.log(theModal);
+        //console.log(theModal);
         //theModal?.hide();
         bucket.name = "";
         bucket.description = "";
-- 
GitLab