Skip to content

Commit

Permalink
Merge branch 'main' into timerange-oversight
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Oct 14, 2024
2 parents a7fb76b + 2c1b430 commit ff1486a
Show file tree
Hide file tree
Showing 7 changed files with 333 additions and 175 deletions.
4 changes: 2 additions & 2 deletions docs/admin-preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@
55.627 l 55.6165,55.627 -231.245496,231.24803 c -127.185,127.1864
-231.5279,231.248 -231.873,231.248 -0.3451,0 -104.688,
-104.0616 -231.873,-231.248 z
" fill="currentColor"></path></g></svg></div></div><div class="sc-dKGrn laenHu api-content"><div class="sc-dsLQwm diwyyM"><div class="sc-la-DxNn dSIRVR"><div class="sc-fQpRED htdgPt api-info"><h1 class="sc-iCZwEW sc-gjHHYa gfRsnu edbYXQ">AEM Admin API (Feature Preview)<!-- --> <span>(<!-- -->12.15.0<!-- -->)</span></h1><p>Download OpenAPI specification<!-- -->:<a download="openapi.json" target="_blank" class="sc-kyZTxD cwcfQE">Download</a></p><div class="sc-euGpHm sc-exayXG fwfkcU kqJXdD"><div class="sc-kwhYVV dgGfLY"><div class="sc-fyEUpq kqOgwj"> <!-- --> <span class="sc-ggPNws hrVgqq">License:<!-- --> <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</a></span> </div></div></div><div data-role="redoc-summary" html="" class="sc-euGpHm sc-exayXG fwfkcU kqJXdD"></div><div data-role="redoc-description" html="&lt;p&gt;AEM Admin API is used to manage the lifecycle of content and code.&lt;/p&gt;
" fill="currentColor"></path></g></svg></div></div><div class="sc-dKGrn laenHu api-content"><div class="sc-dsLQwm diwyyM"><div class="sc-la-DxNn dSIRVR"><div class="sc-fQpRED htdgPt api-info"><h1 class="sc-iCZwEW sc-gjHHYa gfRsnu edbYXQ">AEM Admin API (Feature Preview)<!-- --> <span>(<!-- -->12.20.2<!-- -->)</span></h1><p>Download OpenAPI specification<!-- -->:<a download="openapi.json" target="_blank" class="sc-kyZTxD cwcfQE">Download</a></p><div class="sc-euGpHm sc-exayXG fwfkcU kqJXdD"><div class="sc-kwhYVV dgGfLY"><div class="sc-fyEUpq kqOgwj"> <!-- --> <span class="sc-ggPNws hrVgqq">License:<!-- --> <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</a></span> </div></div></div><div data-role="redoc-summary" html="" class="sc-euGpHm sc-exayXG fwfkcU kqJXdD"></div><div data-role="redoc-description" html="&lt;p&gt;AEM Admin API is used to manage the lifecycle of content and code.&lt;/p&gt;
" class="sc-euGpHm sc-exayXG fwfkcU kqJXdD"><p>AEM Admin API is used to manage the lifecycle of content and code.</p>
</div></div></div></div></div><div class="sc-epzHnm bWkBKa"></div></div></div>
<script>
const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.1.0","info":{"version":"12.15.0","title":"AEM Admin API (Feature Preview)","description":"AEM Admin API is used to manage the lifecycle of content and code.","license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"servers":[{"url":"https://admin.hlx.page"}],"components":{"securitySchemes":{"AuthCookie":{"type":"apiKey","in":"cookie","name":"auth_token"},"BearerToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}}}},"searchIndex":{"store":[],"index":{"version":"2.3.9","fields":["title","description"],"fieldVectors":[],"invertedIndex":[],"pipeline":[]}},"options":{"schemasExpansionLevel":2}};
const __redoc_state = {"menu":{"activeItemIdx":-1},"spec":{"data":{"openapi":"3.1.0","info":{"version":"12.20.2","title":"AEM Admin API (Feature Preview)","description":"AEM Admin API is used to manage the lifecycle of content and code.","license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"servers":[{"url":"https://admin.hlx.page"}],"components":{"securitySchemes":{"AuthCookie":{"type":"apiKey","in":"cookie","name":"auth_token"},"BearerToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}}}},"searchIndex":{"store":[],"index":{"version":"2.3.9","fields":["title","description"],"fieldVectors":[],"invertedIndex":[],"pipeline":[]}},"options":{"schemasExpansionLevel":2}};

var container = document.getElementById('redoc');
Redoc.hydrate(__redoc_state, container);
Expand Down
160 changes: 124 additions & 36 deletions docs/admin.html

Large diffs are not rendered by default.

52 changes: 30 additions & 22 deletions tools/oversight/elements/url-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ function getPersistentToken() {
return localStorage.getItem('rum-bundler-token');
}

function isIncognitoMode() {
return new URL(window.location.href).searchParams.get('domainkey') === 'incognito';
}

export default class URLSelector extends HTMLElement {
constructor() {
super();
Expand Down Expand Up @@ -41,8 +45,7 @@ export default class URLSelector extends HTMLElement {
const img = this.querySelector('img');
img.src = `https://www.google.com/s2/favicons?domain=${input.value.split(':')[0]}&sz=64`;

const token = getPersistentToken();
if (!token) {
if (!getPersistentToken()) {
input.disabled = true;
datalist.remove();

Expand All @@ -55,28 +58,33 @@ export default class URLSelector extends HTMLElement {
window.location.href = targetlocation.href;
}
});
} else {
fetch('https://rum.fastly-aem.page/domains?suggested=true', {
headers: {
accept: 'application/json',
authorization: `Bearer ${token}`,
},
}).then(async (resp) => {
if (!resp.ok) {
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
datalist.appendChild(option);
});
}
}).catch(() => {
datalist.remove();
});
}

input.addEventListener('mouseover', () => {
const token = getPersistentToken();
if (token && !isIncognitoMode()) {
fetch('https://rum.fastly-aem.page/domains?suggested=true', {
headers: {
accept: 'application/json',
authorization: `Bearer ${token}`,
},
}).then(async (resp) => {
if (!resp.ok) {
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
datalist.appendChild(option);
});
}
}).catch(() => {
datalist.remove();
});
}
}, { once: true });

input.addEventListener('focus', () => {
input.select();
});
Expand Down
38 changes: 27 additions & 11 deletions tools/rum/cruncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,12 @@ export class DataChunks {
* @param {string[]} skipped facets to skip
*/
filterBundles(bundles, filterSpec, skipped = []) {
const existenceFilterFn = ([facetName]) => this.facetFns[facetName];
const existenceFilterFn = ([facetName]) => {
if (!this.facetFns[facetName]) {
throw new Error(`Unknown "${facetName}" facet in filter`);
}
return this.facetFns[facetName];
};
const skipFilterFn = ([facetName]) => !skipped.includes(facetName);
const valuesExtractorFn = (attributeName, bundle, parent) => {
const facetValue = parent.facetFns[attributeName](bundle);
Expand All @@ -654,15 +659,21 @@ export class DataChunks {
*/
// eslint-disable-next-line max-len
applyFilter(bundles, filterSpec, skipFilterFn, existenceFilterFn, valuesExtractorFn, combinerExtractorFn) {
const filterBy = Object.entries(filterSpec)
.filter(skipFilterFn)
.filter(([, desiredValues]) => desiredValues.length)
.filter(existenceFilterFn);
return bundles.filter((bundle) => filterBy.every(([attributeName, desiredValues]) => {
const actualValues = valuesExtractorFn(attributeName, bundle, this);
const combiner = combinerExtractorFn(attributeName, this);
return desiredValues[combiner]((value) => actualValues.includes(value));
}));
try {
const filterBy = Object.entries(filterSpec)
.filter(skipFilterFn)
.filter(([, desiredValues]) => desiredValues.length)
.filter(existenceFilterFn);
return bundles.filter((bundle) => filterBy.every(([attributeName, desiredValues]) => {
const actualValues = valuesExtractorFn(attributeName, bundle, this);
const combiner = combinerExtractorFn(attributeName, this);
return desiredValues[combiner]((value) => actualValues.includes(value));
}));
} catch (error) {
// eslint-disable-next-line no-console
console.warn(`Error while applying filter: ${error.message}`);
return [];
}
}

/**
Expand All @@ -677,7 +688,12 @@ export class DataChunks {
* @returns {boolean} the result of the check.
*/
hasConversion(aBundle, filterSpec, combiner) {
const existenceFilterFn = ([facetName]) => this.facetFns[facetName];
const existenceFilterFn = ([facetName]) => {
if (!this.facetFns[facetName]) {
throw new Error(`Unknown "${facetName}" facet in filter`);
}
return this.facetFns[facetName];
};
const skipFilterFn = () => true;
const valuesExtractorFn = (attributeName, bundle, parent) => {
const facetValue = parent.facetFns[attributeName](bundle);
Expand Down
30 changes: 10 additions & 20 deletions tools/rum/elements/daterange-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,8 @@ function debounce(func, wait) {
};
}

// date management
function pad(number) {
return number.toString().padStart(2, '0');
}

function toDateString(date) {
// convert date
const year = date.getFullYear();
const month = pad(date.getMonth() + 1);
const day = pad(date.getDate());

return `${year}-${month}-${day}`;
return date.toISOString().split('T')[0];
}

const STYLES = `
Expand Down Expand Up @@ -304,20 +294,20 @@ export default class TimeRangePicker extends HTMLElement {

dropdownElement.hidden = true;

let dateFrom = new Date(from);
let dateTo = new Date(to);
if (dateFrom > dateTo) {
let dateFrom = from;
let dateTo = to;
if (new Date(from) > new Date(to)) {
// swap the 2 dates
dateFrom = new Date(to);
dateTo = new Date(from);
dateFrom = to;
dateTo = from;
}

if (from) {
fromElement.value = toDateString(dateFrom);
if (dateFrom) {
fromElement.value = dateFrom;
}

if (to) {
toElement.value = toDateString(dateTo);
if (dateTo) {
toElement.value = dateTo;
}

this.updateTimeframe({
Expand Down
52 changes: 30 additions & 22 deletions tools/rum/elements/url-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ function getPersistentToken() {
return localStorage.getItem('rum-bundler-token');
}

function isIncognitoMode() {
return new URL(window.location.href).searchParams.get('domainkey') === 'incognito';
}

export default class URLSelector extends HTMLElement {
constructor() {
super();
Expand Down Expand Up @@ -41,32 +45,36 @@ export default class URLSelector extends HTMLElement {
const img = this.querySelector('img');
img.src = `https://www.google.com/s2/favicons?domain=${input.value.split(':')[0]}&sz=64`;

const token = getPersistentToken();
if (!token) {
if (!getPersistentToken()) {
input.disabled = true;
datalist.remove();
} else {
fetch('https://rum.fastly-aem.page/domains?suggested=true', {
headers: {
accept: 'application/json',
authorization: `Bearer ${token}`,
},
}).then(async (resp) => {
if (!resp.ok) {
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
datalist.appendChild(option);
});
}
}).catch(() => {
datalist.remove();
});
}

input.addEventListener('mouseover', () => {
const token = getPersistentToken();
if (token && !isIncognitoMode()) {
fetch('https://rum.fastly-aem.page/domains?suggested=true', {
headers: {
accept: 'application/json',
authorization: `Bearer ${token}`,
},
}).then(async (resp) => {
if (!resp.ok) {
datalist.remove();
} else {
const { domains } = await resp.json();
domains.forEach((domain) => {
const option = document.createElement('option');
option.value = domain;
datalist.appendChild(option);
});
}
}).catch(() => {
datalist.remove();
});
}
}, { once: true });

input.addEventListener('focus', () => {
input.select();
});
Expand Down
Loading

0 comments on commit ff1486a

Please sign in to comment.