Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
Security fixes for Demo Apps dir (#2)
Browse files Browse the repository at this point in the history
* Revert "[DEVREL-1180] Refactor: Ticket-merger Freshdesk sample-app  (#340)"

This reverts commit c068b68.

* Revert "👌 IMPROVE: add whitelisting domain support (#342)"

This reverts commit 2b451e4.

* Revert "🐛 FIX: whitelisting changes (#341)"

This reverts commit bc05622.

* Revert "[DEVREL-1166] Tweak: Spinner in Joke component (#331)"

This reverts commit e42ea10.
  • Loading branch information
hemchander23 committed Jun 10, 2021
1 parent aec4d80 commit 42edb18
Show file tree
Hide file tree
Showing 21 changed files with 182 additions and 230 deletions.
4 changes: 4 additions & 0 deletions Demo-Apps/ticket_merger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
work
build
.frsh
3 changes: 3 additions & 0 deletions Demo-Apps/ticket_merger/config/iparam_test_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"apiKey": "Enter you API Key"
}
4 changes: 2 additions & 2 deletions Demo-Apps/ticket_merger/config/iparams.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"display_name": "Window Duration",
"description": "The window duration (in minutes) within which similar tickets will be merged.",
"type": "dropdown",
"options": ["10", "30", "60"],
"default_value": "60"
"options": [10, 30, 60],
"default_value": 60
},
"apiKey": {
"display_name": "API Key",
Expand Down
2 changes: 1 addition & 1 deletion Demo-Apps/ticket_merger/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports = {
domain: payload.domain,
apiKey: iparams.apiKey,
primaryTicket: primaryTicket,
windowDuration: parseInt(iparams.window),
windowDuration: iparams.window,
secondaryTicket: secondaryTicket
});
})
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@
<head>
<link rel="stylesheet" type="text/css" href="styles/generics.css" />
<script src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script>
<script
type="module"
src="https://unpkg.com/@freshworks/crayons/dist/crayons/crayons.esm.js"
></script>
<script
nomodule
src="https://unpkg.com/@freshworks/crayons/dist/crayons/crayons.js"
></script>
<script type="module" src="https://unpkg.com/@freshworks/crayons/dist/crayons/crayons.esm.js"></script>
<script nomodule src="https://unpkg.com/@freshworks/crayons/dist/crayons/crayons.js"></script>
</head>

<body>
<main>
<section>
<div class="spinner-div">
<fw-spinner size="medium" color="green"></fw-spinner>
</div>
<div class="card text-center">
<div class="card-body">
<div class="space-below" id="setup"></div>
<fw-button class="space-below" id="punchline-btn" color="primary">
<fw-icon name="bulb" size="18" color="white"></fw-icon>
</fw-button>
<div id="punchline"></div>
<div class="question" id="setup"></div>
<br>
<fw-button id="punchline-btn" color="primary"> <fw-icon name="bulb" size="18" color="white"></fw-icon></fw-button>
<br>
<br>
<div class="answer" id="punchline"></div>
</div>
</div>
</section>
</main>
</body>
<script src="scripts/app.js"></script>
</html>
</html>
Original file line number Diff line number Diff line change
@@ -1,56 +1,49 @@
function getJoke() {
const JOKE_ENDPOINT = "https://official-joke-api.appspot.com/random_joke";
client.request.get(JOKE_ENDPOINT).then(function (data) {
showSpinner(data);
const setup = JSON.parse(data.response).setup;
const punchline = JSON.parse(data.response).punchline;
displayPunchline(punchline);
pick(".card").style.display = "block";
pick(
"#setup"
).innerHTML = `<fw-label value="Question:" color="red"></fw-label> ${setup}`;
}),
function (error) {
console.error("Error fetching data from endpoint", error);
};
}

function showSpinner(data) {
if (data) {
pick(".spinner-div").style.display = "none";
}
}
const JOKE_ENDPOINT = 'https://official-joke-api.appspot.com/random_joke';

