Skip to content

Instantly share code, notes, and snippets.

View hicglobalsolutions's full-sized avatar
🎯
Focusing

HIC Global Solutions hicglobalsolutions

🎯
Focusing
View GitHub Profile
@hicglobalsolutions
hicglobalsolutions / If you wanna add CSS to make it
Created April 25, 2024 12:19
look cooler and show your craftiness, then you are good to go.
/* BarcodeGenerator.css */
.THIS {
font-family: 'Arial', sans-serif;
max-width: 400px;
margin: 0 auto;
text-align: center;
padding: 20px;
border-radius: 10px;
}
@hicglobalsolutions
hicglobalsolutions / Replace the existing code in ‘BarcodeGeneratorHelper.js
Created April 25, 2024 12:17
with the new code and witness the enchanting capabilities as your Aura Component connects with JsBarcode.
({
validateBarcodeInput: function(barcodeValue, selectedFormat) {
// Check if the barcodeValue is empty
if (!barcodeValue || barcodeValue.trim() === '') {
return { success: false, errorMessage: "Barcode value cannot be empty.", checksum: "" };
}
// Perform additional validation based on selected format
switch(selectedFormat) {
@hicglobalsolutions
hicglobalsolutions / BarcodeGeneratorController.js
Created April 25, 2024 12:11
swap out the code, and let the magic happen. This is where your Aura Component taps into JsBarcode's enchanting powers.
({
generateBarcode : function(component, event, helper) {
// Reset previous barcode output
component.set("v.barcodeGenerated", false);
// Get the barcode value and selected format
var barcodeValue = component.get("v.barcodeValue");
var selectedFormat = component.get("v.selectedFormat");
@hicglobalsolutions
hicglobalsolutions / Replace Default Code
Last active April 25, 2024 12:08
Within the newly created Aura Component file, replace the default code with the provided special example code for barcode generation.
<aura:component>
<ltng:require scripts="{!$Resource.Barcode + '/Barcode/JsBarcode.all.min.js'}"/>
<aura:attribute name="barcodeValue" type="String" />
<aura:attribute name="selectedFormat" type="String" default="CODE128" />
<aura:attribute name="barcodeGenerated" type="Boolean" default="false" />
<aura:attribute name="errorMessage" type="String" />
@hicglobalsolutions
hicglobalsolutions / Create cloud_Pub_sub.js-meta.xml file
Created April 4, 2024 14:50
In the cloud_Pub_sub.js-meta.xml file paste the below code.
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__HomePage</target>
<target>lightning__RecordPage</target>
<target>lightningCommunity__Page</target>
<target>lightningCommunity__Default</target>
</targets>
@hicglobalsolutions
hicglobalsolutions / Create a Publisher.css file
Created April 4, 2024 14:11
Create new file in same folder and paste the below code on it
html, body {
min-height: 100%;
padding: 0;
margin: 0;
font-family: Roboto, Arial, sans-serif;
font-size: 14px;
color: #666;
}
h1 {
margin: 0 0 20px;
@hicglobalsolutions
hicglobalsolutions / Create a cloud_Pub_sub.css file
Created April 4, 2024 13:09
In the cloud_Pub_sub.js-meta.xml file paste the below code.
.shadow-box {
box-shadow: 0 0 2px #0176d3;
margin-bottom: 5px;
}
@hicglobalsolutions
hicglobalsolutions / Create cloud_Pub_Sub.js file
Created April 4, 2024 13:07
In the cloud_Pub_Sub.js file paste below code
import { LightningElement, track } from 'lwc';
import pullMessages from '@salesforce/apex/GoogleCloudPubSubService.pullMessages';
export default class Cloud_Pub_Sub extends LightningElement {
@track messages = [];
getMessages() {
console.log('onclick');
try {
pullMessages()
.then(result => {
@hicglobalsolutions
hicglobalsolutions / In the cloud_Pub_Sub.html file paste this code
Created April 4, 2024 13:06
After creating LWC now create the HTML file
<template>
<div class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__body">
<h2 class="slds-card__header-title">
<a href="#" class="slds-card__header-link slds-truncate" title="Data From Website">
<span>Data From Website</span>
</a>
</h2>
@hicglobalsolutions
hicglobalsolutions / Create Apex class and Lightning Web Component in Salesforce
Created April 4, 2024 13:03
Create a new Apex class with the name GoogleCloudPubSubService.
public with sharing class GoogleCloudPubSubService {
// AuraEnabled annotation makes the method available to Lightning components
public static String Endpoint ='https://pubsub.googleapis.com/v1/<Replace with Your Subscription Name>:';
public static String token = 'Bearer ' + '<Replace with your Generated token>';
@AuraEnabled
public static List<Map<String, Object>> pullMessages() {
// Initialize a map to hold the response body
Map<String, Object> responseBody = new Map<String, Object>();
// Initialize a list to hold the processed messages data
List<Map<String, Object>> messagesData = new List<Map<String, Object>>();