diff --git a/backend/metadata/databases/default/tables/public_AppSettings.yaml b/backend/metadata/databases/default/tables/public_AppSettings.yaml index 6942c2288..2d26b290c 100644 --- a/backend/metadata/databases/default/tables/public_AppSettings.yaml +++ b/backend/metadata/databases/default/tables/public_AppSettings.yaml @@ -5,13 +5,13 @@ select_permissions: - role: anonymous permission: columns: - - id - - created_at - - updated_at + - appName + - backgroundImageURL - bannerBackgroundColor - - bannerTextEn - bannerFontColor - bannerTextDe - - backgroundImageURL + - bannerTextEn + - created_at - previewImageURL + - updated_at filter: {} diff --git a/backend/metadata/databases/default/tables/public_User.yaml b/backend/metadata/databases/default/tables/public_User.yaml index dd77eb480..b5a1c2423 100644 --- a/backend/metadata/databases/default/tables/public_User.yaml +++ b/backend/metadata/databases/default/tables/public_User.yaml @@ -2,6 +2,9 @@ table: name: User schema: public object_relationships: + - name: UserStatus + using: + foreign_key_constraint_on: status - name: employmentByEmployment using: foreign_key_constraint_on: employment diff --git a/backend/metadata/databases/default/tables/public_UserStatus.yaml b/backend/metadata/databases/default/tables/public_UserStatus.yaml new file mode 100644 index 000000000..2cdcf8107 --- /dev/null +++ b/backend/metadata/databases/default/tables/public_UserStatus.yaml @@ -0,0 +1,12 @@ +table: + name: UserStatus + schema: public +is_enum: true +array_relationships: + - name: Users + using: + foreign_key_constraint_on: + column: status + table: + name: User + schema: public diff --git a/backend/metadata/databases/default/tables/tables.yaml b/backend/metadata/databases/default/tables/tables.yaml index 71588bb6b..850ba8773 100644 --- a/backend/metadata/databases/default/tables/tables.yaml +++ b/backend/metadata/databases/default/tables/tables.yaml @@ -34,6 +34,7 @@ - "!include public_SessionSpeaker.yaml" - "!include public_University.yaml" - "!include public_User.yaml" +- "!include public_UserStatus.yaml" - "!include public_Weekday.yaml" - "!include rentAScientist_RentAScientistConfig.yaml" - "!include rentAScientist_School.yaml" diff --git a/backend/migrations/default/1697138898623_alter_table_public_AppSettings_add_column_app/down.sql b/backend/migrations/default/1697138898623_alter_table_public_AppSettings_add_column_app/down.sql new file mode 100644 index 000000000..2d7030472 --- /dev/null +++ b/backend/migrations/default/1697138898623_alter_table_public_AppSettings_add_column_app/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."AppSettings" add column "app" text +-- not null unique; diff --git a/backend/migrations/default/1697138898623_alter_table_public_AppSettings_add_column_app/up.sql b/backend/migrations/default/1697138898623_alter_table_public_AppSettings_add_column_app/up.sql new file mode 100644 index 000000000..08fdd1a08 --- /dev/null +++ b/backend/migrations/default/1697138898623_alter_table_public_AppSettings_add_column_app/up.sql @@ -0,0 +1,2 @@ +alter table "public"."AppSettings" add column "app" text + not null unique; diff --git a/backend/migrations/default/1697138989558_alter_table_public_AppSettings_alter_column_app/down.sql b/backend/migrations/default/1697138989558_alter_table_public_AppSettings_alter_column_app/down.sql new file mode 100644 index 000000000..5113cdc4a --- /dev/null +++ b/backend/migrations/default/1697138989558_alter_table_public_AppSettings_alter_column_app/down.sql @@ -0,0 +1,2 @@ +alter table "public"."AppSettings" rename column "appName" to "app"; +comment on column "public"."AppSettings"."app" is NULL; diff --git a/backend/migrations/default/1697138989558_alter_table_public_AppSettings_alter_column_app/up.sql b/backend/migrations/default/1697138989558_alter_table_public_AppSettings_alter_column_app/up.sql new file mode 100644 index 000000000..86cdf9b55 --- /dev/null +++ b/backend/migrations/default/1697138989558_alter_table_public_AppSettings_alter_column_app/up.sql @@ -0,0 +1,2 @@ +comment on column "public"."AppSettings"."app" is E'Name of the app to which the given settings are applied'; +alter table "public"."AppSettings" rename column "app" to "appName"; diff --git a/backend/migrations/default/1697139203652_insert_into_public_AppSettings/down.sql b/backend/migrations/default/1697139203652_insert_into_public_AppSettings/down.sql new file mode 100644 index 000000000..fced04ed8 --- /dev/null +++ b/backend/migrations/default/1697139203652_insert_into_public_AppSettings/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- INSERT INTO "public"."AppSettings" ("appName", "bannerBackgroundColor", "bannerFontColor", "bannerTextDe", "bannerTextEn") +-- VALUES (E'edu', DEFAULT, DEFAULT, DEFAULT, DEFAULT); diff --git a/backend/migrations/default/1697139203652_insert_into_public_AppSettings/up.sql b/backend/migrations/default/1697139203652_insert_into_public_AppSettings/up.sql new file mode 100644 index 000000000..4ad4457dc --- /dev/null +++ b/backend/migrations/default/1697139203652_insert_into_public_AppSettings/up.sql @@ -0,0 +1,2 @@ +INSERT INTO "public"."AppSettings" ("appName", "bannerBackgroundColor", "bannerFontColor", "bannerTextDe", "bannerTextEn") +VALUES (E'edu', DEFAULT, DEFAULT, DEFAULT, DEFAULT); diff --git a/backend/migrations/default/1697197135225_alter_table_public_User_add_column_status/down.sql b/backend/migrations/default/1697197135225_alter_table_public_User_add_column_status/down.sql new file mode 100644 index 000000000..98f49bd17 --- /dev/null +++ b/backend/migrations/default/1697197135225_alter_table_public_User_add_column_status/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."User" add column "status" text +-- not null default 'ACTIVE'; diff --git a/backend/migrations/default/1697197135225_alter_table_public_User_add_column_status/up.sql b/backend/migrations/default/1697197135225_alter_table_public_User_add_column_status/up.sql new file mode 100644 index 000000000..c43bfc309 --- /dev/null +++ b/backend/migrations/default/1697197135225_alter_table_public_User_add_column_status/up.sql @@ -0,0 +1,2 @@ +alter table "public"."User" add column "status" text + not null default 'ACTIVE'; diff --git a/backend/migrations/default/1697197171509_alter_table_public_User_alter_column_status/down.sql b/backend/migrations/default/1697197171509_alter_table_public_User_alter_column_status/down.sql new file mode 100644 index 000000000..b1f02ad4a --- /dev/null +++ b/backend/migrations/default/1697197171509_alter_table_public_User_alter_column_status/down.sql @@ -0,0 +1 @@ +comment on column "public"."User"."status" is NULL; diff --git a/backend/migrations/default/1697197171509_alter_table_public_User_alter_column_status/up.sql b/backend/migrations/default/1697197171509_alter_table_public_User_alter_column_status/up.sql new file mode 100644 index 000000000..c4a606f9b --- /dev/null +++ b/backend/migrations/default/1697197171509_alter_table_public_User_alter_column_status/up.sql @@ -0,0 +1 @@ +comment on column "public"."User"."status" is E'Current user status'; diff --git a/backend/migrations/default/1697197428451_create_table_public_UserStatus/down.sql b/backend/migrations/default/1697197428451_create_table_public_UserStatus/down.sql new file mode 100644 index 000000000..c2886e00d --- /dev/null +++ b/backend/migrations/default/1697197428451_create_table_public_UserStatus/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."UserStatus"; diff --git a/backend/migrations/default/1697197428451_create_table_public_UserStatus/up.sql b/backend/migrations/default/1697197428451_create_table_public_UserStatus/up.sql new file mode 100644 index 000000000..a924b1112 --- /dev/null +++ b/backend/migrations/default/1697197428451_create_table_public_UserStatus/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."UserStatus" ("value" text NOT NULL, "comment" text NOT NULL, PRIMARY KEY ("value") , UNIQUE ("value"));COMMENT ON TABLE "public"."UserStatus" IS E'Possible activity status of a user'; diff --git a/backend/migrations/default/1697197498958_insert_into_public_UserStatus/down.sql b/backend/migrations/default/1697197498958_insert_into_public_UserStatus/down.sql new file mode 100644 index 000000000..bca72538a --- /dev/null +++ b/backend/migrations/default/1697197498958_insert_into_public_UserStatus/down.sql @@ -0,0 +1 @@ +DELETE FROM "public"."UserStatus" WHERE "value" = 'ACTIVE'; diff --git a/backend/migrations/default/1697197498958_insert_into_public_UserStatus/up.sql b/backend/migrations/default/1697197498958_insert_into_public_UserStatus/up.sql new file mode 100644 index 000000000..2d02b8999 --- /dev/null +++ b/backend/migrations/default/1697197498958_insert_into_public_UserStatus/up.sql @@ -0,0 +1 @@ +INSERT INTO "public"."UserStatus"("value", "comment") VALUES (E'ACTIVE', E'User is active'); diff --git a/backend/migrations/default/1697197543892_insert_into_public_UserStatus/down.sql b/backend/migrations/default/1697197543892_insert_into_public_UserStatus/down.sql new file mode 100644 index 000000000..380f4994c --- /dev/null +++ b/backend/migrations/default/1697197543892_insert_into_public_UserStatus/down.sql @@ -0,0 +1 @@ +DELETE FROM "public"."UserStatus" WHERE "value" = 'INACTIVE'; diff --git a/backend/migrations/default/1697197543892_insert_into_public_UserStatus/up.sql b/backend/migrations/default/1697197543892_insert_into_public_UserStatus/up.sql new file mode 100644 index 000000000..ccbd165ed --- /dev/null +++ b/backend/migrations/default/1697197543892_insert_into_public_UserStatus/up.sql @@ -0,0 +1 @@ +INSERT INTO "public"."UserStatus"("value", "comment") VALUES (E'INACTIVE', E'User did not show any activity on the platform for more than 12 month (currently not implemented)'); diff --git a/backend/migrations/default/1697197617230_insert_into_public_UserStatus/down.sql b/backend/migrations/default/1697197617230_insert_into_public_UserStatus/down.sql new file mode 100644 index 000000000..d1d722095 --- /dev/null +++ b/backend/migrations/default/1697197617230_insert_into_public_UserStatus/down.sql @@ -0,0 +1 @@ +DELETE FROM "public"."UserStatus" WHERE "value" = 'DELETED'; diff --git a/backend/migrations/default/1697197617230_insert_into_public_UserStatus/up.sql b/backend/migrations/default/1697197617230_insert_into_public_UserStatus/up.sql new file mode 100644 index 000000000..fc829a835 --- /dev/null +++ b/backend/migrations/default/1697197617230_insert_into_public_UserStatus/up.sql @@ -0,0 +1 @@ +INSERT INTO "public"."UserStatus"("value", "comment") VALUES (E'DELETED', E'All private information considering these user is deleted).'); diff --git a/backend/migrations/default/1697197640210_insert_into_public_UserStatus/down.sql b/backend/migrations/default/1697197640210_insert_into_public_UserStatus/down.sql new file mode 100644 index 000000000..6d898d314 --- /dev/null +++ b/backend/migrations/default/1697197640210_insert_into_public_UserStatus/down.sql @@ -0,0 +1 @@ +DELETE FROM "public"."UserStatus" WHERE "value" = 'SPAM'; diff --git a/backend/migrations/default/1697197640210_insert_into_public_UserStatus/up.sql b/backend/migrations/default/1697197640210_insert_into_public_UserStatus/up.sql new file mode 100644 index 000000000..d4bab16a1 --- /dev/null +++ b/backend/migrations/default/1697197640210_insert_into_public_UserStatus/up.sql @@ -0,0 +1 @@ +INSERT INTO "public"."UserStatus"("value", "comment") VALUES (E'SPAM', E'The user is classified as SPAM.'); diff --git a/backend/migrations/default/1697197720085_set_fk_public_User_status/down.sql b/backend/migrations/default/1697197720085_set_fk_public_User_status/down.sql new file mode 100644 index 000000000..29f2c6976 --- /dev/null +++ b/backend/migrations/default/1697197720085_set_fk_public_User_status/down.sql @@ -0,0 +1 @@ +alter table "public"."User" drop constraint "User_status_fkey"; diff --git a/backend/migrations/default/1697197720085_set_fk_public_User_status/up.sql b/backend/migrations/default/1697197720085_set_fk_public_User_status/up.sql new file mode 100644 index 000000000..418d493ac --- /dev/null +++ b/backend/migrations/default/1697197720085_set_fk_public_User_status/up.sql @@ -0,0 +1,5 @@ +alter table "public"."User" + add constraint "User_status_fkey" + foreign key ("status") + references "public"."UserStatus" + ("value") on update restrict on delete restrict; diff --git a/backend/migrations/default/1697662588510_modify_primarykey_public_AppSettings/down.sql b/backend/migrations/default/1697662588510_modify_primarykey_public_AppSettings/down.sql new file mode 100644 index 000000000..9410b8b98 --- /dev/null +++ b/backend/migrations/default/1697662588510_modify_primarykey_public_AppSettings/down.sql @@ -0,0 +1,4 @@ +alter table "public"."AppSettings" drop constraint "AppSettings_pkey"; +alter table "public"."AppSettings" + add constraint "AppSettings_pkey" + primary key ("id"); diff --git a/backend/migrations/default/1697662588510_modify_primarykey_public_AppSettings/up.sql b/backend/migrations/default/1697662588510_modify_primarykey_public_AppSettings/up.sql new file mode 100644 index 000000000..63311b2d5 --- /dev/null +++ b/backend/migrations/default/1697662588510_modify_primarykey_public_AppSettings/up.sql @@ -0,0 +1,6 @@ +BEGIN TRANSACTION; +ALTER TABLE "public"."AppSettings" DROP CONSTRAINT "AppSettings_pkey"; + +ALTER TABLE "public"."AppSettings" + ADD CONSTRAINT "AppSettings_pkey" PRIMARY KEY ("id", "appName"); +COMMIT TRANSACTION; diff --git a/backend/migrations/default/1697662666960_modify_primarykey_public_AppSettings/down.sql b/backend/migrations/default/1697662666960_modify_primarykey_public_AppSettings/down.sql new file mode 100644 index 000000000..dc045178d --- /dev/null +++ b/backend/migrations/default/1697662666960_modify_primarykey_public_AppSettings/down.sql @@ -0,0 +1,4 @@ +alter table "public"."AppSettings" drop constraint "AppSettings_pkey"; +alter table "public"."AppSettings" + add constraint "AppSettings_pkey" + primary key ("id", "appName"); diff --git a/backend/migrations/default/1697662666960_modify_primarykey_public_AppSettings/up.sql b/backend/migrations/default/1697662666960_modify_primarykey_public_AppSettings/up.sql new file mode 100644 index 000000000..a36b1faf1 --- /dev/null +++ b/backend/migrations/default/1697662666960_modify_primarykey_public_AppSettings/up.sql @@ -0,0 +1,6 @@ +BEGIN TRANSACTION; +ALTER TABLE "public"."AppSettings" DROP CONSTRAINT "AppSettings_pkey"; + +ALTER TABLE "public"."AppSettings" + ADD CONSTRAINT "AppSettings_pkey" PRIMARY KEY ("appName"); +COMMIT TRANSACTION; diff --git a/backend/migrations/default/1697662921271_alter_table_public_AppSettings_drop_column_id/down.sql b/backend/migrations/default/1697662921271_alter_table_public_AppSettings_drop_column_id/down.sql new file mode 100644 index 000000000..79c0b3416 --- /dev/null +++ b/backend/migrations/default/1697662921271_alter_table_public_AppSettings_drop_column_id/down.sql @@ -0,0 +1,4 @@ +comment on column "public"."AppSettings"."id" is E'To store characteristics on the app level.'; +alter table "public"."AppSettings" alter column "id" set default nextval('"AppSettings_id_seq"'::regclass); +alter table "public"."AppSettings" alter column "id" drop not null; +alter table "public"."AppSettings" add column "id" int4; diff --git a/backend/migrations/default/1697662921271_alter_table_public_AppSettings_drop_column_id/up.sql b/backend/migrations/default/1697662921271_alter_table_public_AppSettings_drop_column_id/up.sql new file mode 100644 index 000000000..9816f5766 --- /dev/null +++ b/backend/migrations/default/1697662921271_alter_table_public_AppSettings_drop_column_id/up.sql @@ -0,0 +1 @@ +alter table "public"."AppSettings" drop column "id" cascade; diff --git a/frontend-nx/apps/edu-hub/__generated__/globalTypes.ts b/frontend-nx/apps/edu-hub/__generated__/globalTypes.ts index 4b3f9a9f0..94e6d4953 100644 --- a/frontend-nx/apps/edu-hub/__generated__/globalTypes.ts +++ b/frontend-nx/apps/edu-hub/__generated__/globalTypes.ts @@ -1217,6 +1217,28 @@ export enum University_update_column { value = "value", } +/** + * unique or primary key constraints on table "UserStatus" + */ +export enum UserStatus_constraint { + UserStatus_pkey = "UserStatus_pkey", +} + +export enum UserStatus_enum { + ACTIVE = "ACTIVE", + DELETED = "DELETED", + INACTIVE = "INACTIVE", + SPAM = "SPAM", +} + +/** + * update columns of table "UserStatus" + */ +export enum UserStatus_update_column { + comment = "comment", + value = "value", +} + /** * unique or primary key constraints on table "User" */ @@ -1241,6 +1263,7 @@ export enum User_select_column { newsletterRegistration = "newsletterRegistration", otherUniversity = "otherUniversity", picture = "picture", + status = "status", university = "university", updated_at = "updated_at", } @@ -1275,6 +1298,7 @@ export enum User_update_column { newsletterRegistration = "newsletterRegistration", otherUniversity = "otherUniversity", picture = "picture", + status = "status", university = "university", updated_at = "updated_at", } @@ -6030,6 +6054,65 @@ export interface University_order_by { value?: order_by | null; } +/** + * Boolean expression to filter rows from the table "UserStatus". All fields are combined with a logical 'AND'. + */ +export interface UserStatus_bool_exp { + Users?: User_bool_exp | null; + Users_aggregate?: User_aggregate_bool_exp | null; + _and?: UserStatus_bool_exp[] | null; + _not?: UserStatus_bool_exp | null; + _or?: UserStatus_bool_exp[] | null; + comment?: String_comparison_exp | null; + value?: String_comparison_exp | null; +} + +/** + * Boolean expression to compare columns of type "UserStatus_enum". All fields are combined with logical 'AND'. + */ +export interface UserStatus_enum_comparison_exp { + _eq?: UserStatus_enum | null; + _in?: UserStatus_enum[] | null; + _is_null?: boolean | null; + _neq?: UserStatus_enum | null; + _nin?: UserStatus_enum[] | null; +} + +/** + * input type for inserting data into table "UserStatus" + */ +export interface UserStatus_insert_input { + Users?: User_arr_rel_insert_input | null; + comment?: string | null; + value?: string | null; +} + +/** + * input type for inserting object relation for remote table "UserStatus" + */ +export interface UserStatus_obj_rel_insert_input { + data: UserStatus_insert_input; + on_conflict?: UserStatus_on_conflict | null; +} + +/** + * on_conflict condition type for table "UserStatus" + */ +export interface UserStatus_on_conflict { + constraint: UserStatus_constraint; + update_columns: UserStatus_update_column[]; + where?: UserStatus_bool_exp | null; +} + +/** + * Ordering options when selecting data from "UserStatus". + */ +export interface UserStatus_order_by { + Users_aggregate?: User_aggregate_order_by | null; + comment?: order_by | null; + value?: order_by | null; +} + export interface User_aggregate_bool_exp { bool_and?: User_aggregate_bool_exp_bool_and | null; bool_or?: User_aggregate_bool_exp_bool_or | null; @@ -6090,6 +6173,7 @@ export interface User_bool_exp { CourseEnrollments_aggregate?: CourseEnrollment_aggregate_bool_exp | null; Experts?: Expert_bool_exp | null; Experts_aggregate?: Expert_aggregate_bool_exp | null; + UserStatus?: UserStatus_bool_exp | null; _and?: User_bool_exp[] | null; _not?: User_bool_exp | null; _or?: User_bool_exp[] | null; @@ -6106,6 +6190,7 @@ export interface User_bool_exp { newsletterRegistration?: Boolean_comparison_exp | null; otherUniversity?: String_comparison_exp | null; picture?: String_comparison_exp | null; + status?: UserStatus_enum_comparison_exp | null; university?: University_enum_comparison_exp | null; universityByUniversity?: University_bool_exp | null; updated_at?: timestamptz_comparison_exp | null; @@ -6121,6 +6206,7 @@ export interface User_insert_input { Attendances?: Attendance_arr_rel_insert_input | null; CourseEnrollments?: CourseEnrollment_arr_rel_insert_input | null; Experts?: Expert_arr_rel_insert_input | null; + UserStatus?: UserStatus_obj_rel_insert_input | null; anonymousId?: string | null; created_at?: any | null; email?: string | null; @@ -6134,6 +6220,7 @@ export interface User_insert_input { newsletterRegistration?: boolean | null; otherUniversity?: string | null; picture?: string | null; + status?: UserStatus_enum | null; university?: University_enum | null; universityByUniversity?: University_obj_rel_insert_input | null; updated_at?: any | null; @@ -6200,6 +6287,7 @@ export interface User_order_by { Attendances_aggregate?: Attendance_aggregate_order_by | null; CourseEnrollments_aggregate?: CourseEnrollment_aggregate_order_by | null; Experts_aggregate?: Expert_aggregate_order_by | null; + UserStatus?: UserStatus_order_by | null; anonymousId?: order_by | null; created_at?: order_by | null; email?: order_by | null; @@ -6213,6 +6301,7 @@ export interface User_order_by { newsletterRegistration?: order_by | null; otherUniversity?: order_by | null; picture?: order_by | null; + status?: order_by | null; university?: order_by | null; universityByUniversity?: University_order_by | null; updated_at?: order_by | null; diff --git a/frontend-nx/apps/edu-hub/components/ManageAppSettingsContent/ManageAppSettingsOverview.tsx b/frontend-nx/apps/edu-hub/components/ManageAppSettingsContent/ManageAppSettingsOverview.tsx index 849bb9321..380b9ef20 100644 --- a/frontend-nx/apps/edu-hub/components/ManageAppSettingsContent/ManageAppSettingsOverview.tsx +++ b/frontend-nx/apps/edu-hub/components/ManageAppSettingsContent/ManageAppSettingsOverview.tsx @@ -10,9 +10,8 @@ import { useAdminMutation } from '../../hooks/authedMutation'; import { useAdminQuery } from '../../hooks/authedQuery'; import { UpdateAppSettingsVariables, UpdateAppSettings } from '../../queries/__generated__/UpdateAppSettings'; -import { APP_SETTINGS, INSERT_APP_SETTINGS, UPDATE_APP_SETTINGS } from '../../queries/appSettings'; +import { APP_SETTINGS, UPDATE_APP_SETTINGS } from '../../queries/appSettings'; import { AppSettings } from '../../queries/__generated__/AppSettings'; -import { InsertAppSettings, InsertAppSettingsVariables } from '../../queries/__generated__/InsertAppSettings'; type Inputs = { // backgroundImageURL: string; @@ -49,8 +48,9 @@ const ManageAppSettingsOverview: FC = () => { error: appSettingsError, refetch: refetchAppSettings, } = useAdminQuery(APP_SETTINGS, { + variables: { appName: 'edu' }, onCompleted: (data) => { - const appSettings = data.AppSettings[0]; + const [appSettings] = data.AppSettings; // Using array destructuring to get the first item if (appSettings) { reset({ @@ -66,32 +66,19 @@ const ManageAppSettingsOverview: FC = () => { }); const [updateAppSettings] = useAdminMutation(UPDATE_APP_SETTINGS); - const [insertAppSettings] = useAdminMutation(INSERT_APP_SETTINGS); const onSubmit: SubmitHandler = async (data) => { try { - const variables = { - // backgroundImageURL: data.backgroundImageURL, - bannerBackgroundColor: data.bannerBackgroundColor, - bannerFontColor: data.bannerFontColor, - bannerTextDe: data.bannerTextDe, - bannerTextEn: data.bannerTextEn, - }; - - if (appSettingsData.AppSettings && appSettingsData.AppSettings[0]) { - await updateAppSettings({ - variables: { - ...variables, - id: appSettingsData.AppSettings[0].id, - }, - }); - } else { - await insertAppSettings({ - variables: { - ...variables, - }, - }); - } + await updateAppSettings({ + variables: { + appName: 'edu', + // backgroundImageURL: data.backgroundImageURL, + bannerBackgroundColor: data.bannerBackgroundColor, + bannerFontColor: data.bannerFontColor, + bannerTextDe: data.bannerTextDe, + bannerTextEn: data.bannerTextEn, + }, + }); refetchAppSettings(); await new Promise((resolve) => setTimeout(resolve, 1000)); @@ -139,10 +126,10 @@ const ManageAppSettingsOverview: FC = () => {
- label={t('manageAppSettings:bannerTextDe')} name="bannerTextDe" required /> + label={t('manageAppSettings:bannerTextDe')} name="bannerTextDe" />
- label={t('manageAppSettings:bannerTextEn')} name="bannerTextEn" required /> + label={t('manageAppSettings:bannerTextEn')} name="bannerTextEn" />
{/*
diff --git a/frontend-nx/apps/edu-hub/components/Page.tsx b/frontend-nx/apps/edu-hub/components/Page.tsx index 214672f96..7241470d8 100644 --- a/frontend-nx/apps/edu-hub/components/Page.tsx +++ b/frontend-nx/apps/edu-hub/components/Page.tsx @@ -43,9 +43,11 @@ export const Page: FC = ({ children, className }) => { loading: appSettingsLoading, error: appSettingsError, } = useRoleQuery(APP_SETTINGS, { + variables: { appName: 'edu' }, onCompleted: (data) => { - const appSettings = data.AppSettings[0]; - if (appSettings) { + const [appSettings] = data.AppSettings; // Using array destructuring to get the first item + + if (appSettings.bannerTextDe && appSettings.bannerTextEn) { if (lang === 'de') handleBanner('bannerContentDe', appSettings.bannerTextDe); else if (lang === 'en') handleBanner('bannerContentEn', appSettings.bannerTextEn); } diff --git a/frontend-nx/apps/edu-hub/queries/__generated__/AppSettings.ts b/frontend-nx/apps/edu-hub/queries/__generated__/AppSettings.ts index 25418c921..4a146dac5 100644 --- a/frontend-nx/apps/edu-hub/queries/__generated__/AppSettings.ts +++ b/frontend-nx/apps/edu-hub/queries/__generated__/AppSettings.ts @@ -9,10 +9,14 @@ export interface AppSettings_AppSettings { __typename: "AppSettings"; + /** + * Name of the app to which the given settings are applied + */ + appName: string; /** * Homepage background image */ - backgroundImageURL: string; + backgroundImageURL: string | null; /** * Background color for the dismissiable banner displayed on the homepage */ @@ -29,11 +33,10 @@ export interface AppSettings_AppSettings { * English version for the text of a dismissiable banner on the homepage */ bannerTextEn: string | null; - id: number; /** * Preview image that is shared with links */ - previewImageURL: string; + previewImageURL: string | null; } export interface AppSettings { @@ -42,3 +45,7 @@ export interface AppSettings { */ AppSettings: AppSettings_AppSettings[]; } + +export interface AppSettingsVariables { + appName: string; +} diff --git a/frontend-nx/apps/edu-hub/queries/__generated__/InsertAppSettings.ts b/frontend-nx/apps/edu-hub/queries/__generated__/InsertAppSettings.ts deleted file mode 100644 index d8695f1b3..000000000 --- a/frontend-nx/apps/edu-hub/queries/__generated__/InsertAppSettings.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL mutation operation: InsertAppSettings -// ==================================================== - -export interface InsertAppSettings_insert_AppSettings_one { - __typename: "AppSettings"; - id: number; -} - -export interface InsertAppSettings { - /** - * insert a single row into the table: "AppSettings" - */ - insert_AppSettings_one: InsertAppSettings_insert_AppSettings_one | null; -} - -export interface InsertAppSettingsVariables { - bannerBackgroundColor?: string | null; - bannerFontColor?: string | null; - bannerTextDe?: string | null; - bannerTextEn?: string | null; -} diff --git a/frontend-nx/apps/edu-hub/queries/__generated__/UpdateAppSettings.ts b/frontend-nx/apps/edu-hub/queries/__generated__/UpdateAppSettings.ts index d9a3a433f..d00fa4b09 100644 --- a/frontend-nx/apps/edu-hub/queries/__generated__/UpdateAppSettings.ts +++ b/frontend-nx/apps/edu-hub/queries/__generated__/UpdateAppSettings.ts @@ -9,6 +9,14 @@ export interface UpdateAppSettings_update_AppSettings_by_pk { __typename: "AppSettings"; + /** + * Name of the app to which the given settings are applied + */ + appName: string; + /** + * Homepage background image + */ + backgroundImageURL: string | null; /** * Background color for the dismissiable banner displayed on the homepage */ @@ -17,15 +25,14 @@ export interface UpdateAppSettings_update_AppSettings_by_pk { * Font color for the text in the dismissiable banner displayed on the homepage */ bannerFontColor: string | null; - /** - * German version for the text of a dismissiable banner on the homepage - */ - bannerTextDe: string | null; /** * English version for the text of a dismissiable banner on the homepage */ bannerTextEn: string | null; - id: number; + /** + * German version for the text of a dismissiable banner on the homepage + */ + bannerTextDe: string | null; } export interface UpdateAppSettings { @@ -36,9 +43,9 @@ export interface UpdateAppSettings { } export interface UpdateAppSettingsVariables { + appName: string; bannerBackgroundColor?: string | null; bannerFontColor?: string | null; bannerTextDe?: string | null; bannerTextEn?: string | null; - id: number; } diff --git a/frontend-nx/apps/edu-hub/queries/appSettings.ts b/frontend-nx/apps/edu-hub/queries/appSettings.ts index 636b2820e..c190d81de 100644 --- a/frontend-nx/apps/edu-hub/queries/appSettings.ts +++ b/frontend-nx/apps/edu-hub/queries/appSettings.ts @@ -1,72 +1,39 @@ import { gql } from '@apollo/client'; export const APP_SETTINGS = gql` - query AppSettings { - AppSettings { + query AppSettings($appName: String!) { + AppSettings(where: { appName: { _eq: $appName } }) { + appName backgroundImageURL bannerBackgroundColor bannerFontColor bannerTextDe bannerTextEn - id previewImageURL } } `; - export const UPDATE_APP_SETTINGS = gql` - mutation UpdateAppSettings( - # $backgroundImageURL: String + mutation UpdateAppSettings($appName: String! $bannerBackgroundColor: String $bannerFontColor: String $bannerTextDe: String $bannerTextEn: String - $id: Int! - # $previewImageURL: String ) { - update_AppSettings_by_pk( - pk_columns: { id: $id } - _set: { - # backgroundImageURL: $backgroundImageURL - bannerBackgroundColor: $bannerBackgroundColor - bannerFontColor: $bannerFontColor - bannerTextDe: $bannerTextDe - bannerTextEn: $bannerTextEn - # previewImageURL: $previewImageURL - } - ) { - # backgroundImageURL - bannerBackgroundColor - bannerFontColor - bannerTextDe - bannerTextEn - id - # previewImageURL - } + update_AppSettings_by_pk(pk_columns: {appName: $appName}, + _set: { + bannerBackgroundColor: $bannerBackgroundColor + bannerFontColor: $bannerFontColor + bannerTextDe: $bannerTextDe + bannerTextEn: $bannerTextEn } + ) { + appName + backgroundImageURL + bannerBackgroundColor + bannerFontColor + bannerTextEn + bannerTextDe } +} `; - - -export const INSERT_APP_SETTINGS = gql` - mutation InsertAppSettings ( - $bannerBackgroundColor: String - $bannerFontColor: String - $bannerTextDe: String - $bannerTextEn: String - # $backgroundImageURL: String - # $previewImageURL: String - ){ - insert_AppSettings_one( - object: { - bannerBackgroundColor: $bannerBackgroundColor - bannerFontColor: $bannerFontColor - bannerTextDe: $bannerTextDe - bannerTextEn: $bannerTextEn - # backgroundImageURL: $backgroundImageURL - # previewImageURL: $previewImageURL - }) { - id - } - } -`; \ No newline at end of file diff --git a/keycloak/Dockerfile b/keycloak/Dockerfile index 444fe142f..6af4e67f7 100644 --- a/keycloak/Dockerfile +++ b/keycloak/Dockerfile @@ -1,16 +1,16 @@ -FROM quay.io/keycloak/keycloak:19.0 as builder +FROM quay.io/keycloak/keycloak:22.0 as builder ENV KC_METRICS_ENABLED=true ENV KC_FEATURES=token-exchange ENV KC_DB=postgres -COPY ./libs/keycloak-bcrypt-1.5.0.jar /opt/keycloak/providers/ +COPY ./libs/keycloak-bcrypt-1.6.0.jar /opt/keycloak/providers/ COPY ./themes/opencampus /opt/keycloak/themes/opencampus COPY ./themes/edu-hub /opt/keycloak/themes/edu-hub RUN /opt/keycloak/bin/kc.sh build -FROM quay.io/keycloak/keycloak:19.0 +FROM quay.io/keycloak/keycloak:22.0 COPY --from=builder /opt/keycloak/lib/quarkus/ /opt/keycloak/lib/quarkus/ -COPY ./libs/keycloak-bcrypt-1.5.0.jar /opt/keycloak/providers/ +COPY ./libs/keycloak-bcrypt-1.6.0.jar /opt/keycloak/providers/ COPY ./themes/opencampus /opt/keycloak/themes/opencampus COPY ./themes/edu-hub /opt/keycloak/themes/edu-hub diff --git a/keycloak/Dockerfile-dev b/keycloak/Dockerfile-dev index f11336f2f..4fd42e85a 100644 --- a/keycloak/Dockerfile-dev +++ b/keycloak/Dockerfile-dev @@ -1,16 +1,16 @@ -FROM quay.io/keycloak/keycloak:19.0 as builder +FROM quay.io/keycloak/keycloak:22.0 as builder ENV KC_METRICS_ENABLED=true ENV KC_FEATURES=token-exchange ENV KC_DB=postgres -COPY ./libs/keycloak-bcrypt-1.5.0.jar /opt/keycloak/providers/ +COPY ./libs/keycloak-bcrypt-1.6.0.jar /opt/keycloak/providers/ COPY ./themes/opencampus /opt/keycloak/themes/opencampus COPY ./themes/edu-hub /opt/keycloak/themes/edu-hub RUN /opt/keycloak/bin/kc.sh build -FROM quay.io/keycloak/keycloak:19.0 +FROM quay.io/keycloak/keycloak:22.0 COPY --from=builder /opt/keycloak/lib/quarkus/ /opt/keycloak/lib/quarkus/ -COPY ./libs/keycloak-bcrypt-1.5.0.jar /opt/keycloak/providers/ +COPY ./libs/keycloak-bcrypt-1.6.0.jar /opt/keycloak/providers/ WORKDIR /opt/keycloak ENV KC_HOSTNAME_STRICT=false diff --git a/keycloak/libs/keycloak-bcrypt-1.5.0.jar b/keycloak/libs/keycloak-bcrypt-1.5.0.jar deleted file mode 100644 index 8ed965986..000000000 Binary files a/keycloak/libs/keycloak-bcrypt-1.5.0.jar and /dev/null differ diff --git a/keycloak/libs/keycloak-bcrypt-1.6.0.jar b/keycloak/libs/keycloak-bcrypt-1.6.0.jar new file mode 100644 index 000000000..02d8094cd Binary files /dev/null and b/keycloak/libs/keycloak-bcrypt-1.6.0.jar differ