function displayPunchline(punchline) {
pick("#punchline-btn").addEventListener("click", function () {
pick(
"#punchline"
).innerHTML = `<fw-label value="${punchline}" color="green"></fw-label>`;
});
function getJoke() {
client.request.get(JOKE_ENDPOINT).then(
function (data) {
let setup = JSON.parse(data.response).setup;
punchline = JSON.parse(data.response).punchline;
document.getElementById('setup').innerHTML = `<fw-label value="Question:" color="red"></fw-label> ${setup}`;
}), function(error) {
console.log(error )
}
}

function pick(selector) {
return document.querySelector(selector);
function addListner() {
document.getElementById('punchline-btn').addEventListener('click', function() {
document.getElementById('punchline').innerHTML = `<fw-label value="${punchline}" color="green"></fw-label>`
})
}

document.onreadystatechange = function () {
if (document.readyState === "interactive") renderApp();
if (document.readyState === 'interactive') renderApp();

function renderApp() {
var onInit = app.initialized();

onInit.then(getClient).catch(handleErr);

function getClient(_client) {
window.client = _client;
client.events.on("app.activated", onAppActivate);
client.events.on('app.activated', onAppActivate);
}
}
};

function onAppActivate() {
var textElement = document.getElementById('apptext');
var getContact = client.data.get('contact');
getContact.then(showContact).catch(handleErr);

function showContact(payload) {
textElement.innerHTML = `Ticket created by ${payload.contact.name}`;
}
getJoke();
addListner();
}

function handleErr(err) {
console.error(`Error occurred. Details:`, err);
console.error(`Error occured. Details:`, err);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,28 @@ main {
justify-content: center;
align-items: center;
font-size: 1rem;
font-family: "Lucida Sans", "Lucida Grande";
font-family: 'Lucida Sans', 'Lucida Grande';
}

.card {
position: relative;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0, 0, 0, 0.125);
border-radius: 0.5rem;
padding: 10px;
border: 1px solid rgba(0, 0, 0, .125);
border-radius: .50rem;
padding: 10px;
margin: 100px;
display: none;
}

.card-body {
flex: 1 1 auto;
padding: 1.25rem;
flex: 1 1 auto;
padding: 1.25rem
}

.card-title {
margin-bottom: 0.75rem;
margin-bottom: .75rem
}

.text-center {
text-align: center;
}

.spinner-div {
display: grid;
justify-content: center;
align-content: center;
margin-top: 20vh;
}

.space-below {
margin-bottom: 1rem;
}
text-align: center
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@
<head>
<link rel="stylesheet" type="text/css" href="styles/generics.css" />
<script src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script>
<script
type="module"
src="https://unpkg.com/@freshworks/crayons/dist/crayons/crayons.esm.js"
></script>
<script
nomodule
src="https://unpkg.com/@freshworks/crayons/dist/crayons/crayons.js"
></script>
<script type="module" src="https://unpkg.com/@freshworks/crayons/dist/crayons/crayons.esm.js"></script>
<script nomodule src="https://unpkg.com/@freshworks/crayons/dist/crayons/crayons.js"></script>
</head>

<body>
<main>
<section>
<div class="spinner-div">
<fw-spinner size="medium" color="green"></fw-spinner>
</div>
<div class="card text-center">
<div class="card-body">
<div class="space-below" id="setup"></div>
<fw-button class="space-below" id="punchline-btn" color="primary">
<fw-icon name="bulb" size="18" color="white"></fw-icon>
</fw-button>
<div id="punchline"></div>
<div class="question" id="setup"></div>
<br>
<fw-button id="punchline-btn" color="primary"> <fw-icon name="bulb" size="18" color="white"></fw-icon></fw-button>
<br>
<br>
<div class="answer" id="punchline"></div>
</div>
</div>
</section>
</main>
</body>
<script src="scripts/app.js"></script>
</html>
</html>
Original file line number Diff line number Diff line change
@@ -1,56 +1,49 @@
function getJoke() {
const JOKE_ENDPOINT = "https://official-joke-api.appspot.com/random_joke";
client.request.get(JOKE_ENDPOINT).then(function (data) {
showSpinner(data);
const setup = JSON.parse(data.response).setup;
const punchline = JSON.parse(data.response).punchline;
displayPunchline(punchline);
pick(".card").style.display = "block";
pick(
"#setup"
).innerHTML = `<fw-label value="Question:" color="red"></fw-label> ${setup}`;
}),
function (error) {
console.error("Error fetching data from endpoint", error);
};
}

function showSpinner(data) {
if (data) {
pick(".spinner-div").style.display = "none";
}
}
const JOKE_ENDPOINT = 'https://official-joke-api.appspot.com/random_joke';

function displayPunchline(punchline) {
pick("#punchline-btn").addEventListener("click", function () {
pick(
"#punchline"
).innerHTML = `<fw-label value="${punchline}" color="green"></fw-label>`;
});
function getJoke() {
client.request.get(JOKE_ENDPOINT).then(
function (data) {
let setup = JSON.parse(data.response).setup;
punchline = JSON.parse(data.response).punchline;
document.getElementById('setup').innerHTML = `<fw-label value="Question:" color="red"></fw-label> ${setup}`;
}), function(error) {
console.log(error )
}
}

function pick(selector) {
return document.querySelector(selector);
function addListner() {
document.getElementById('punchline-btn').addEventListener('click', function() {
document.getElementById('punchline').innerHTML = `<fw-label value="${punchline}" color="green"></fw-label>`
})
}

document.onreadystatechange = function () {
if (document.readyState === "interactive") renderApp();
if (document.readyState === 'interactive') renderApp();

function renderApp() {
var onInit = app.initialized();

onInit.then(getClient).catch(handleErr);

function getClient(_client) {
window.client = _client;
client.events.on("app.activated", onAppActivate);
client.events.on('app.activated', onAppActivate);
}
}
};

function onAppActivate() {
var textElement = document.getElementById('apptext');
var getContact = client.data.get('contact');
getContact.then(showContact).catch(handleErr);

function showContact(payload) {
textElement.innerHTML = `Ticket created by ${payload.contact.name}`;
}
getJoke();
addListner();
}

function handleErr(err) {
console.error(`Error occurred. Details:`, err);
console.error(`Error occured. Details:`, err);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,28 @@ main {
justify-content: center;
align-items: center;
font-size: 1rem;
font-family: "Lucida Sans", "Lucida Grande";
font-family: 'Lucida Sans', 'Lucida Grande';
}

.card {
position: relative;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0, 0, 0, 0.125);
border-radius: 0.5rem;
padding: 10px;
border: 1px solid rgba(0, 0, 0, .125);
border-radius: .50rem;
padding: 10px;
margin: 100px;
display: none;
}

.card-body {
flex: 1 1 auto;
padding: 1.25rem;
flex: 1 1 auto;
padding: 1.25rem
}

.card-title {
margin-bottom: 0.75rem;
margin-bottom: .75rem
}

.text-center {
text-align: center;
}

.spinner-div {
display: grid;
justify-content: center;
align-content: center;
margin-top: 20vh;
}

.space-below {
margin-bottom: 1rem;
}
text-align: center
}
Loading

0 comments on commit 42edb18

Please sign in to comment.