SyncMadeEasy/force-app/main/default/aura/AuthenticateOrg/AuthenticateOrg.cmp

365 lines
25 KiB
Plaintext

<aura:component controller="AddDeleteController" >
<aura:attribute name="OpenModel" type="boolean" default="false"/>
<aura:registerEvent name="ParentCmpRefresh" type="c.ParentCmpRefresh" />
<aura:attribute name="siteObj" type="Object" default="{'siteUrl':'',
'siteguestid':
}"/>
<aura:attribute name="Refreshtoken" type="String" default=""/>
<aura:attribute name="ConfigsavedsiteUrl" type="String" default=""/>
<aura:attribute name="SiteNotifcation" type="String" default="Please Setup Site"/>
<aura:attribute name="SiteModalIsOpen" type="boolean" default="false"/>
<aura:attribute name="DisplayPopupButton" type="boolean" default="ture"/>
<aura:attribute name="Spinner" type="boolean" default="false"/>
<aura:attribute name="hasError" type="boolean" default="true"/>
<aura:handler name="init" value="this" action="{!c.doInit}" />
<aura:attribute name="URLsavedsuccess" type="boolean" default="false"/>
<aura:attribute name="siteurlparent" type="String" default="blank"/>
<aura:attribute name="isOpen" type="boolean" default="false"/>
<aura:attribute name="siteURLList" type="list" />
<aura:attribute name="selectedsite" type="String" />
<aura:attribute name="errormessage" type="String" />
<aura:attribute name="copyurlvalue" type="String" default="copy URL"/>
<aura:attribute name="CreateRemotesiteSettingUrl" type="String" default="not"/>
<aura:attribute name="Remotesiteexist" type="boolean" default="false"/>
<aura:attribute name="RemotesiteURL" type="String" default="/0rp/e"/>
<aura:attribute name="AuthenticateButton" type="boolean" default="false"/>
<aura:attribute name ="CheckCertificate" type= "boolean" default="false"/>
<aura:attribute name ="CheckSiteAccess" type= "boolean" default="true"/>
<aura:attribute name ="CheckSiteExist" type= "boolean" default="false"/>
<aura:attribute name ="Toolingremotesite" type= "boolean" default="false"/>
<aura:attribute name="AUthenticationLink" type="String" default="/apex/hic_shopifysync__SalesforceAuthentication?viewmode="/>
<aura:attribute name="CertificateCreateLink" type="String" default="/0P1/e"/>
<aura:attribute name="viewmode" type="String" default=""/>
<aura:registerEvent name="AuthenticateErorrEvent" type="c:AuthenticateErorrEvent"/>
<center>
<!--div style = "width: 23em;">
<ui:message title="Information" severity="info" closable="false" >
<h1 style= "float:left"><b>"Please authenticate your org <a href="/apex/hic_shopifysync__SalesforceAuthentication" target="_top" >click here</a> "</b></h1> <br></br>
</ui:message>
</div-->
<div style="font-size: x-large;">
<img src="{!$Resource.AuthenticateConnecting}" style="width: 20%;margin-top: 2%;" height="50"/>
<aura:if isTrue="{!and(v.CheckCertificate,and(and(v.URLsavedsuccess,and(v.CheckSiteExist,and(v.Remotesiteexist,and(or(v.Refreshtoken == undefined,v.Refreshtoken == null),v.CheckSiteAccess))))))}">
<div>
<p style="margin-top: 1%;margin-bottom: 2%;">
<b>Let's get started! please click below to initiate the process.</b><br/>
</p>
<lightning:button class ="InitializeButton" variant="destructive" onclick="{!c.InitializingButtonfunction}" label="Please Authenticate" title="Brand action" ><b>Initialize</b></lightning:button>
</div>
<aura:set attribute="else">
<fieldset id="Attentionfieldset" style="pointer-events: all;" class="slds-box slds-theme--default slds-container--small" >
<div style="float:right">
<img id = "mainSpinner" src="{!$Resource.DataProcessing}" style="width: 35px;display:none" height="50"/>
<lightning:button iconName="utility:sync" class="Syncbuttonstyle" iconPosition="left" variant="destructive" label="Check Status"
title="Check Status"
onclick="{!c.doInit}"/>
</div>
<legend class="slds-text-heading--small slds-p-vertical--medium RealtimeSyncStyle" style="margin-right: 68% !important;font-size: large;" ><lightning:icon iconName="utility:lock" />
Attention required
</legend>
<table style="width: 39em;">
<aura:renderIf isTrue="{!v.isOpen}">
<tr style="font-size: large;">
<td>
<div class="slds-form-element">
<div class="slds-form-element__control">
<div style=" display: block;
margin: 10px 0px;
padding:12px;
color: #D8000C;
background-color: #FFD2D2;
width: 28%;"
>
<h1 > {!v.errormessage} </h1>
</div>
</div>
</div>
</td>
</tr>
</aura:renderIf>
<tr >
<td>
<div class="slds-form-element">
<div class="slds-form-element__control">
<aura:renderif isTrue="{!!v.CheckSiteExist}">
<div class="slds-checkbox">
<abbr class="slds-required" title="required">*</abbr>
<input type="checkbox" name="options" id="checkbox-unique-id-72" value="{!v.CheckSiteExist}" disabled="true" checked="{!v.CheckSiteExist}" />
<label class="slds-checkbox__label" for="checkbox-unique-id-72">
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label" style="font-size: large; color:#166efb;">There is no activate site in your org. Please <a href="" style="color:red;" onclick="{!c.Toolingremotesite}" >click here</a> to create new or activate site.</span>
</label>
<span>
<lightning:buttonIcon iconName="utility:info" variant="bare" onclick="{!c.siteactiveinfo}"/>
</span>
</div>
<aura:set attribute="else">
<div class="slds-checkbox" id="configsite" style = "{!if(!v.URLsavedsuccess,'','opacity: 0.6;')}">
<abbr class="slds-required" title="required">*</abbr>
<input type="checkbox" name="options" id="checkbox-unique-id-55" value="{!v.URLsavedsuccess}" disabled="true" checked="{!v.URLsavedsuccess}" />
<label class="slds-checkbox__label" for="checkbox-unique-id-72">
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label" style="font-size: large; color:#166efb;">Please <a href="" style="color:red;" onclick="{!if(!v.URLsavedsuccess,c.OpenSiteModal,'')}" > click here</a> for configure site.</span>
</label>
</div>
<!--aura:if isTrue="{!!v.siteURLList.length > 0}">
There is no active site in your org. Please <a href="/0DM/o" >click here</a> to create new site.
</aura:if-->
</aura:set>
</aura:renderif>
</div>
</div>
</td>
</tr>
<!--aura:if istrue="{!v.CheckSiteAccess}">
<tr>
<td>
<div class="slds-form-element">
<div class="slds-form-element__control">
<div class="slds-checkbox" style="{!if(v.CheckSiteExist,'','opacity: 0.6;')}">
<abbr class="slds-required" title="required">*</abbr>
<input type="checkbox" name="options" id="checkbox-unique-id-72" value="{!and(v.CheckSiteAccess,v.CheckSiteExist)}" disabled="true" checked="{!and(v.CheckSiteAccess,v.CheckSiteExist)}" />
<label class="slds-checkbox__label" for="checkbox-unique-id-72">
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label" style="font-size: large; color:#166efb;" >Give access to all Package's class and page to site profile. Please <a href="" style="color:red;" onclick="{!if(v.CheckSiteExist,c.Toolingremotesite,'')}">click here</a> to give access.</span>
</label>
</div>
</div>
</div>
</td>
</tr>
</aura:if-->
<tr>
<td>
<div class="slds-form-element">
<div class="slds-form-element__control">
<div class="slds-checkbox" style="{!if(and(v.CheckSiteAccess,and(v.CheckSiteExist,and(!v.Remotesiteexist,v.URLsavedsuccess))),'','opacity: 0.6;')}">
<abbr class="slds-required" title="required">*</abbr>
<input type="checkbox" name="options" id="checkbox-unique-id-72" value="{!v.Remotesiteexist}" disabled="true" checked="{!v.Remotesiteexist}" />
<label class="slds-checkbox__label" for="checkbox-unique-id-72">
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label" style="font-size: large; color:#166efb;"> Create Remote site setting . Please <!--<a href="" onclick="{!if(and(!v.Remotesiteexist,v.URLsavedsuccess),c.CopyURl,'')}" style="color:red;"> {!v.copyurlvalue} </a> and --> <a onclick="{!if(and(v.CheckSiteAccess,and(v.CheckSiteExist,and(!v.Remotesiteexist,v.URLsavedsuccess))),c.ReDirectRemoteSiteSetting,'')}" target = "_blank" style="color:red;">click here</a> to create remote site setting.</span>
</label>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="slds-form-element">
<div class="slds-form-element__control">
<div class="slds-checkbox" style="{!if(and(v.CheckSiteAccess,and(v.CheckSiteExist,and(v.Remotesiteexist,and(!v.CheckCertificate,v.URLsavedsuccess)))),'','opacity: 0.6;')}">
<abbr class="slds-required" title="required">*</abbr>
<input type="checkbox" name="options" id="checkbox-unique-id-72" value="{!v.CheckCertificate}" disabled="true" checked="{!v.CheckCertificate}" />
<label class="slds-checkbox__label" for="checkbox-unique-id-72">
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label" style="font-size: large; color:#166efb;">There is no self-signed Certificate with name 'Shopify'. Please <a href="{!if(and(v.CheckSiteAccess,and(v.CheckSiteExist,and(v.Remotesiteexist,and(!v.CheckCertificate,v.URLsavedsuccess)))),v.CertificateCreateLink,'')}" target = "_blank" style="color:red;">click here</a> to create self-signed Certificate.</span>
</label>
</div>
</div>
</div>
</td>
</tr>
</table>
</fieldset>
<!-- Lightning Indicator-->
<span>
<p style="margin-top:1%;font-size: small;"><sup><b style="color: red;">*</b></sup> Please click check status button after completion of any authentication requirement.</p>
<br />
</span>
</aura:set>
</aura:if>
</div>
<aura:renderIf isTrue="{!v.isOpen}">
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<center>
<div class="slds-modal__container">
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<div >
<center>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">{!v.errormessage}</h2>
</center>
<div id ="CancleGotosite" style="margin-top:20px">
<lightning:button variant="neutral"
label="Cancel"
title="Cancel"
onclick="{! c.SyncAuthenticatepage }"/>
<span id="Checkstates" style="margin-left: 1em;">
<lightning:button iconName="utility:sync" class="Syncbuttonstyle" iconPosition="left" variant="destructive" label="Check Status"
title="Check Status"
onclick="{!c.SyncAuthenticatepage}"/>
</span>
</div>
</div>
</div>
<br/><br/>
</div>
</center>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</aura:renderIf>
<aura:if isTrue="{!v.SiteModalIsOpen}">
<!--###### MODAL BOX Start From Here ######-->
<div role="dialog" tabindex="-1" aria-labelledby="header99" class="slds-modal slds-fade-in-open slds-modal_small">
<div class="slds-modal__container">
<!-- ###### MODAL BOX HEADER Part Start From Here ######-->
<div class="slds-modal__header">
<lightning:buttonIcon iconName="utility:close"
onclick="{! c.CloseSiteModal }"
alternativeText="close"
variant="bare-inverse"
class="slds-modal__close"/>
<h2 id="header99" class="slds-text-heading--medium">Setup Site</h2>
<br/>
</div>
<!--###### MODAL BOX BODY Part Start From Here ######-->
<div class="slds-modal__content slds-p-around_medium">
<!--showing 3 screens based on progress indicator steps-->
<div style="margin-top:20px;">
<span style="width: 57%;float: left;margin-left: 4%;">
<!--ui:inputSelect aura:id="beforeauthsite" required="true" class="slds-select" label=" * Select a Site URL" change="{!c.onsitechange}" value="{!v.selectedsite}">
<ui:inputSelectOption text="" label="Select site"/>
<aura:iteration items="{!v.siteURLList}" var="tableRow2" indexVar="index2" >
<ui:inputSelectOption text="{!tableRow2.siteUrl}" label="{!tableRow2.siteUrl}"/>
</aura:iteration>
</ui:inputSelect-->
<lightning:select aura:id="beforeauthsite" disabled="true" label="Select a Site URL" onchange="{!c.onsitechange}" value="{!v.selectedsite}" required="true">
<option text="Select Site" value=""/>
<aura:iteration items="{!v.siteURLList}" var="tableRow2" >
<option text="{!tableRow2.siteUrl}" value="{!tableRow2.siteUrl}" />
</aura:iteration>
</lightning:select>
</span>
<span>
<span aura:id = "DataProceesing">
<img src="{!$Resource.DataProcessing}" style="width: 5%;" height="50"/>
</span>
</span>
<span >
<lightning:button aura:id = "sitesavebutton" iconName="utility:save" class="buttonstyle" iconPosition="left" variant="brand" label="Save"
title="Save"
disabled="false"
onclick="{! c.savesite }" />
<lightning:button
class="buttonstyle"
iconName="utility:forward"
iconPosition="left"
label="Site page"
title="Go to Site page"
onclick="{! c.siteredirect }"/>
</span>
</div>
</div>
<!--###### MODAL BOX FOOTER Part Start From Here ######-->
<div class="slds-modal__footer slds-modal__footer_directional">
<span style="float:right;">
<h1 style="color:red;">{!v.SiteNotifcation}</h1>
</span>
<span style="float:left;">
<a href="https://youtu.be/0LihizAJGo8?si=CSvvhD7ssMmK0Ylq" target="_blank" style="color:blue;">How to setup Site ?</a>
</span>
</div>
</div>
</div>
<div class="slds-backdrop slds-backdrop_open"></div>
<!--###### MODAL BOX Part END Here ######-->
</aura:if>
<aura:if isTrue="{!v.OpenModel}">
<div class="slds-m-around_xx-large">
<!--Use aura:if tag to display/hide popup based on isModalOpen value-->
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<header class="slds-modal__header">
<lightning:buttonIcon iconName="utility:close"
onclick="{! c.closeSiteactiveinfo }"
alternativeText="close"
variant="bare-inverse"
class="slds-modal__close"/>
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate"><b>How to activate site</b> <!--lightning:Icon iconName="utility:report_issue"
alternativeText="Support"
/--></h2>
</header>
<!--Modal/Popup Box Body Starts here-->
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<p>
<!-- CREATE NEW EXPENSE -->
<div aria-labelledby="newexpenseform">
<form class="slds-form--stacked">
<img src="{!$Resource.HowtoactivatesitInfo}" class="hover-shadow" style="width: 100%;margin: 1%;" height="50%"/>
</form>
</div>
<!-- / CREATE NEW EXPENSE -->
</p>
</div>
<footer class="slds-modal__footer" style="padding:0;">
<center>
<span>
<a href="https://youtu.be/0LihizAJGo8?si=CSvvhD7ssMmK0Ylq" target="_blank" style="color:blue;">How to setup Site ?</a>
</span>
<lightning:button
class="buttonstyle"
iconName="utility:forward"
iconPosition="left"
label="Go to Site page"
title="Go to Site page"
onclick="{! c.siteactiveinfoPageRedirect }"/>
</center>
</footer>
</div>
</section>
<div class="slds-backdrop slds-backdrop_open"></div>
</div>
</aura:if>
</center>
</aura:component>