Skip to content
Open
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
10 changes: 8 additions & 2 deletions force-app/main/default/classes/VideoViewerController.cls
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public with sharing class VideoViewerController {

@AuraEnabled(cacheable=true)
public static String getBaseUrl() {
return System.URL.getOrgDomainUrl().toExternalForm();
if(Network.getNetworkId() == null){
String baseURL = System.URL.getSalesforceBaseUrl().toExternalForm();
baseURL = baseURL.split('\\.')[0];
return baseURL+'--c'+'.documentforce.com';
}else{
return System.URL.getSalesforceBaseUrl().toExternalForm();
}
}
}
}
6 changes: 2 additions & 4 deletions force-app/main/default/lwc/videoViewer/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
/**
* Util methods
*/
const CUSTOM_PART = "--c";
const DOWNLOAD_PART =
".documentforce.com/sfc/servlet.shepherd/document/download/";
"/sfc/servlet.shepherd/document/download/";

// Returns either an empty string or the org's base video download url
export function getBaseVideoUrl(baseUrl) {
if (baseUrl) {
const domain = baseUrl.split(".")[0];
return `${domain}${CUSTOM_PART}${DOWNLOAD_PART}`;
return `${baseUrl}${DOWNLOAD_PART}`;
}
return "";
}
160 changes: 83 additions & 77 deletions force-app/main/default/lwc/videoViewer/videoViewer.html
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,88 +1,94 @@
<template>
<lightning-card icon-name="custom:custom21" class="forceBaseCard">
<span
slot="title"
class="header-title-container slds-card__header slds-p-left_none slds-card__header-title slds-truncate"
title={computedTitle}
>{computedTitle}
</span>
<div class="video-container" if:false={hasNoVideos}>
<h3 class="slds-text-align_center slds-p-top_small">
<span class="slds-text-heading_medium" if:true={showVideoName}
>{currentVideoTitle}</span
>
</h3>
<div class="slds-align_absolute-center" if:false={hasError}>
<template if:true={hasLoadingCompleted}>
<video
controls
preload="auto"
width={width}
height={height}
src={currentVideoUrl}
muted={muted}
<template if:true={computedShowComponent}>
<lightning-card icon-name="custom:custom21" class="forceBaseCard">
<span
slot="title"
class="
header-title-container
slds-card__header
slds-p-left_none
slds-card__header-title
slds-truncate
"
title={computedTitle}
>{computedTitle}
</span>
<div class="video-container" if:false={hasNoVideos}>
<h3 class="slds-text-align_center slds-p-top_small">
<span class="slds-text-heading_medium" if:true={showVideoName}
>{currentVideoTitle}</span
>
<p>
{errorMessage}
</p>
</video>
</template>
<template if:false={hasLoadingCompleted}>
<lightning-spinner
alternative-text="Loading Video"
></lightning-spinner>
</h3>
<div class="slds-align_absolute-center" if:false={hasError}>
<template if:true={hasLoadingCompleted}>
<video
controls
preload="auto"
width={width}
height={height}
src={currentVideoUrl}
muted={muted}
>
<p>{errorMessage}</p>
</video>
</template>
<template if:false={hasLoadingCompleted}>
<lightning-spinner
alternative-text="Loading Video"
></lightning-spinner>
</template>
</div>
<template if:true={hasError}>
<div class="slds-align_absolute-center error-message">
<div class="empty-state-container slds-text-align_center">
<img
src="/_slds/images/illustrations/empty-states/desertSmall.svg"
aria-hidden="true"
alt=""
/>
<div class="empty-state-message slds-m-top_medium">
{errorMessage}
</div>
</div>
</div>
</template>
<p
class="slds-text-body_regular slds-p-around_medium video-description"
if:true={showVideoDescription}
>
{currentVideoDescription}
</p>
</div>
<template if:true={hasError}>
<div class="slds-align_absolute-center error-message">

<template if:true={hasNoVideos}>
<div class="slds-align_absolute-center">
<div class="empty-state-container slds-text-align_center">
<img
src="/_slds/images/illustrations/empty-states/desertSmall.svg"
aria-hidden="true"
alt=""
/>
<div class="empty-state-message slds-m-top_medium">
{errorMessage}
<img src="/img/lbpm/empty.svg" aria-hidden="true" alt="" />
<div class="empty-state-message slds-m-top_medium no-video-message">
{noVideoMessage}
</div>
</div>
</div>
</template>
<p
class="slds-text-body_regular slds-p-around_medium video-description"
if:true={showVideoDescription}
>
{currentVideoDescription}
<p slot="footer" if:true={showNavigation}>
<lightning-button-icon
icon-name="utility:chevronleft"
variant="border-filled"
alternative-text="Previous Video"
title="Previous"
disabled={previousButtonDisabled}
onclick={handlePreviousClick}
></lightning-button-icon>
<lightning-button-icon
icon-name="utility:chevronright"
variant="border-filled"
alternative-text="Next Video"
class="slds-m-left_xx-small"
title="Next"
disabled={forwardButtonDisabled}
onclick={handleNextClick}
></lightning-button-icon>
</p>
</div>

<template if:true={hasNoVideos}>
<div class="slds-align_absolute-center">
<div class="empty-state-container slds-text-align_center">
<img src="/img/lbpm/empty.svg" aria-hidden="true" alt="" />
<div class="empty-state-message slds-m-top_medium no-video-message">
{noVideoMessage}
</div>
</div>
</div>
</template>
<p slot="footer" if:true={showNavigation}>
<lightning-button-icon
icon-name="utility:chevronleft"
variant="border-filled"
alternative-text="Previous Video"
title="Previous"
disabled={previousButtonDisabled}
onclick={handlePreviousClick}
></lightning-button-icon>
<lightning-button-icon
icon-name="utility:chevronright"
variant="border-filled"
alternative-text="Next Video"
class="slds-m-left_xx-small"
title="Next"
disabled={forwardButtonDisabled}
onclick={handleNextClick}
></lightning-button-icon>
</p>
</lightning-card>
</lightning-card>
</template>
</template>
12 changes: 11 additions & 1 deletion force-app/main/default/lwc/videoViewer/videoViewer.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { LightningElement, api, wire } from "lwc";
import { LightningElement, api, wire, track } from "lwc";
import getAttachedDocuments from "@salesforce/apex/VideoViewerController.getAttachedDocuments";
import getBaseUrl from "@salesforce/apex/VideoViewerController.getBaseUrl";
import CONTENTDOCUMENT_OBJECT from "@salesforce/schema/ContentDocument";
Expand Down Expand Up @@ -63,6 +63,10 @@ export default class VideoViewer extends LightningElement {
@api
showVideoDescription;

// Hide if no video is available ?
@api
hideIfNoVideoAvailable;

// Message when there is no supported video attached to the record
@api
noVideoMessage;
Expand All @@ -83,6 +87,7 @@ export default class VideoViewer extends LightningElement {
videoMap = {};

// private variable to keep count of the video the user is on
@track
_currentVideoCount = 0;

// Title for the current video
Expand All @@ -92,6 +97,7 @@ export default class VideoViewer extends LightningElement {
currentVideoDescription;

// Total number of videos
@track
totalVideos = 0;

// Flag to enable/disable navigation's forward button
Expand Down Expand Up @@ -178,6 +184,10 @@ export default class VideoViewer extends LightningElement {
this._currentVideoCount = count;
}

get computedShowComponent() {
return this.totalVideos > 0 || !this.hideIfNoVideoAvailable;
}

// Event handler for previous button click
handlePreviousClick() {
if (this.currentVideoCount > 0) {
Expand Down
Loading