Skip to content

Commit

Permalink
ACR-3.0.0 API upgrade (#506)
Browse files Browse the repository at this point in the history
* Added Azure Credentials Manager Singleton (#18)

* Added Azure Credentials Manager Singleton
* Added getResourceManagementClient

* Sorted Existing Create Registry ready for code review

* Added acquiring telemetry data for create registry

* broke up createnewresourcegroup method and fixed client use

Added try catch loop and awaited for resource group list again to check for duplicates with ResourceManagementClient

* Jackson esteban/unified client nit Fix (#24)

* Added Azure Credentials Manager Singleton

* Small Style Fixes

* Further Style fixes, added getResourceManagementClient

* Lazy Initialization Patches

* Enabled location selection

* Location request fixes

-Changed order of questions asked to user for better UX (location of new res group & location of new registry)
-Placeholder of location is display name view

* Refactor while loop for new res group

* Added SKU selection

* Quick fix- initializing array syntax

* Added specific error messages and comments

* Julia/delete image (#29)

* first fully functional version of delete through input bar AND right click

* refactored code to make it prettier!

* comments

* comments, added subscription function

* fixed to style guide

* style fixes, refactoring

* delete image after reviews

put my functions from azureCredentialsManager into two new files: utils/azure/acrTools.ts, and commands/utils/quick-pick-azure.ts

Edited code based on Esteban's and Bin's reviews

* One last little change to delete image

* moved repository, azureimage, and getsubscriptions to the correct places within deleteImage

* changes from PR reviews on delete image

* fixed authentication issue, got rid of azureAccount property for repository and image

**on constructor for repository, azurecredentialsmanager was being recreated and thus couldn't find the azureAccount. For this reason, I got rid of the azureAccount property of the classes Repository and AzureImage. This bug may lead to future problems (Esteban and I couldn't see why it was happening)

* minor fixes deleteImage

* delete a parentheses

* copied previous push to acr into new pull-from-azure.ts file

* Estebanreyl/dev merge fixes  (#43)

* Merge fixes to acquire latest telemetry items

* Updated to master AzureUtilityManager

* added acrbuild stuff

* added acrbuild stuff

* Update to match utility manager class

* Rutusamai/list build tasks for each registry (#37)

* tslint updates, transfered from old branch

* updated icon

* Addressed PR comments- mostly styling/code efficiency

* Changed url to aka.ms link

* changed Error window to Info message for no build tasks in your registry

* Changed default sku and unified parsing resource group into a new method, getResourceGroup in acrTools.ts

* Changed build task icon

* Added quick pick for selecting resource group and registry

* clean

* Added subscription support

* utility bug fix

* Julia/delete repository final (#49)

* deleteRepo moved over to branch off dev

* Got rid of unnecessary code, fully functioning!

* deleteRepo moved over to branch off dev

* Got rid of unnecessary code, fully functioning!

* spacing

* final commit

* Cleaned code

* Added Telemetry

* Julia/delete registry final (#47)


Delete azure registry functionality added

Delete azure registry moved to branch off dev

Reorganized stye

* Made loginCredentials method in acrTools more efficient, added Pull Image from Azure option, temporary fix for no registries

* added folder select

* Split the loginCredentials function, added docker login and docker pull and telemetry actions

* Finished pull from azure right click feature

* deleted push to azure

* removed username and password from Azure Registry Node

* Clean up

* copied previous push to acr into new pull-from-azure.ts file

* Made loginCredentials method in acrTools more efficient, added Pull Image from Azure option, temporary fix for no registries

* Split the loginCredentials function, added docker login and docker pull and telemetry actions

* Finished pull from azure right click feature

* deleted push to azure

* Clean up

* Working again after rebasing and resolving merge conflicts

* Updates and fixes

* Fixes from PR comments

-renamed loginCredentials functions
-added await to docker commands in image pull
-cleanup

* uncapitalize AzureRegistryNode

* Refactoring, prod.

* Flexible OSType

* Estebanreyl/ready for production (#55)

* began updating

* Reorganized create registry and delete azure image

* continued improvements

* Began updating login

* being credentials update

* further updates

* Finished updating, need to test functionality now

* Updated requests, things all work now

* Applied some nit fixes

* Updates to naming

* maintain UtilityManager standards

* Updated Prompts

* Updated imports and naming / standarized telemetry

* Added explorer refresh capabilities on delete/add

* Jackson/quick build dev (#46)

* added acrbuild stuff

* added acrbuild stuff

* Update to match utility manager class

* Added quick pick for selecting resource group and registry

* clean

* Added subscription support

* utility bug fix

* added folder select

* Updates and fixes

* Refactoring, prod.

* Flexible OSType

* added ID

* Move build to azure commands

* cleanup

* Relative dockerfile support

* Removed await, updating list in enumeration

* fixed chdir

* flexible ostype

* Rutusamai/Show Build Task properties (#70)

* Show build task works through input bar

* added run build task

* Right click not working on BuildTaskNode. Works through command palette

* quick fixes

* quick fix to enable context menu on buildTaskNode

* comamnd not sending via right click

* working from right click now. trying to do show in json

* Acquire properties in JSON format internally, works

* Now shows organized task jsons on right click

* import

* to do

* issues with getImagesByRepository

* try catch build step

* acrTools

* small refactor

* Show build task works through input bar

* added run build task

* Right click not working on BuildTaskNode. Works through command palette

* quick fixes

* quick fix to enable context menu on buildTaskNode

* comamnd not sending via right click

* working from right click now. trying to do show in json

* Acquire properties in JSON format internally, works

* Now shows organized task jsons on right click

* import

* to do

* issues with getImagesByRepository

* try catch build step

* acrTools

* small refactor

* Show is working- final

* removed run build task stuff

* cleanup

* addressed esteban's comments

* buildTask = context.task.name rather than label

* fixes from Bin's comments

* Merge branch 'dev' of https://github.com/AzureCR/vscode-docker into master4

* merge

* missed small changes

* Rutusamai/Run a Build Task (#71)

* Show build task works through input bar

* added run build task

* Right click not working on BuildTaskNode. Works through command palette

* quick fixes

* quick fix to enable context menu on buildTaskNode

* comamnd not sending via right click

* working from right click now. trying to do show in json

* Acquire properties in JSON format internally, works

* Now shows organized task jsons on right click

* import

* to do

* issues with getImagesByRepository

* try catch build step

* acrTools

* small refactor

* Show build task works through input bar

* added run build task

* Right click not working on BuildTaskNode. Works through command palette

* quick fixes

* quick fix to enable context menu on buildTaskNode

* comamnd not sending via right click

* working from right click now. trying to do show in json

* Acquire properties in JSON format internally, works

* Now shows organized task jsons on right click

* import

* to do

* issues with getImagesByRepository

* try catch build step

* acrTools

* small refactor

* Show is working- final

* run is working for right click

* run build task works through command pallette. added success notification

* removed show build task

* cleanup- matched quickpick buils task and tasknode withshow build task branch

* removed showTaskManager

* spacing

* outputChannel and null icon

* merge to update with dev

* Estebanreyl/build logs final (#72)

*  "Merge branch 'estebanreyl/buildlogsWithAccesibility' of https://github.com/AzureCR/vscode-docker into estebanreyl/buildlogsWithAccesibility"

This reverts commit e645cbf, reversing
changes made to fc4a477.

* Refactored and organized log view into readable components.

* moved storage

* Began incorporating icons

* Added icons

* Further standarization

* added logs

* Added download log capabilities

* Updated Copy

* Updated inner div size alignment

* Added resizing script

* header sort by is only clickable on text now

* fixed header table

* Fix minor display issues

* Identified filtering strategy

* Begin adding sorting

* Merge with dev

* Added proper filtering

* Nit loading improvements

* Added accesibility, key only behaviour

* accesibility retouches and enable right click from tasknode

* merges

* fix module name

* Adds streaming and command standarization (ext.ui) (#73)

* Adds streaming and command standarization (ext.ui)

* removed unecessary append lines

* small fixes

* Fix merge issues

* changes for ACR 3.0.0 (#80)

* This commit contains changes necessary for the
azure-arm-containerregistry 3.0.0

* Fixed PR feedback

* Run task fixed. Issue ID: 79

* missing changes added

* Fixing ACR run logs for Images

* Sajaya/top1 (#83)

* Query only 1 record for runs

* View Azure logs

* Refactoring build to run and buildTask to task

* Update Credentail Management

Sorted Existing Create Registry ready for code review

Jackson esteban/unified client nit Fix (#24)

* Added Azure Credentials Manager Singleton

* Small Style Fixes

* Further Style fixes, added getResourceManagementClient

* Lazy Initialization Patches

Enabled location selection

Location request fixes

-Changed order of questions asked to user for better UX (location of new res group & location of new registry)
-Placeholder of location is display name view

Added SKU selection

Quick fix- initializing array syntax

Julia/delete image (#29)

* first fully functional version of delete through input bar AND right click

* refactored code to make it prettier!

* comments

* comments, added subscription function

* fixed to style guide

* style fixes, refactoring

* delete image after reviews

put my functions from azureCredentialsManager into two new files: utils/azure/acrTools.ts, and commands/utils/quick-pick-azure.ts

Edited code based on Esteban's and Bin's reviews

* One last little change to delete image

* moved repository, azureimage, and getsubscriptions to the correct places within deleteImage

* changes from PR reviews on delete image

* fixed authentication issue, got rid of azureAccount property for repository and image

**on constructor for repository, azurecredentialsmanager was being recreated and thus couldn't find the azureAccount. For this reason, I got rid of the azureAccount property of the classes Repository and AzureImage. This bug may lead to future problems (Esteban and I couldn't see why it was happening)

* minor fixes deleteImage

* delete a parentheses

copied previous push to acr into new pull-from-azure.ts file

Estebanreyl/dev merge fixes  (#43)

* Merge fixes to acquire latest telemetry items

* Updated to master AzureUtilityManager

added acrbuild stuff

Rutusamai/list build tasks for each registry (#37)

* tslint updates, transfered from old branch

* updated icon

* Addressed PR comments- mostly styling/code efficiency

* Changed url to aka.ms link

* changed Error window to Info message for no build tasks in your registry

* Changed default sku and unified parsing resource group into a new method, getResourceGroup in acrTools.ts

* Changed build task icon

utility bug fix

Julia/delete repository final (#49)

* deleteRepo moved over to branch off dev

* Got rid of unnecessary code, fully functioning!

* deleteRepo moved over to branch off dev

* Got rid of unnecessary code, fully functioning!

* spacing

* final commit

* Cleaned code

* Added Telemetry

Julia/delete registry final (#47)

Delete azure registry functionality added

Delete azure registry moved to branch off dev

Reorganized stye

Made loginCredentials method in acrTools more efficient, added Pull Image from Azure option, temporary fix for no registries

Split the loginCredentials function, added docker login and docker pull and telemetry actions

copied previous push to acr into new pull-from-azure.ts file

Made loginCredentials method in acrTools more efficient, added Pull Image from Azure option, temporary fix for no registries

Split the loginCredentials function, added docker login and docker pull and telemetry actions

Finished pull from azure right click feature

Working again after rebasing and resolving merge conflicts

Refactoring, prod.

Estebanreyl/ready for production (#55)

* began updating

* Reorganized create registry and delete azure image

* continued improvements

* Began updating login

* being credentials update

* further updates

* Finished updating, need to test functionality now

* Updated requests, things all work now

* Applied some nit fixes

* Updates to naming

* maintain UtilityManager standards

* Updated Prompts

* Updated imports and naming / standarized telemetry

* Added explorer refresh capabilities on delete/add

Jackson/quick build dev (#46)

* added acrbuild stuff

* added acrbuild stuff

* Update to match utility manager class

* Added quick pick for selecting resource group and registry

* clean

* Added subscription support

* utility bug fix

* added folder select

* Updates and fixes

* Refactoring, prod.

* Flexible OSType

added ID

Move build to azure commands

cleanup

Relative dockerfile support

Removed await, updating list in enumeration

fixed chdir

flexible ostype

Rutusamai/Show Build Task properties (#70)

* Show build task works through input bar

* added run build task

* Right click not working on BuildTaskNode. Works through command palette

* quick fixes

* quick fix to enable context menu on buildTaskNode

* comamnd not sending via right click

* working from right click now. trying to do show in json

* Acquire properties in JSON format internally, works

* Now shows organized task jsons on right click

* import

* to do

* issues with getImagesByRepository

* try catch build step

* acrTools

* small refactor

* Show build task works through input bar

* added run build task

* Right click not working on BuildTaskNode. Works through command palette

* quick fixes

* quick fix to enable context menu on buildTaskNode

* comamnd not sending via right click

* working from right click now. trying to do show in json

* Acquire properties in JSON format internally, works

* Now shows organized task jsons on right click

* import

* to do

* issues with getImagesByRepository

* try catch build step

* acrTools

* small refactor

* Show is working- final

* removed run build task stuff

* cleanup

* addressed esteban's comments

* buildTask = context.task.name rather than label

* fixes from Bin's comments

Merge branch 'dev' of https://github.com/AzureCR/vscode-docker into master4

merge

missed small changes

Rutusamai/Run a Build Task (#71)

* Show build task works through input bar

* added run build task

* Right click not working on BuildTaskNode. Works through command palette

* quick fixes

* quick fix to enable context menu on buildTaskNode

* comamnd not sending via right click

* working from right click now. trying to do show in json

* Acquire properties in JSON format internally, works

* Now shows organized task jsons on right click

* import

* to do

* issues with getImagesByRepository

* try catch build step

* acrTools

* small refactor

* Show build task works through input bar

* added run build task

* Right click not working on BuildTaskNode. Works through command palette

* quick fixes

* quick fix to enable context menu on buildTaskNode

* comamnd not sending via right click

* working from right click now. trying to do show in json

* Acquire properties in JSON format internally, works

* Now shows organized task jsons on right click

* import

* to do

* issues with getImagesByRepository

* try catch build step

* acrTools

* small refactor

* Show is working- final

* run is working for right click

* run build task works through command pallette. added success notification

* removed show build task

* cleanup- matched quickpick buils task and tasknode withshow build task branch

* removed showTaskManager

* spacing

* outputChannel and null icon

* merge to update with dev

Estebanreyl/build logs final (#72)

*  "Merge branch 'estebanreyl/buildlogsWithAccesibility' of https://github.com/AzureCR/vscode-docker into estebanreyl/buildlogsWithAccesibility"

This reverts commit e645cbf, reversing
changes made to fc4a477.

* Refactored and organized log view into readable components.

* moved storage

* Began incorporating icons

* Added icons

* Further standarization

* added logs

* Added download log capabilities

* Updated Copy

* Updated inner div size alignment

* Added resizing script

* header sort by is only clickable on text now

* fixed header table

* Fix minor display issues

* Identified filtering strategy

* Begin adding sorting

* Merge with dev

* Added proper filtering

* Nit loading improvements

* Added accesibility, key only behaviour

* accesibility retouches and enable right click from tasknode

* merges

* fix module name

Adds streaming and command standarization (ext.ui) (#73)

* Adds streaming and command standarization (ext.ui)

* removed unecessary append lines

* small fixes

* Fix merge issues

changes for ACR 3.0.0 (#80)

* This commit contains changes necessary for the
azure-arm-containerregistry 3.0.0

* Fixed PR feedback

Run task fixed. Issue ID: 79

missing changes added

Fixing ACR run logs for Images

Sajaya/top1 (#83)

* Query only 1 record for runs

* View Azure logs

bug fix

* Removed filter for top (#88)

* fixing Image Log Filter

* fixing tslint error messages

* tslint fixes 2

* First PR #506 review Update include:
	Deletion of resizable.js
	Package.json commands alphabetically ordered.
	General typos, grammar and naming fixes.
	Change from fs - fs-extra.
	Other general improvments.

* Hide Azure Quick Build if Azure Account not available

* Second PR #506 review update.
	Quick Build Image name and dockerFile selection Improvements.
	Upgrade from fs to fs-extra.
	Log table bug fixes.
	Error Handeling Improvements.
	Other general improvements.

* Improving Logs generation Error handeling

* Third PR #506 review update.
	loadLogs parameters update.
	uploadSourceCode Improvements.

* UploadSourceCode no longer has to change process working directory.

* lint fix
  • Loading branch information
rosanch authored and StephenWeatherford committed Nov 9, 2018
1 parent ac05b65 commit 6204e4c
Show file tree
Hide file tree
Showing 42 changed files with 2,409 additions and 450 deletions.
65 changes: 65 additions & 0 deletions commands/azureCommands/acr-logs-utils/logFileManager.ts
@@ -0,0 +1,65 @@
import { BlobService, createBlobServiceWithSas } from 'azure-storage';
import * as fse from 'fs-extra';
import * as vscode from 'vscode';
import { getBlobInfo, getBlobToText, IBlobInfo } from '../../../utils/Azure/acrTools';

export class LogContentProvider implements vscode.TextDocumentContentProvider {
public static scheme: string = 'purejs';
private onDidChangeEvent: vscode.EventEmitter<vscode.Uri> = new vscode.EventEmitter<vscode.Uri>();

constructor() { }

public provideTextDocumentContent(uri: vscode.Uri): string {
let parse: { log: string } = <{ log: string }>JSON.parse(uri.query);
return decodeBase64(parse.log);
}

get onDidChange(): vscode.Event<vscode.Uri> {
return this.onDidChangeEvent.event;
}

public update(uri: vscode.Uri, message: string): void {
this.onDidChangeEvent.fire(uri);
}

}

export function decodeBase64(str: string): string {
return Buffer.from(str, 'base64').toString('ascii');
}

export function encodeBase64(str: string): string {
return Buffer.from(str, 'ascii').toString('base64');
}

/** Loads log text from remote url using azure blobservices */
export async function accessLog(url: string, title: string, download: boolean): Promise<void> {
let blobInfo: IBlobInfo = getBlobInfo(url);
let blob: BlobService = createBlobServiceWithSas(blobInfo.host, blobInfo.sasToken);
let text1 = await getBlobToText(blobInfo, blob, 0);
if (download) {
await downloadLog(text1, title);
} else {
openLogInNewWindow(text1, title);
}
}

function openLogInNewWindow(content: string, title: string): void {
const scheme = 'purejs';
let query = JSON.stringify({ 'log': encodeBase64(content) });
let uri: vscode.Uri = vscode.Uri.parse(`${scheme}://authority/${title}.log?${query}#idk`);
vscode.workspace.openTextDocument(uri).then((doc) => {
return vscode.window.showTextDocument(doc, vscode.ViewColumn.Active + 1, true);
});
}

export async function downloadLog(content: string, title: string): Promise<void> {
let uri = await vscode.window.showSaveDialog({
filters: { 'Log': ['.log', '.txt'] },
defaultUri: vscode.Uri.file(`${title}.log`)
});
fse.writeFile(uri.fsPath, content,
(err) => {
if (err) { throw err; }
});
}
306 changes: 306 additions & 0 deletions commands/azureCommands/acr-logs-utils/logScripts.js
@@ -0,0 +1,306 @@
// Global Variables
const status = {
'Succeeded': 4,
'Queued': 3,
'Error': 2,
'Failed': 1
}

var currentItemsCount = 4;
var currentDir = "asc"
var triangles = {
'down': '&nbsp;<i class="ms-Icon ms-Icon--ChevronDown"></i>',
'up': '&nbsp;<i class="rotate180 ms-Icon ms-Icon--ChevronDown"></i>'
}

document.addEventListener("scroll", function () {
var translate = "translate(0," + this.lastChild.scrollTop + "px)";
let fixedItems = this.querySelectorAll(".fixed");
for (item of fixedItems) {
item.style.transform = translate;
}
});

// Main
let content = document.querySelector('#core');
const vscode = acquireVsCodeApi();
setLoadMoreListener();
setInputListeners();
loading();

document.onkeydown = function (event) {
if (event.key === "Enter") { // The Enter/Return key
document.activeElement.onclick(event);
}
};

/* Sorting
* PR note, while this does not use a particularly quick algorithm
* it allows a low stuttering experience that allowed rapid testing.
* I will improve it soon.*/
function sortTable(n, dir = "asc", holdDir = false) {
currentItemsCount = n;
let table, rows, switching, i, x, y, shouldSwitch, switchcount = 0;
let cmpFunc = acquireCompareFunction(n);
table = document.getElementById("core");
switching = true;
//Set the sorting direction to ascending:

while (switching) {
switching = false;
rows = table.querySelectorAll(".holder");
for (i = 0; i < rows.length - 1; i++) {
shouldSwitch = false;
x = rows[i].getElementsByTagName("TD")[n + 1];
y = rows[i + 1].getElementsByTagName("TD")[n + 1];
if (dir == "asc") {
if (cmpFunc(x, y)) {
shouldSwitch = true;
break;
}
} else if (dir == "desc") {
if (cmpFunc(y, x)) {
shouldSwitch = true;
break;
}
}
}
if (shouldSwitch) {
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
switching = true;
switchcount++;
} else {
/*If no switching has been done AND the direction is "asc", set the direction to "desc" and run the while loop again.*/
if (switchcount == 0 && dir == "asc" && !holdDir) {
dir = "desc";
switching = true;
}
}
}
if (!holdDir) {
let sortColumns = document.querySelectorAll(".sort");
if (sortColumns[n].innerHTML === triangles['down']) {
sortColumns[n].innerHTML = triangles['up'];
} else if (sortColumns[n].innerHTML === triangles['up']) {
sortColumns[n].innerHTML = triangles['down'];
} else {
for (cell of sortColumns) {
cell.innerHTML = ' ';
}
sortColumns[n].innerHTML = triangles['down'];
}
}
currentDir = dir;
}

function acquireCompareFunction(n) {
switch (n) {
case 0: //Name
case 1: //Task
return (x, y) => {
return x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()
}
case 2: //Status
return (x, y) => {
return status[x.dataset.status] > status[y.dataset.status];;
}
case 3: //Created time
return (x, y) => {
if (x.dataset.createdtime === '') return true;
if (y.dataset.createdtime === '') return false;
let dateX = new Date(x.dataset.createdtime);
let dateY = new Date(y.dataset.createdtime);
return dateX > dateY;
}
case 4: //Elapsed time
return (x, y) => {
if (x.innerHTML === '') return true;
if (y.innerHTML === '') return false;
return Number(x.innerHTML.substring(0, x.innerHTML.length - 1)) > Number(y.innerHTML.substring(0, y.innerHTML.length - 1));
}
case 5: //OS Type
return (x, y) => {
return x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()
}
default:
throw 'Could not acquire Compare function, invalid n';
}
}

// Event Listener Setup
window.addEventListener('message', event => {
const message = event.data; // The JSON data our extension sent
if (message.type === 'populate') {
content.insertAdjacentHTML('beforeend', message.logComponent);

let item = content.querySelector(`#btn${message.id}`);
setSingleAccordion(item);

let panel = item.nextElementSibling;

const logButton = panel.querySelector('.openLog');
setLogBtnListener(logButton, false);
const downloadlogButton = panel.querySelector('.downloadlog');
setLogBtnListener(downloadlogButton, true);

const digestClickables = panel.querySelectorAll('.copy');
setDigestListener(digestClickables);

} else if (message.type === 'endContinued') {
sortTable(currentItemsCount, currentDir, true);
loading();
} else if (message.type === 'end') {
window.addEventListener("resize", setAccordionTableWidth);
setAccordionTableWidth();
setTableSorter();
loading();
}

if (message.canLoadMore) {
const loadBtn = document.querySelector('.loadMoreBtn');
loadBtn.style.display = 'flex';
}

});

function setSingleAccordion(item) {
item.onclick = function (event) {
this.classList.toggle('active');
this.querySelector('.arrow').classList.toggle('activeArrow');
let panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.display = 'none';
panel.style.maxHeight = null;
let index = openAccordions.indexOf(panel);
if (index > -1) {
openAccordions.splice(index, 1);
}
} else {
openAccordions.push(panel);
setAccordionTableWidth();
panel.style.display = 'table-row';
let paddingTop = +panel.style.paddingTop.split('px')[0];
let paddingBottom = +panel.style.paddingBottom.split('px')[0];
panel.style.maxHeight = (panel.scrollHeight + paddingTop + paddingBottom) + 'px';
}
};
}

function setTableSorter() {
let tableHeader = document.querySelector("#tableHead");
let items = tableHeader.querySelectorAll(".colTitle");
for (let i = 0; i < items.length; i++) {
items[i].onclick = () => {
sortTable(i);
};
}
}

function setLogBtnListener(item, download) {
item.onclick = (event) => {
vscode.postMessage({
logRequest: {
'id': event.target.dataset.id,
'download': download
}
});
};
}

function setLoadMoreListener() {
let item = document.querySelector("#loadBtn");
item.onclick = function () {
const loadBtn = document.querySelector('.loadMoreBtn');
loadBtn.style.display = 'none';
loading();
vscode.postMessage({
loadMore: true
});
};
}

function setDigestListener(digestClickables) {
for (digest of digestClickables) {
digest.onclick = function (event) {
vscode.postMessage({
copyRequest: {
'text': event.target.parentNode.dataset.digest,
}
});
};
}
}

let openAccordions = [];

function setAccordionTableWidth() {
let headerCells = document.querySelectorAll("#core thead tr th");
let topWidths = [];
for (let cell of headerCells) {
topWidths.push(parseInt(getComputedStyle(cell).width));
}
for (acc of openAccordions) {
let cells = acc.querySelectorAll(".innerTable th, .innerTable td"); // 4 items
const cols = acc.querySelectorAll(".innerTable th").length + 1; //Account for arrowHolder
const rows = cells.length / cols;
//cells[0].style.width = topWidths[0];
for (let row = 0; row < rows; row++) {
for (let col = 1; col < cols - 1; col++) {
let cell = cells[row * cols + col];
cell.style.width = topWidths[col - 1] + "px"
}
}
}
}

function setInputListeners() {
const inputFields = document.querySelectorAll("input");
const loadBtn = document.querySelector('.loadMoreBtn');
for (let inputField of inputFields) {
inputField.addEventListener("keyup", function (event) {
if (event.key === "Enter") {
clearLogs();
loading();
loadBtn.style.display = 'none';
vscode.postMessage({
loadFiltered: {
filterString: getFilterString(inputFields)
}
});
}
});
}
}

/*interface Filter
image?: string;
runId?: string;
runTask?: string;
*/
function getFilterString(inputFields) {
let filter = {};
if (inputFields[0].value.length > 0) { //Run Id
filter.runId = inputFields[0].value;
} else if (inputFields[1].value.length > 0) { //Task id
filter.task = inputFields[1].value;
}
return filter;
}

function clearLogs() {
let items = document.querySelectorAll("#core tbody");
for (let item of items) {
item.remove();
}
}
var shouldLoad = false;

function loading() {
const loader = document.querySelector('#loadingDiv');
if (shouldLoad) {
loader.style.display = 'flex';
} else {
loader.style.display = 'none';
}
shouldLoad = !shouldLoad;
}

0 comments on commit 6204e4c

Please sign in to comment.