@@ -7,6 +7,7 @@ import * as Constants from "../constants";
7
7
import { MapiClient } from "./mapiClient" ;
8
8
import { KnownMimeTypes } from "../models/knownMimeTypes" ;
9
9
import { KnownHttpHeaders } from "../models/knownHttpHeaders" ;
10
+ import { ISettingsProvider } from "@paperbits/common/configuration" ;
10
11
11
12
export class ProvisionService {
12
13
constructor (
@@ -15,7 +16,8 @@ export class ProvisionService {
15
16
private readonly authenticator : IAuthenticator ,
16
17
private readonly viewManager : ViewManager ,
17
18
private readonly router : Router ,
18
- private readonly blobStorage : AzureBlobStorage
19
+ private readonly blobStorage : AzureBlobStorage ,
20
+ private readonly settingsProvider : ISettingsProvider
19
21
) { }
20
22
21
23
private async fetchData ( url : string ) : Promise < Object > {
@@ -27,6 +29,9 @@ export class ProvisionService {
27
29
const dataUrl = `/editors/templates/default.json` ;
28
30
const dataObj = await this . fetchData ( dataUrl ) ;
29
31
const keys = Object . keys ( dataObj ) ;
32
+
33
+ await this . setUpDefaultContent ( dataObj ) ;
34
+
30
35
const accessToken = await this . authenticator . getAccessTokenAsString ( ) ;
31
36
32
37
if ( ! accessToken ) {
@@ -106,4 +111,24 @@ export class ProvisionService {
106
111
await this . cleanupBlobs ( ) ;
107
112
await this . cleanupContent ( ) ;
108
113
}
114
+
115
+ private async setUpDefaultContent ( dataObj : object ) : Promise < void > {
116
+ const backendUrl = await this . settingsProvider . getSetting < string > ( "backendUrl" ) || `https://${ location . hostname } ` ;
117
+ const defaultMedias : { [ name : string ] : string } = {
118
+ "hero-gradient" : "hero-gradient.jpg" ,
119
+ "featured-1" : "featured-1.jpg" ,
120
+ "featured-2" : "featured-2.jpg" ,
121
+ "featured-3" : "featured-3.jpg" ,
122
+ "contoso-black" : "contoso-black.png" ,
123
+ "logo-contoso-small" : "logo-contoso-small.png"
124
+ }
125
+
126
+ const keyPath = "/contentTypes/blob/contentItems" ;
127
+ const downloadUrl = "/assets/images/" ;
128
+
129
+ for ( const key in defaultMedias ) {
130
+ const media = defaultMedias [ key ] ;
131
+ dataObj [ `${ keyPath } /${ key } ` ] [ "properties" ] [ "downloadUrl" ] = backendUrl + downloadUrl + media ;
132
+ }
133
+ }
109
134
}
0 commit comments