inferno_core 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/inferno/public/common.js +48 -0
- data/lib/inferno/public/session.js +35 -0
- data/lib/inferno/public/test_kits.js +59 -0
- data/lib/inferno/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8f8cb64cc07cf0ea3225a930fa47c6e54619da91d739912452cf0b8c8e27568
|
4
|
+
data.tar.gz: fcc3c0d0b6f20a0cb34021f26a79f32a8abff955333a105a4b7cc94de0307db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 749b0cc95ead3ef3a7c200918f314aae140c789f98d10199f26b65d973c23b269115cfdbe45e19358e0a13cc71f284c7366f7c8b90c29277b52eaed95215afc3
|
7
|
+
data.tar.gz: 593752aa7a14ec8c04b921403eae863e72d84e2de4f452ea656d2a56bf102597e5a88c444447cb02ea0bf93918039cf51ac88dce58338686da1d7cf8f861f5d1
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/* UTILITIES */
|
2
|
+
|
3
|
+
// Show/hide element based on condition
|
4
|
+
const showElement = (condition, element) => {
|
5
|
+
if (condition) {
|
6
|
+
element.classList.add('show-item');
|
7
|
+
element.classList.remove('hide-item');
|
8
|
+
} else {
|
9
|
+
element.classList.add('hide-item');
|
10
|
+
element.classList.remove('show-item');
|
11
|
+
}
|
12
|
+
};
|
13
|
+
|
14
|
+
// Show toast message -- there should only be one at a time,
|
15
|
+
// if this behavior changes then this will need to be updated
|
16
|
+
const showToast = (message) => {
|
17
|
+
const toastElement = document.querySelector('.toast');
|
18
|
+
const toast = new bootstrap.Toast(toastElement);
|
19
|
+
const toastBody = document.querySelector('.toast-body');
|
20
|
+
toastBody.innerHTML = ''; // clear any existing errors
|
21
|
+
toastBody.append(message);
|
22
|
+
toast.show();
|
23
|
+
};
|
24
|
+
|
25
|
+
$(document).ready(function () {
|
26
|
+
const scrollTopTrigger = 0;
|
27
|
+
$(window).scroll(function () {
|
28
|
+
if ($(window).scrollTop() > scrollTopTrigger) {
|
29
|
+
$('.navbar').addClass('scrolled');
|
30
|
+
} else {
|
31
|
+
$('.navbar').removeClass('scrolled');
|
32
|
+
}
|
33
|
+
});
|
34
|
+
if ($(window).scrollTop() > scrollTopTrigger) {
|
35
|
+
$('.navbar').addClass('scrolled');
|
36
|
+
} else {
|
37
|
+
$('.navbar').removeClass('scrolled');
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
document.addEventListener('DOMContentLoaded', function () {
|
42
|
+
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
|
43
|
+
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
44
|
+
return new bootstrap.Tooltip(tooltipTriggerEl);
|
45
|
+
});
|
46
|
+
});
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
const createSession = () => {
|
2
|
+
// Get Suite ID
|
3
|
+
const suiteId = Array.from(document.getElementsByTagName('input'))
|
4
|
+
.filter((elem) => elem.checked && elem.name === 'suite')
|
5
|
+
.map((elem) => elem.value)[0]; // should only have one selected option
|
6
|
+
|
7
|
+
// Get checked options and map to id and value
|
8
|
+
const checkedOptions = Array.from(document.getElementsByTagName('input'))
|
9
|
+
.filter((elem) => elem.checked && elem.name !== 'suite' && $(elem).is(':visible'))
|
10
|
+
.map((elem) => ({
|
11
|
+
id: elem.name,
|
12
|
+
value: elem.value
|
13
|
+
}));
|
14
|
+
|
15
|
+
const postUrl = `api/test_sessions?test_suite_id=${suiteId}`;
|
16
|
+
const postBody = {
|
17
|
+
preset_id: null,
|
18
|
+
suite_options: checkedOptions,
|
19
|
+
};
|
20
|
+
fetch(postUrl, { method: 'POST', body: JSON.stringify(postBody) })
|
21
|
+
.then((response) => response.json())
|
22
|
+
.then((result) => {
|
23
|
+
const sessionId = result.id;
|
24
|
+
if (!result) {
|
25
|
+
throw Error('Session could not be created. Please check input values.');
|
26
|
+
} else if (!sessionId || sessionId === 'undefined') {
|
27
|
+
throw Error('Session could not be created. Session ID is undefined.');
|
28
|
+
} else {
|
29
|
+
location.href = `test_sessions/${sessionId}`;
|
30
|
+
}
|
31
|
+
})
|
32
|
+
.catch((e) => {
|
33
|
+
showToast(e);
|
34
|
+
});
|
35
|
+
};
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// Returns a list of all tags as strings from a test kit element
|
2
|
+
const getTags = (tags, elem) => {
|
3
|
+
Array.from(elem.children).forEach((e) => {
|
4
|
+
if (e.className === 'tag') {
|
5
|
+
tags.push(e.innerText);
|
6
|
+
}
|
7
|
+
getTags(tags, e);
|
8
|
+
});
|
9
|
+
return tags;
|
10
|
+
};
|
11
|
+
|
12
|
+
// Returns the level of maturity for a given test kit element
|
13
|
+
const getMaturity = (elem) => {
|
14
|
+
let innerText = '';
|
15
|
+
Array.from(elem.children).forEach((e) => {
|
16
|
+
if (e.className === 'maturity') {
|
17
|
+
innerText = e.innerText;
|
18
|
+
return e.innerText;
|
19
|
+
}
|
20
|
+
|
21
|
+
// ignore the pinned icon for traversal, which is hit last
|
22
|
+
if(e.nodeName !== 'I'){
|
23
|
+
innerText = getMaturity(e);
|
24
|
+
}
|
25
|
+
|
26
|
+
});
|
27
|
+
|
28
|
+
return innerText;
|
29
|
+
};
|
30
|
+
|
31
|
+
// Returns true if test kit should be shown based on standard filter
|
32
|
+
const filterTag = (testKit, standard) => {
|
33
|
+
if (!standard) return true;
|
34
|
+
const tags = getTags([], testKit);
|
35
|
+
return tags.includes(standard) || standard === 'All Tags';
|
36
|
+
};
|
37
|
+
|
38
|
+
// Returns true if test kit should be shown based on maturity filter
|
39
|
+
const filterMaturity = (testKit, maturity) => {
|
40
|
+
if (!maturity) return true;
|
41
|
+
const testKitMaturity = getMaturity(testKit);
|
42
|
+
return testKitMaturity.includes(maturity) || maturity === 'All Levels';
|
43
|
+
};
|
44
|
+
|
45
|
+
// Returns true if test kit should be shown based on text filter
|
46
|
+
const filterText = (testKit, text) => {
|
47
|
+
const testKitText = testKit.innerText.toLowerCase();
|
48
|
+
return testKitText.includes(text);
|
49
|
+
};
|
50
|
+
|
51
|
+
// Ensure all applied filters take effect
|
52
|
+
const filterAll = (text, standard, maturity) => {
|
53
|
+
for (let testKit of document.getElementsByName('test-kit')) {
|
54
|
+
showElement(
|
55
|
+
filterText(testKit, text) && filterTag(testKit, standard) && filterMaturity(testKit, maturity),
|
56
|
+
testKit,
|
57
|
+
);
|
58
|
+
}
|
59
|
+
};
|
data/lib/inferno/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inferno_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen MacVicar
|
@@ -690,8 +690,11 @@ files:
|
|
690
690
|
- lib/inferno/public/assets.json
|
691
691
|
- lib/inferno/public/bundle.js
|
692
692
|
- lib/inferno/public/bundle.js.LICENSE.txt
|
693
|
+
- lib/inferno/public/common.js
|
693
694
|
- lib/inferno/public/favicon.ico
|
694
695
|
- lib/inferno/public/logo192.png
|
696
|
+
- lib/inferno/public/session.js
|
697
|
+
- lib/inferno/public/test_kits.js
|
695
698
|
- lib/inferno/repositories.rb
|
696
699
|
- lib/inferno/repositories/headers.rb
|
697
700
|
- lib/inferno/repositories/igs.rb
|