Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move default media files to regional storage #2407

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/services/provisioningService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Constants from "../constants";
import { MapiClient } from "./mapiClient";
import { KnownMimeTypes } from "../models/knownMimeTypes";
import { KnownHttpHeaders } from "../models/knownHttpHeaders";
import { ISettingsProvider } from "@paperbits/common/configuration";

export class ProvisionService {
constructor(
Expand All @@ -15,7 +16,8 @@ export class ProvisionService {
private readonly authenticator: IAuthenticator,
private readonly viewManager: ViewManager,
private readonly router: Router,
private readonly blobStorage: AzureBlobStorage
private readonly blobStorage: AzureBlobStorage,
private readonly settingsProvider: ISettingsProvider
) { }

private async fetchData(url: string): Promise<Object> {
Expand All @@ -27,6 +29,9 @@ export class ProvisionService {
const dataUrl = `/editors/templates/default.json`;
const dataObj = await this.fetchData(dataUrl);
const keys = Object.keys(dataObj);

await this.setUpDefaultContent(dataObj);

const accessToken = await this.authenticator.getAccessTokenAsString();

if (!accessToken) {
Expand Down Expand Up @@ -106,4 +111,24 @@ export class ProvisionService {
await this.cleanupBlobs();
await this.cleanupContent();
}

private async setUpDefaultContent(dataObj: object): Promise<void> {
const backendUrl = await this.settingsProvider.getSetting<string>("backendUrl") || `https://${location.hostname}`;
const defaultMedias: { [name: string]: string } = {
"hero-gradient": "hero-gradient.jpg",
"featured-1": "featured-1.jpg",
"featured-2": "featured-2.jpg",
"featured-3": "featured-3.jpg",
"contoso-black": "contoso-black.png",
"logo-contoso-small": "logo-contoso-small.png"
}

const keyPath = "/contentTypes/blob/contentItems";
const downloadUrl = "/assets/images/";

for (const key in defaultMedias) {
const media = defaultMedias[key];
dataObj[`${keyPath}/${key}`]["properties"]["downloadUrl"] = backendUrl + downloadUrl + media;
}
}
}
Binary file added src/themes/website/images/contoso-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/themes/website/images/featured-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/themes/website/images/featured-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/themes/website/images/featured-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/themes/website/images/hero-gradient.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/themes/website/images/logo-contoso-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion templates/default.json

Large diffs are not rendered by default.

Loading