Skip to content
Merged

Dev #2840

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,7 @@
const reportingAiUrl = globalThis.reportingAiUrl;
const container = document.getElementById('container');

const initializeAIReporting = async () => {
if (!container) {
return;
}

if (!reportingAiUrl) {
showInitializationError(container, 'AI Reporting is not configured.');
return;
}

let reportingUrl;
try {
reportingUrl = new URL(reportingAiUrl);
} catch (error) {
showInitializationError(container, 'AI Reporting is not configured correctly.', error);
return;
}

let token;
try {
token = await unity.grantManager.identity.jwtToken.generateJWTToken();
} catch (error) {
showInitializationError(container, 'Failed to initialize AI Reporting. Please refresh the page and try again.', error);
return;
}

const buildReportingIframe = (reportingUrl, token) => {
const iframe = document.createElement('iframe');

iframe.style.width = '100%';
Expand Down Expand Up @@ -66,7 +41,32 @@
};

iframe.src = reportingUrl.href;
container.appendChild(iframe);
return iframe;
};

initializeAIReporting();
if (container) {
if (!reportingAiUrl) {
showInitializationError(container, 'AI Reporting is not configured.');
} else {
let reportingUrl;
try {
reportingUrl = new URL(reportingAiUrl);
} catch (error) {
reportingUrl = null;
showInitializationError(container, 'AI Reporting is not configured correctly.', error);
}

if (reportingUrl) {
const initializeReporting = async () => {
try {
const token = await unity.grantManager.identity.jwtToken.generateJWTToken();
container.appendChild(buildReportingIframe(reportingUrl, token));
} catch (error) {
showInitializationError(container, 'Failed to initialize AI Reporting. Please refresh the page and try again.', error);
}
};

initializeReporting();

Check warning on line 69 in applications/Unity.GrantManager/modules/Unity.AI/src/Unity.AI.Web/Pages/AIReporting/Index.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer top-level await over an async function `initializeReporting` call.

See more on https://sonarcloud.io/project/issues?id=bcgov_Unity&issues=AaAcVaJkK395OeeRp_Xe&open=AaAcVaJkK395OeeRp_Xe&pullRequest=2840
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,12 @@ $(function () {
return hash;
}
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
const char = str.codePointAt(i);
hash = ((hash << 5) - hash) + char;
hash |= 0;
if (char > 0xFFFF) {
i++;
}
}
return hash;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ const emailGroupsManager = {
'createAddUserBtn',
function(selectedUser) {
// Add to selected users if not already there
if (!selectedUsers.find(u => u.userId === selectedUser.userId)) {
if (!selectedUsers.some(u => u.userId === selectedUser.userId)) {
const newUser = {
userId: selectedUser.userId,
userName: selectedUser.userName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
toast: true,
position: 'top-end',
icon: 'info',
title: sender,
titleText: String(sender || ''),
text: message,
showConfirmButton: false,
timer: 5000,
Expand Down Expand Up @@ -970,7 +970,7 @@
toast: true,
position: 'top-end',
icon: 'info',
title: sender,
titleText: String(sender || ''),
text: message,
showConfirmButton: false,
timer: 5000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ $(function () {
}

function formatName(userData) {
return typeof userData !== 'undefined' && userData !== null ? `${userData?.name} ${userData?.surname}` : "";
return userData !== undefined && userData !== null ? `${userData?.name} ${userData?.surname}` : "";
}

function getApprovalDateColumn(columnIndex, level) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(function () {
$(function () {
const l = abp.localization.getResource('Payments');
$('.unity-currency-input').maskMoney({});
$('.unity-currency-input').each(function () {
Expand Down Expand Up @@ -61,10 +61,8 @@
inputElement.hasClass('unity-currency-input') ||
inputElement.hasClass('numeric-mask')
) {
paymentInfoObj[input.name.split('.')[1]] = input.value.replace(
/,/g,
''
);
const fieldName = input.name.split('.')[1];
paymentInfoObj[fieldName] = input.value.replaceAll(',', '');
} else {
paymentInfoObj[input.name.split('.')[1]] = input.value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ $(function () {
setExternalSearchFilter(iDt);

if ($('#btn-toggle-filter').length) {
if ($.fn.dataTable !== 'undefined' && typeof $.fn.dataTable.FilterRow !== 'undefined') {
if ($.fn.dataTable !== undefined && $.fn.dataTable.FilterRow !== undefined) {
const filterRow = new $.fn.dataTable.FilterRow(iDt.settings()[0], {
buttonId: 'btn-toggle-filter',
buttonText: FilterDesc.Default,
buttonTextActive: FilterDesc.With_Filter,
enablePopover: $.fn.popover !== 'undefined'
enablePopover: $.fn.popover !== undefined
});

iDt.settings()[0]._filterRow = filterRow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
@if (CurrentUser.IsInRole("ITOperations"))
{
<abp-dropdown-item href="/UnityAdmin">Unity Admin</abp-dropdown-item>
<abp-dropdown-item href="/UnityMessaging">Unity Messaging</abp-dropdown-item>
@if (await FeatureChecker.IsEnabledAsync("Unity.Notifications.DirectMessaging"))
{
<abp-dropdown-item href="/UnityMessaging">Unity Messaging</abp-dropdown-item>
}
<abp-dropdown-item href="/ExceptionLogs">Exception Logs</abp-dropdown-item>
}

Expand Down
13 changes: 6 additions & 7 deletions applications/Unity.GrantManager/scripts/Get-SonarIssues.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
or attaching to a PR instead of screen-scraping the SonarQube UI.

.PARAMETER ServerUrl
SonarQube server URL. Default: https://sonarqube.econ.gov.bc.ca/sonar. Set this to
https://sonarcloud.io when querying SonarCloud.
SonarQube server URL. Default: https://sonarcloud.io, matching sonar-project.properties.

.PARAMETER ProjectKey
SonarQube project (component) key. Default: UnityScanKey.
SonarQube project (component) key. Default: bcgov_Unity.

.PARAMETER Branch
Branch name to query. If omitted, you'll be prompted to pick the current git branch, one of
Expand Down Expand Up @@ -70,9 +69,9 @@
.\Get-SonarIssues.ps1 -Branch main -FixLevel Quick
#>
param(
[string]$ServerUrl = "https://sonarqube.econ.gov.bc.ca/sonar",
[string]$ServerUrl = "https://sonarcloud.io",

[string]$ProjectKey = "UnityScanKey",
[string]$ProjectKey = "bcgov_Unity",

[string]$Branch = "",

Expand Down Expand Up @@ -281,9 +280,9 @@ function Get-SonarIssuePage {
if (-not $response.IsSuccessStatusCode) {
$status = [int]$response.StatusCode
if ($status -eq 401 -or $status -eq 403) {
throw "SonarCloud returned $status - pass -Token (or set `$env:SONAR_TOKEN) with access to '$ProjectKey'."
throw "Sonar server returned $status for '$ProjectKey' at '$ServerUrl'. Pass -Token (or set `$env:SONAR_TOKEN) with browse access to this project."
}
throw "SonarCloud returned $status`: $text"
throw "Sonar server returned $status`: $text"
}

return $text | ConvertFrom-Json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ $(function () {

// Make sure input string have no error with the plugin
LinksInput.prototype.anyErrors = function (string) {
if (!this.options.duplicate && this.arr.indexOf(string) != -1) {
if (!this.options.duplicate && this.arr.includes(string)) {
console.log('duplicate found " ' + string + ' " ')
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
|| error?.responseText
|| '';

const match = String(message).match(/try again in\s+(\d+)\s+second/i);
const match = /try again in\s+(\d+)\s+second/i.exec(String(message));
return match ? Number(match[1]) : 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ function defineTagSummaryColumnDefs() {
title: "Count",
name: 'totalCount',
data: 'totalCount'
});

columnDefs.push({
}, {
title: "Actions",
name: 'actions',
data: 'tag.name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ $(function () {
let groupedValues = Object.values(groupedTags);
if (groupedValues.length === 0) return [];

return groupedValues.reduce(function (prev, next) {
return groupedValues.slice(1).reduce(function (prev, next) {
return prev.filter(p => hasMatchingTagId(p, next));
});
}, groupedValues[0]);
}

function filterUncommonTags(tagList, commonTags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function downloadChefsFile(event) {
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
link.remove();
abp.notify.success('', 'The file has been downloaded successfully.');
},
error: function (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function initTribute(mentionData) {
let tribute = new Tribute({
values: mentionData,
selectTemplate: function (item) {
if (typeof item === 'undefined') return null;
if (item === undefined) return null;
if (this.range.isContentEditable(this.current.element)) {
return (`<span contenteditable="false"><a class="name-highlighted" href="#" onclick="return false;">${item.original.value}</a><span>`);
}
Expand Down
Loading