File

branding/shared/data/store-branding.service.ts

Description

Service to load and store the branding of the tenant.

Index

Properties
Methods

Constructor

constructor(applicationService: ApplicationService, inventory: InventoryService, binary: InventoryBinaryService, zip: ZipService, fetch: FetchClient, brandingVersionService: BrandingVersionService, appState: AppStateService, staticAssets: StaticAssetsService, themeSwitcher: ThemeSwitcherService)
Parameters :
Name Type Optional
applicationService ApplicationService No
inventory InventoryService No
binary InventoryBinaryService No
zip ZipService No
fetch FetchClient No
brandingVersionService BrandingVersionService No
appState AppStateService No
staticAssets StaticAssetsService No
themeSwitcher ThemeSwitcherService No

Methods

Async addBranding
addBranding(version: string, content: BrandingOptionsJson, tags: string[], publicOptionsApp?: IApplication)

Adds a new branding version to the public options app. The public options app can be optionally provided to avoid another request for it.

Parameters :
Name Type Optional Default value
version string No
content BrandingOptionsJson No {}
tags string[] No []
publicOptionsApp IApplication Yes
Returns : Promise<literal type>
Async createPublicOptionsAppFromInheritedOptions
createPublicOptionsAppFromInheritedOptions(brandingVars?: Record)

Combines current branding options with the provided branding variables and creates a new public options app. Any assets in the branding will be cloned.

Parameters :
Name Type Optional
brandingVars Record<string | string> Yes
Returns : Promise<literal type>
Async deleteAllBrandings
deleteAllBrandings(publicOptions?: IApplication)

Deletes the public options app and therefore all brandings. The public options app can be optionally provided to avoid another request for it.

Parameters :
Name Type Optional
publicOptions IApplication Yes
Returns : Promise<void>
Async deleteBrandingVersion
deleteBrandingVersion(version: string, publicOptions?: IApplication)

Removes a branding version from the public options app. The public options app can be optionally provided to avoid another request for it.

Parameters :
Name Type Optional
version string No
publicOptions IApplication Yes
Returns : Promise<void>
Async getBrandingOptionsForVersion
getBrandingOptionsForVersion(version?: string)

Returns the branding options for the provided version. If no branding was found (e.g. status 404), an error is thrown.

Parameters :
Name Type Optional
version string Yes
Async getBrandingZip
getBrandingZip(content: Record)

Returns the blob of a zip file containing the provided branding options (options.json) and the manifest (cumulocity.json).

Parameters :
Name Type Optional Default value
content Record<string | any> No {}
Returns : Promise<Blob>
Async getMetadataOfBrandingBinaries
getMetadataOfBrandingBinaries(versions: BrandVersion[])

Enhances the provided branding versions with metadata from the linked binaries. It will add the owner and lastUpdated fields to the versions. The provided array is altered.

Parameters :
Name Type Optional
versions BrandVersion[] No
Returns : Promise<BrandVersion[]>
Async getStartedUsingBranding
getStartedUsingBranding()

Will create a the initial branding based on the currently applied CSS variables.

Returns : Promise<void>
getZipForBinary
getZipForBinary(binaryId: string, fileName: string)
Parameters :
Name Type Optional Default value
binaryId string No
fileName string No this.fileNames.exportZipName
Returns : Observable<File>
Async loadBrandingVariants
loadBrandingVariants(app?: IApplication)

Returns the brandings of the tenant. If no public options app is found, publicOptions will be undefined and variants an empty array. For old brandings (created without versioning) a default version is returned.

Parameters :
Name Type Optional
app IApplication Yes
Returns : Promise<literal type>
Async markAsActive
markAsActive(brandingVersion: BrandVersion, app?: IApplication)

Sets the latest tag on the provided branding version. Making it the global active branding.

Parameters :
Name Type Optional
brandingVersion BrandVersion No
app IApplication Yes
Returns : Promise<void>
replaceBrandingAssetsInBrandingOptions
replaceBrandingAssetsInBrandingOptions(branding: BrandingOptionsJson, oldAssets: StaticAsset[], newAssets: StaticAsset[])

Replaces the assets in the branding options with the new assets. Goes through the provided oldAssets and replaces their occurrences in the branding with the corresponding newAssets entry sharing the same fileName. Returns the updated branding options.

Parameters :
Name Type Optional
branding BrandingOptionsJson No
oldAssets StaticAsset[] No
newAssets StaticAsset[] No
Async saveBranding
saveBranding(blob: Blob | File, version: string, tags: string[], publicOptionsApp?: IApplication)

Saves the provided branding as a new version for the public options app. The public options app can be optionally provided to avoid another request for it.

Parameters :
Name Type Optional Default value
blob Blob | File No
version string No
tags string[] No []
publicOptionsApp IApplication Yes
Returns : Promise<literal type>
Async saveExistingBranding
saveExistingBranding(branding: Record, currentVersion: string, tagsOfCurrentVersion: string[], newVersion?: string)

Saves a new iteration of an already existing branding.

Parameters :
Name Type Optional Default value
branding Record<string | any> No
currentVersion string No
tagsOfCurrentVersion string[] No []
newVersion string Yes
Returns : Promise<string>
Async waitForBrandingToBePresent
waitForBrandingToBePresent(version: string)

As the branding is not immediately available after creation, this method will wait for the branding to be present.

Parameters :
Name Type Optional Description
version string No

The version of the branding to be retrieved.

Returns : Promise<void>

Properties

Readonly fileNames
Default value : { options: 'options.json', manifest: 'cumulocity.json', exportZipName: 'public-options.zip' } as const
Readonly manifestValues
Default value : { name: 'public-options', contextPath: 'public-options', key: 'public-options-key', description: 'Application containing static assets used by e.g. branding.', noAppSwitcher: true, type: ApplicationType.HOSTED, availability: ApplicationAvailability.SHARED } as const satisfies IApplication
refreshTriggerBrandingVariants
Default value : new BehaviorSubject<void>(null)

results matching ""

    No results matching ""