Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Commit

Permalink
[BB-2239] Hero customization page (#559)
Browse files Browse the repository at this point in the history
* Implement the hero customization page in the console

Also implement the necessary changes in the backend needed by the frontend.
  • Loading branch information
lgp171188 authored and giovannicimolin committed Apr 10, 2020
1 parent 85505dd commit f391954
Show file tree
Hide file tree
Showing 54 changed files with 3,805 additions and 48 deletions.
2 changes: 1 addition & 1 deletion frontend/packages/api_client/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.3-SNAPSHOT
4.3.1-SNAPSHOT
73 changes: 64 additions & 9 deletions frontend/packages/api_client/src/apis/V2Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* API for OpenCraft Instance Manager
*
* The version of the OpenAPI document: api
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
Expand All @@ -18,12 +18,12 @@ import {
Account,
AccountFromJSON,
AccountToJSON,
ApplicationImageUpload,
ApplicationImageUploadFromJSON,
ApplicationImageUploadToJSON,
GenericAPIError,
GenericAPIErrorFromJSON,
GenericAPIErrorToJSON,
LogoFaviconUpload,
LogoFaviconUploadFromJSON,
LogoFaviconUploadToJSON,
OpenEdXInstanceConfig,
OpenEdXInstanceConfigFromJSON,
OpenEdXInstanceConfigToJSON,
Expand All @@ -36,6 +36,9 @@ import {
OpenEdXInstanceDeploymentStatus,
OpenEdXInstanceDeploymentStatusFromJSON,
OpenEdXInstanceDeploymentStatusToJSON,
StaticContentOverrides,
StaticContentOverridesFromJSON,
StaticContentOverridesToJSON,
ThemeSchema,
ThemeSchemaFromJSON,
ThemeSchemaToJSON,
Expand Down Expand Up @@ -93,6 +96,7 @@ export interface InstancesOpenedxConfigImageRequest {
id: string;
logo?: Blob;
favicon?: Blob;
heroCoverImage?: Blob;
}

export interface InstancesOpenedxConfigPartialUpdateRequest {
Expand All @@ -104,6 +108,11 @@ export interface InstancesOpenedxConfigReadRequest {
id: string;
}

export interface InstancesOpenedxConfigStaticContentOverridesRequest {
id: string;
data: StaticContentOverrides;
}

export interface InstancesOpenedxConfigThemeConfigRequest {
id: string;
data: ThemeSchema;
Expand Down Expand Up @@ -476,7 +485,7 @@ export class V2Api extends runtime.BaseAPI {
* Send a POST to action image/ with the file in the `logo` or `favicon` field to add or update it.
* Endpoint for saving favicon or logo images
*/
async instancesOpenedxConfigImageRaw(requestParameters: InstancesOpenedxConfigImageRequest): Promise<runtime.ApiResponse<LogoFaviconUpload>> {
async instancesOpenedxConfigImageRaw(requestParameters: InstancesOpenedxConfigImageRequest): Promise<runtime.ApiResponse<ApplicationImageUpload>> {
if (requestParameters.id === null || requestParameters.id === undefined) {
throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling instancesOpenedxConfigImage.');
}
Expand All @@ -502,8 +511,6 @@ export class V2Api extends runtime.BaseAPI {
let useForm = false;
// use FormData to transmit files using content-type "multipart/form-data"
useForm = canConsumeForm;
// use FormData to transmit files using content-type "multipart/form-data"
useForm = canConsumeForm;
if (useForm) {
formParams = new FormData();
} else {
Expand All @@ -518,6 +525,10 @@ export class V2Api extends runtime.BaseAPI {
formParams.append('favicon', requestParameters.favicon as any);
}

if (requestParameters.heroCoverImage !== undefined) {
formParams.append('hero_cover_image', requestParameters.heroCoverImage as any);
}

const response = await this.request({
path: `/v2/instances/openedx_config/{id}/image/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'POST',
Expand All @@ -526,14 +537,14 @@ export class V2Api extends runtime.BaseAPI {
body: formParams,
});

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

/**
* Send a POST to action image/ with the file in the `logo` or `favicon` field to add or update it.
* Endpoint for saving favicon or logo images
*/
async instancesOpenedxConfigImage(requestParameters: InstancesOpenedxConfigImageRequest): Promise<LogoFaviconUpload> {
async instancesOpenedxConfigImage(requestParameters: InstancesOpenedxConfigImageRequest): Promise<ApplicationImageUpload> {
const response = await this.instancesOpenedxConfigImageRaw(requestParameters);
return await response.value();
}
Expand Down Expand Up @@ -658,6 +669,50 @@ export class V2Api extends runtime.BaseAPI {
return await response.value();
}

/**
* Partial update for static content overrides configuration
*/
async instancesOpenedxConfigStaticContentOverridesRaw(requestParameters: InstancesOpenedxConfigStaticContentOverridesRequest): Promise<runtime.ApiResponse<StaticContentOverrides>> {
if (requestParameters.id === null || requestParameters.id === undefined) {
throw new runtime.RequiredError('id','Required parameter requestParameters.id was null or undefined when calling instancesOpenedxConfigStaticContentOverrides.');
}

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

const queryParameters: runtime.HTTPQuery = {};

const headerParameters: runtime.HTTPHeaders = {};

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

if (this.configuration && this.configuration.apiKey) {
headerParameters["Authorization"] = this.configuration.apiKey("Authorization"); // api_key authentication
}

if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
}
const response = await this.request({
path: `/v2/instances/openedx_config/{id}/static_content_overrides/`.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters.id))),
method: 'PATCH',
headers: headerParameters,
query: queryParameters,
body: StaticContentOverridesToJSON(requestParameters.data),
});

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

/**
* Partial update for static content overrides configuration
*/
async instancesOpenedxConfigStaticContentOverrides(requestParameters: InstancesOpenedxConfigStaticContentOverridesRequest): Promise<StaticContentOverrides> {
const response = await this.instancesOpenedxConfigStaticContentOverridesRaw(requestParameters);
return await response.value();
}

/**
* This is a custom handler to partially update theme fields.
* Partial update for theme configuration
Expand Down
70 changes: 70 additions & 0 deletions frontend/packages/api_client/src/models/ApplicationImageUpload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* tslint:disable */
/* eslint-disable */
/**
* OpenCraft Instance Manager
* API for OpenCraft Instance Manager
*
* The version of the OpenAPI document: api
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
/**
*
* @export
* @interface ApplicationImageUpload
*/
export interface ApplicationImageUpload {
/**
*
* @type {string}
* @memberof ApplicationImageUpload
*/
readonly logo?: string;
/**
*
* @type {string}
* @memberof ApplicationImageUpload
*/
readonly favicon?: string;
/**
*
* @type {string}
* @memberof ApplicationImageUpload
*/
readonly heroCoverImage?: string;
}

export function ApplicationImageUploadFromJSON(json: any): ApplicationImageUpload {
return ApplicationImageUploadFromJSONTyped(json, false);
}

export function ApplicationImageUploadFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApplicationImageUpload {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'logo': !exists(json, 'logo') ? undefined : json['logo'],
'favicon': !exists(json, 'favicon') ? undefined : json['favicon'],
'heroCoverImage': !exists(json, 'hero_cover_image') ? undefined : json['hero_cover_image'],
};
}

export function ApplicationImageUploadToJSON(value?: ApplicationImageUpload | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

};
}


7 changes: 7 additions & 0 deletions frontend/packages/api_client/src/models/LogoFaviconUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export interface LogoFaviconUpload {
* @memberof LogoFaviconUpload
*/
readonly favicon?: string;
/**
*
* @type {string}
* @memberof LogoFaviconUpload
*/
readonly heroCoverImage?: string;
}

export function LogoFaviconUploadFromJSON(json: any): LogoFaviconUpload {
Expand All @@ -45,6 +51,7 @@ export function LogoFaviconUploadFromJSONTyped(json: any, ignoreDiscriminator: b

'logo': !exists(json, 'logo') ? undefined : json['logo'],
'favicon': !exists(json, 'favicon') ? undefined : json['favicon'],
'heroCoverImage': !exists(json, 'hero_cover_image') ? undefined : json['hero_cover_image'],
};
}

Expand Down
8 changes: 8 additions & 0 deletions frontend/packages/api_client/src/models/OpenEdXAppServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ export interface OpenEdXAppServer {
* @memberof OpenEdXAppServer
*/
configurationThemeSettings?: string;
/**
* YAML vars for setting SiteConfiguration variables
* @type {string}
* @memberof OpenEdXAppServer
*/
configurationSiteConfigurationSettings?: string | null;
/**
* YAML variables for commonly needed services.
* @type {string}
Expand Down Expand Up @@ -192,6 +198,7 @@ export function OpenEdXAppServerFromJSONTyped(json: any, ignoreDiscriminator: bo
'configurationDatabaseSettings': !exists(json, 'configuration_database_settings') ? undefined : json['configuration_database_settings'],
'configurationStorageSettings': !exists(json, 'configuration_storage_settings') ? undefined : json['configuration_storage_settings'],
'configurationThemeSettings': !exists(json, 'configuration_theme_settings') ? undefined : json['configuration_theme_settings'],
'configurationSiteConfigurationSettings': !exists(json, 'configuration_site_configuration_settings') ? undefined : json['configuration_site_configuration_settings'],
'commonConfigurationSettings': !exists(json, 'common_configuration_settings') ? undefined : json['common_configuration_settings'],
'configurationSettings': json['configuration_settings'],
'instance': InstanceReferenceMinimalFromJSON(json['instance']),
Expand Down Expand Up @@ -226,6 +233,7 @@ export function OpenEdXAppServerToJSON(value?: OpenEdXAppServer | null): any {
'configuration_database_settings': value.configurationDatabaseSettings,
'configuration_storage_settings': value.configurationStorageSettings,
'configuration_theme_settings': value.configurationThemeSettings,
'configuration_site_configuration_settings': value.configurationSiteConfigurationSettings,
'common_configuration_settings': value.commonConfigurationSettings,
'configuration_settings': value.configurationSettings,
'instance': InstanceReferenceMinimalToJSON(value.instance),
Expand Down
19 changes: 19 additions & 0 deletions frontend/packages/api_client/src/models/OpenEdXInstanceConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

import { exists, mapValues } from '../runtime';
import {
StaticContentOverrides,
StaticContentOverridesFromJSON,
StaticContentOverridesFromJSONTyped,
StaticContentOverridesToJSON,
ThemeSchema,
ThemeSchemaFromJSON,
ThemeSchemaFromJSONTyped,
Expand Down Expand Up @@ -86,6 +90,18 @@ export interface OpenEdXInstanceConfig {
* @memberof OpenEdXInstanceConfig
*/
readonly favicon?: string;
/**
* This is used as the cover image for the hero section in the instance LMS home page.
* @type {string}
* @memberof OpenEdXInstanceConfig
*/
readonly heroCoverImage?: string | null;
/**
*
* @type {StaticContentOverrides}
* @memberof OpenEdXInstanceConfig
*/
draftStaticContentOverrides?: StaticContentOverrides;
}

export function OpenEdXInstanceConfigFromJSON(json: any): OpenEdXInstanceConfig {
Expand All @@ -108,6 +124,8 @@ export function OpenEdXInstanceConfigFromJSONTyped(json: any, ignoreDiscriminato
'draftThemeConfig': !exists(json, 'draft_theme_config') ? undefined : ThemeSchemaFromJSON(json['draft_theme_config']),
'logo': !exists(json, 'logo') ? undefined : json['logo'],
'favicon': !exists(json, 'favicon') ? undefined : json['favicon'],
'heroCoverImage': !exists(json, 'hero_cover_image') ? undefined : json['hero_cover_image'],
'draftStaticContentOverrides': !exists(json, 'draft_static_content_overrides') ? undefined : StaticContentOverridesFromJSON(json['draft_static_content_overrides']),
};
}

Expand All @@ -127,6 +145,7 @@ export function OpenEdXInstanceConfigToJSON(value?: OpenEdXInstanceConfig | null
'privacy_policy_url': value.privacyPolicyUrl,
'use_advanced_theme': value.useAdvancedTheme,
'draft_theme_config': ThemeSchemaToJSON(value.draftThemeConfig),
'draft_static_content_overrides': StaticContentOverridesToJSON(value.draftStaticContentOverrides),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

import { exists, mapValues } from '../runtime';
import {
StaticContentOverrides,
StaticContentOverridesFromJSON,
StaticContentOverridesFromJSONTyped,
StaticContentOverridesToJSON,
ThemeSchema,
ThemeSchemaFromJSON,
ThemeSchemaFromJSONTyped,
Expand Down Expand Up @@ -80,6 +84,18 @@ export interface OpenEdXInstanceConfigUpdate {
* @memberof OpenEdXInstanceConfigUpdate
*/
readonly favicon?: string;
/**
* This is used as the cover image for the hero section in the instance LMS home page.
* @type {string}
* @memberof OpenEdXInstanceConfigUpdate
*/
readonly heroCoverImage?: string | null;
/**
*
* @type {StaticContentOverrides}
* @memberof OpenEdXInstanceConfigUpdate
*/
draftStaticContentOverrides?: StaticContentOverrides;
}

export function OpenEdXInstanceConfigUpdateFromJSON(json: any): OpenEdXInstanceConfigUpdate {
Expand All @@ -101,6 +117,8 @@ export function OpenEdXInstanceConfigUpdateFromJSONTyped(json: any, ignoreDiscri
'draftThemeConfig': !exists(json, 'draft_theme_config') ? undefined : ThemeSchemaFromJSON(json['draft_theme_config']),
'logo': !exists(json, 'logo') ? undefined : json['logo'],
'favicon': !exists(json, 'favicon') ? undefined : json['favicon'],
'heroCoverImage': !exists(json, 'hero_cover_image') ? undefined : json['hero_cover_image'],
'draftStaticContentOverrides': !exists(json, 'draft_static_content_overrides') ? undefined : StaticContentOverridesFromJSON(json['draft_static_content_overrides']),
};
}

Expand All @@ -120,6 +138,7 @@ export function OpenEdXInstanceConfigUpdateToJSON(value?: OpenEdXInstanceConfigU
'privacy_policy_url': value.privacyPolicyUrl,
'use_advanced_theme': value.useAdvancedTheme,
'draft_theme_config': ThemeSchemaToJSON(value.draftThemeConfig),
'draft_static_content_overrides': StaticContentOverridesToJSON(value.draftStaticContentOverrides),
};
}

Expand Down
Loading

0 comments on commit f391954

Please sign in to comment.