Skip to content

Instantly share code, notes, and snippets.

View dhaniksahni's full-sized avatar

Dhanik Lal Sahni dhaniksahni

View GitHub Profile
@dhaniksahni
dhaniksahni / commonDialog.html
Last active September 1, 2020 16:07
Common Dialog LWC Component
<template>
<template if:true={open}>
<div>
<section role="dialog" tabindex="-1" class="slds-modal slds-fade-in-open">
<div class="slds-modal__container">
<header class="slds-modal__header">
<lightning-button-icon class="slds-modal__close" icon-name="utility:close" onclick={closeModal}></lightning-button-icon>
<h2>{title}</h2>
</header>
<div class="slds-modal__content slds-var-p-around_medium">
@dhaniksahni
dhaniksahni / SingleSelectDatatable.js
Created August 16, 2020 19:07
Single Row Selection in LWC
import { LightningElement, wire } from 'lwc';
import getContactList from '@salesforce/apex/ContactController.getContactList';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
const columns = [
{ label: 'First Name', fieldName: 'FirstName' },
{ label: 'Last Name', fieldName: 'LastName' },
{ label: 'Title', fieldName: 'Title' },
{ label: 'Phone', fieldName: 'Phone', type: 'phone' },
{ label: 'Email', fieldName: 'Email', type: 'email' }
<template>
<template if:true={contact}>
<lightning-datatable key-field="Id"
data={contact}
columns={columns}>
</lightning-datatable>
</template>
</template>
@dhaniksahni
dhaniksahni / ObjectRecognition.css
Created August 8, 2020 10:45
ObjectRecognition in Lightning Web Component
.lgc-bg {
background-color: rgb(242, 242, 242);
}
.slds-spinner_container {
top: 50% !important;
bottom: 50% !important;
}
@dhaniksahni
dhaniksahni / ObjectRecogRequest.apxc
Last active August 8, 2020 18:23
Google Cloud Object Recognition
public class ObjectRecogRequest {
public list<request> requests{get;set;}
public class request{
public image image{get;set;}
public list<feature> features{get;set;}
}
public class image{
public Blob content{get;set;}
}
@dhaniksahni
dhaniksahni / imageMap.css
Created August 1, 2020 11:20
Dynamic Image Map in Salesfore LWC
.area
{
pointer-events:none;
}
@dhaniksahni
dhaniksahni / ImageMapController.apxc
Created August 1, 2020 11:13
Get Image Detail for Image map
public class ImageMapController {
@auraenabled(cacheable=true)
public static List<Image__c> getAllImages()
{
return [select id,name from Image__c];
}
@auraenabled(cacheable=true)
public static ImageResponse getImage(string id)
.lgc-bg {
background-color: rgb(242, 242, 242);
}
.slds-spinner_container {
top: 50% !important;
bottom: 50% !important;
}
@dhaniksahni
dhaniksahni / LogoRecognizer.apxc
Last active July 30, 2020 19:26
Logo Recognition Using Google in Salesforce
public class LogoRecognizer {
public static string getAccessToken()
{
GoogleAuthSetting__mdt mapping =
[SELECT AccessToken__c, Label FROM GoogleAuthSetting__mdt WHERE Label='Fitness' and DeveloperName='Fitness'];
return mapping.AccessToken__c;
}
@auraenabled(cacheable=true)
@dhaniksahni
dhaniksahni / viewFile.html
Last active August 1, 2020 15:58
View S3 File information using LWC
<template>
<template if:true={imageUrl}>
<iframe src={imageUrl}></iframe>
</template>
</template>