Api Credentials ophalen via route, Postcodes capslock maken + aan elkaar, BV infix toevoegen aan Bestteling URL

This commit is contained in:
2024-10-07 15:32:12 +02:00
parent 6300da2b64
commit 598886e578
7 changed files with 49 additions and 47 deletions

View File

@@ -12,7 +12,8 @@
ul {
margin: 0;
padding: 0; }
padding: 0;
}
.ms-welcome__header {
padding: 20px;

View File

@@ -1 +1 @@
{"version":3,"file":"commands.js","mappings":"AAOAA,OAAOC,SAAQ,WACb,IAuBFD,OAAOE,QAAQC,UAAU,UAhBzB,SAAgBC,GACd,IAAMC,EAAU,CACdC,KAAMN,OAAOO,aAAaC,4BAA4BC,qBACtDJ,QAAS,oBACTK,KAAM,aACNC,YAAY,GAIdX,OAAOY,QAAQC,QAAQC,KAAKC,qBAAqBC,aAAa,SAAUX,GAGxED,EAAMa,WACR","sources":["webpack://office-addin-taskpane-js/./src/commands/commands.js"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n * See LICENSE in the project root for license information.\n */\n\n/* global Office */\n\nOffice.onReady(() => {\n // If needed, Office.js is ready to be called.\n});\n\n/**\n * Shows a notification when the add-in command is executed.\n * @param event {Office.AddinCommands.Event}\n */\nfunction action(event) {\n const message = {\n type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,\n message: \"Performed action.\",\n icon: \"Icon.80x80\",\n persistent: true,\n };\n\n // Show a notification message.\n Office.context.mailbox.item.notificationMessages.replaceAsync(\"action\", message);\n\n // Be sure to indicate when the add-in command function is complete.\n event.completed();\n}\n\n// Register the function with Office.\nOffice.actions.associate(\"action\", action);\n"],"names":["Office","onReady","actions","associate","event","message","type","MailboxEnums","ItemNotificationMessageType","InformationalMessage","icon","persistent","context","mailbox","item","notificationMessages","replaceAsync","completed"],"sourceRoot":""}
{"version":3,"file":"commands.js","mappings":"AAOAA,OAAOC,SAAQ,WACb,IAuBFD,OAAOE,QAAQC,UAAU,UAhBzB,SAAgBC,GACd,IAAMC,EAAU,CACdC,KAAMN,OAAOO,aAAaC,4BAA4BC,qBACtDJ,QAAS,oBACTK,KAAM,aACNC,YAAY,GAIdX,OAAOY,QAAQC,QAAQC,KAAKC,qBAAqBC,aAAa,SAAUX,GAGxED,EAAMa,WACR","sources":["webpack://office-addin-taskpane-js/./src/commands/commands.js"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n * See LICENSE in the project root for license information.\r\n */\r\n\r\n/* global Office */\r\n\r\nOffice.onReady(() => {\r\n // If needed, Office.js is ready to be called.\r\n});\r\n\r\n/**\r\n * Shows a notification when the add-in command is executed.\r\n * @param event {Office.AddinCommands.Event}\r\n */\r\nfunction action(event) {\r\n const message = {\r\n type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,\r\n message: \"Performed action.\",\r\n icon: \"Icon.80x80\",\r\n persistent: true,\r\n };\r\n\r\n // Show a notification message.\r\n Office.context.mailbox.item.notificationMessages.replaceAsync(\"action\", message);\r\n\r\n // Be sure to indicate when the add-in command function is complete.\r\n event.completed();\r\n}\r\n\r\n// Register the function with Office.\r\nOffice.actions.associate(\"action\", action);\r\n"],"names":["Office","onReady","actions","associate","event","message","type","MailboxEnums","ItemNotificationMessageType","InformationalMessage","icon","persistent","context","mailbox","item","notificationMessages","replaceAsync","completed"],"sourceRoot":""}

49
dist/manifest.xml vendored
View File

@@ -2,15 +2,15 @@
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>6aefdc1b-c9c2-4f92-95c7-af96bd9ced13</Id>
<Version>1.0.0.0</Version>
<ProviderName>Contoso</ProviderName>
<ProviderName>OVAS</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="order-finder"/>
<Description DefaultValue="A template to get started."/>
<IconUrl DefaultValue="https://www.contoso.com/assets/icon-64.png"/>
<HighResolutionIconUrl DefaultValue="https://www.contoso.com/assets/icon-128.png"/>
<SupportUrl DefaultValue="https://www.contoso.com/help"/>
<DisplayName DefaultValue="Order finder OVAS"/>
<Description DefaultValue="Vind bestellingen die eventueel bij de e-mail horen"/>
<IconUrl DefaultValue="https://outlookplugin.ovas.nl/assets/icon-64.png"/>
<HighResolutionIconUrl DefaultValue="https://outlookplugin.ovas.nl/assets/icon-128.png"/>
<SupportUrl DefaultValue="https://ovas.nl"/>
<AppDomains>
<AppDomain>https://www.contoso.com</AppDomain>
<AppDomain>https://outlookplugin.ovas.nl</AppDomain>
</AppDomains>
<Hosts>
<Host Name="Mailbox"/>
@@ -23,7 +23,7 @@
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://www.contoso.com/taskpane.html"/>
<SourceLocation DefaultValue="https://outlookplugin.ovas.nl/taskpane.html"/>
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
@@ -62,21 +62,6 @@
<SourceLocation resid="Taskpane.Url"/>
</Action>
</Control>
<Control xsi:type="Button" id="ActionButton">
<Label resid="ActionButton.Label"/>
<Supertip>
<Title resid="ActionButton.Label"/>
<Description resid="ActionButton.Tooltip"/>
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>action</FunctionName>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
@@ -85,22 +70,20 @@
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://www.contoso.com/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://www.contoso.com/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://www.contoso.com/assets/icon-80.png"/>
<bt:Image id="Icon.16x16" DefaultValue="https://outlookplugin.ovas.nl/assets/icon-16.png"/>
<bt:Image id="Icon.32x32" DefaultValue="https://outlookplugin.ovas.nl/assets/icon-32.png"/>
<bt:Image id="Icon.80x80" DefaultValue="https://outlookplugin.ovas.nl/assets/icon-80.png"/>
</bt:Images>
<bt:Urls>
<bt:Url id="Commands.Url" DefaultValue="https://www.contoso.com/commands.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://www.contoso.com/taskpane.html"/>
<bt:Url id="Commands.Url" DefaultValue="https://outlookplugin.ovas.nl/commands.html"/>
<bt:Url id="Taskpane.Url" DefaultValue="https://outlookplugin.ovas.nl/taskpane.html"/>
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Contoso Add-in"/>
<bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
<bt:String id="ActionButton.Label" DefaultValue="Perform an action"/>
<bt:String id="GroupLabel" DefaultValue="OVAS (Zoek bestellingen)"/>
<bt:String id="TaskpaneButton.Label" DefaultValue="Bestellingen zoeken"/>
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opens a pane displaying all available properties."/>
<bt:String id="ActionButton.Tooltip" DefaultValue="Perform an action when clicked."/>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Opent een paneel waar je bestellingen kan zoeken voor de des betreffende e-mail"/>
</bt:LongStrings>
</Resources>
</VersionOverrides>

2
dist/taskpane.html vendored
View File

@@ -1 +1 @@
<!doctype html><html><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=Edge"/><meta name="viewport" content="width=device-width,initial-scale=1"><title>Contoso Task Pane Add-in</title><script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script><link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/11.0.0/css/fabric.min.css"/><link href="fc95fa02fd204a05f6f4.css" rel="stylesheet"/><script defer="defer" src="polyfill.js"></script><script defer="defer" src="taskpane.js"></script></head><body class="ms-font-m ms-welcome ms-Fabric"><header class="ms-welcome__header"><h1 class="ms-font-su" style="color:#fff">OVAS</h1></header><main style="color:#fff" id="app-body" class="ms-welcome__main" style="display:none"><ul class="ms-List ms-welcome__features"><li class="ms-ListItem"><i class="ms-Icon ms-Icon--Ribbon ms-font-xl"></i> <span class="ms-font-m">Zoek bijbehorende bestellingen efficient vanuit Outlook</span></li></ul><button class="run-button" id="run"><span id="btn-text">Zoek naar bestellingen</span><div class="loader" id="loader"></div></button><p><label id="item-subject"></label></p><div id="results"></div></main></body></html>
<!doctype html><html><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=Edge"/><meta name="viewport" content="width=device-width,initial-scale=1"><title>Contoso Task Pane Add-in</title><script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script><link rel="stylesheet" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/11.0.0/css/fabric.min.css"/><link href="c08679ea19c3178e4320.css" rel="stylesheet"/><script defer="defer" src="polyfill.js"></script><script defer="defer" src="taskpane.js"></script></head><body class="ms-font-m ms-welcome ms-Fabric"><header class="ms-welcome__header"><h1 class="ms-font-su" style="color:#fff">OVAS</h1></header><main style="color:#fff" id="app-body" class="ms-welcome__main" style="display:none"><ul class="ms-List ms-welcome__features"><li class="ms-ListItem"><i class="ms-Icon ms-Icon--Ribbon ms-font-xl"></i> <span class="ms-font-m">Zoek bijbehorende bestellingen efficient vanuit Outlook</span></li></ul><button class="run-button" id="run"><span id="btn-text">Zoek naar bestellingen</span><div class="loader" id="loader"></div></button><p><label id="item-subject"></label></p><div id="results"></div></main></body></html>

2
dist/taskpane.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -6,17 +6,14 @@
/* global document, Office */
import axios from "axios";
const api_tokens = {
prod: "Uvk3eiHf2NB8ahRC1ijXp0N1YrrhZ1eakIG9gTA0",
};
// axios conf
axios.defaults.headers.common["api-key"] = api_tokens.prod;
axios.defaults.headers.common["api-language"] = "nl";
// url = https://backoffice.sociale-controle.nl
const localApiUrl = "https://backoffice.sociale-controle.nl/api/zoek_bestelling";
const orderUrlEdit = "https://backoffice.sociale-controle.nl/bestellingen/edit/";
const orderUrlIndex = "https://backoffice.sociale-controle.nl/bestellingen";
const apiCredentialUrl = "https://backoffice.sociale-controle.nl/api/api_credentials";
Office.onReady((info) => {
if (info.host === Office.HostType.Outlook) {
@@ -55,6 +52,19 @@ export async function run() {
showResults(results);
}
async function getApiCredential() {
let key = [];
await axios
.get(apiCredentialUrl)
.then(function (res) {
key = res.data.key ?? "";
})
.catch((err) => err);
return key;
}
// Animation function for loader on button
function loadAnimation(animate) {
const loadButton = document.getElementById("run");
@@ -78,9 +88,14 @@ function loadAnimation(animate) {
async function search(searchInfo) {
let results = [];
let key = await getApiCredential();
await axios
.get(localApiUrl, {
params: searchInfo,
headers: {
"api-key": key,
},
})
.then(function (res) {
results = res.data.results ?? [];
@@ -107,8 +122,11 @@ function getInitials(name) {
function getPostalCodesFromText(emailBody) {
const regex = /\b\d{4}\s?[A-Z]{2}\b/g;
let postalCodes = emailBody.match(regex);
return btoa(emailBody.match(regex));
let postalCodesWithoutWhiteSpaces = postalCodes.map((i) => i.replace(/\s/g, "").toUpperCase());
return btoa(postalCodesWithoutWhiteSpaces);
}
function showResults(results) {
@@ -117,15 +135,15 @@ function showResults(results) {
if (results.length > 0) {
results.forEach((result) => {
resultDiv.innerHTML += resultsFoundButton(result.id, result.lastname);
resultDiv.innerHTML += resultsFoundButton(result.id, result.lastname, result.url_infix);
});
} else {
resultDiv.innerHTML = noResultsFoundButton();
}
}
function resultsFoundButton(id, customer) {
return `<button type="button" target="_blank" onclick="location.href='${orderUrlEdit}${id}'" class="result-button" style="text-decoration: none;">
function resultsFoundButton(id, customer, urlInfix) {
return `<button type="button" target="_blank" onclick="location.href='${orderUrlEdit}${id}?bv=${urlInfix}'" class="result-button" style="text-decoration: none;">
<span class="btn-text" style="display: block;">Order ID: ${id} - ${customer}</span>
</button>`;
}