Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6e0a6ef
Create basic table with dummy data.
geraldtivatyi Jun 3, 2021
7349923
create basis for interfaces and classes to handle and structure data …
geraldtivatyi Jun 4, 2021
83bd5b0
Merge pull request #1 from geraldtivatyi/foundational-setup
geraldtivatyi Jun 4, 2021
1b69e97
render table records and headings to html
geraldtivatyi Jun 4, 2021
7f89a05
Some code refactoring.
geraldtivatyi Jun 7, 2021
a70d634
Make http request to get data from server.
geraldtivatyi Jun 7, 2021
888df86
Update fetching data from server
geraldtivatyi Jun 7, 2021
59f3d00
Add styling and fix bug
geraldtivatyi Jun 8, 2021
68c6db2
Merge pull request #3 from geraldtivatyi/use-data-from-server
geraldtivatyi Jun 8, 2021
fa380a5
Merge pull request #2 from geraldtivatyi/rendering-to-html
geraldtivatyi Jun 8, 2021
31961b5
Refactor code and add comments
geraldtivatyi Jun 8, 2021
0c5f435
Merge pull request #4 from geraldtivatyi/code-refactoring
geraldtivatyi Jun 8, 2021
2cd6d76
Edit code to meet code style requirements
geraldtivatyi Jun 8, 2021
5c41aaf
Merge pull request #5 from geraldtivatyi/codestyle-javascript-style-g…
geraldtivatyi Jun 8, 2021
0a3474b
fix navigation
geraldtivatyi Jun 9, 2021
d232ff5
fix navigation
geraldtivatyi Jun 9, 2021
8403aae
add filters
geraldtivatyi Jun 10, 2021
4c63762
fix filter bugs
geraldtivatyi Jun 11, 2021
4e32a4f
fix filters and navigation
geraldtivatyi Jun 11, 2021
5b98879
fix form filters
geraldtivatyi Jun 14, 2021
445ed5c
Merge pull request #6 from geraldtivatyi/fix-navigation
geraldtivatyi Jun 14, 2021
7fdc286
Update file names and refactor code
geraldtivatyi Jun 14, 2021
44ea44e
Fix file names and refactor code
geraldtivatyi Jun 14, 2021
e2bad73
Merge pull request #7 from geraldtivatyi/code-refactoring
geraldtivatyi Jun 14, 2021
b8c3324
responsive screen size
geraldtivatyi Jun 14, 2021
c9bb2dd
fix unnecessary calls and rapid firing calls
geraldtivatyi Jun 15, 2021
d62f5e8
New updates
geraldtivatyi Jun 17, 2021
bc0f8c6
Implement promises
geraldtivatyi Jun 17, 2021
d153f62
Implementing promises
geraldtivatyi Jun 18, 2021
bcc469c
Promises and fetch updates
geraldtivatyi Jun 18, 2021
ad82237
Updates
geraldtivatyi Jun 18, 2021
4b6e798
Update promises
geraldtivatyi Jun 20, 2021
40ac37d
Finalise promises
geraldtivatyi Jun 20, 2021
5615095
Updates - code refactoring
geraldtivatyi Jun 20, 2021
b24d3db
Code refactoring
geraldtivatyi Jun 20, 2021
e3ff6f0
Code refactoring
geraldtivatyi Jun 21, 2021
7b8f169
Final code refactoring
geraldtivatyi Jun 21, 2021
5178b2d
Merge pull request #8 from geraldtivatyi/new-updates
geraldtivatyi Jun 21, 2021
8d910b0
Updates to js files
geraldtivatyi Jun 21, 2021
8916976
Remove .js and .js.map files
geraldtivatyi Jun 21, 2021
5526bd2
Remove empty file
geraldtivatyi Jun 21, 2021
4060dce
Fixing code - comments
geraldtivatyi Jun 22, 2021
bf30acf
Fixing code - comments from code review
geraldtivatyi Jun 23, 2021
f63224e
Update code
geraldtivatyi Jun 23, 2021
8dbaa7b
Reworked left and right arrow functions.
geraldtivatyi Jun 23, 2021
e71702c
Remove js import statements and
geraldtivatyi Jun 28, 2021
8883bc6
Fix gitignore file
geraldtivatyi Jun 28, 2021
2ca2f32
Updates
geraldtivatyi Jun 29, 2021
2115eb4
Updates
geraldtivatyi Jun 29, 2021
329ab1a
Updates
geraldtivatyi Jun 30, 2021
1ab3ae1
Updates
geraldtivatyi Jul 1, 2021
7378b6b
Updates
geraldtivatyi Jul 1, 2021
59019f0
Updates
geraldtivatyi Jul 2, 2021
ebf4a49
Updates
geraldtivatyi Jul 2, 2021
be7b34a
Final updates
geraldtivatyi Jul 5, 2021
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
354 changes: 354 additions & 0 deletions app.ts

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions classes/get-column-headings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions classes/get-column-headings.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions classes/get-column-headings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// <reference path="../interfaces/has-format-method.ts" />

namespace HFM {
/**
* This function is used to fetch the column headings from the back-end
* @param hd This parameter holds the HTML DIV element with ID #headings
* @param interfaceHeading This parameter is of type interface and holds the method for rendering the headings to the HTML DOM
* @method HFM.TableHeadingString This method is for rendering the headings to the HTML DOM
*/
export function getColumnsHeadings() {
fetch("/columns").then(res => res.text()).then((headingsStr) => {
let hd = new HFM.RenderTableHeading(document.querySelector('#headings') as HTMLDivElement);
let interfaceHeading = new HFM.TableHeadingString(headingsStr);
hd.constructTableHeadings(interfaceHeading);
}).catch(err => console.log(err));
}
}
24 changes: 24 additions & 0 deletions classes/render-table-headings.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions classes/render-table-headings.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions classes/render-table-headings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/// <reference path="../interfaces/has-format-method.ts" />

namespace HFM {
/**
* This class is used to inject the created html string containing the headings into the DOM
* @param div This parameter holds the created div element which contaings the headings html string to be injected into the HTML DOM
*/
export class RenderTableHeading {
constructor( private container: HTMLDivElement) {}

constructTableHeadings(hd: HasFormatMethod) {
let div = document.createElement('div');
div.innerHTML = hd.internalFormat();
div.className = "tablecell";
div.style.gridTemplateColumns = "repeat("+hd.arrayLength()+", 1fr)";

this.container.append(div);
}
}
}
54 changes: 54 additions & 0 deletions classes/render-table-rows.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions classes/render-table-rows.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions classes/render-table-rows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/// <reference path="../interfaces/has-format-method.ts" />

namespace HFM {
/**
* This class is used to create and render the html string containing the rows of records into the DOM
* @param returnStr This parameter holds formatted html string containing the rows of records to be injected into the DOM
* @param arrLength This parameter holds length of the array containing the rows of the records
* @param records This parameter holds the HTML DIV element with the ID #records
* @param navigation This parameter holds the HTML DIV element with the ID #navigation
* @param myArr This parameter is the array of the parsed string of records fetched from the back-end
* @param headings This parameter holds the HTML DIV element with the ID #headings and is used to edit the style of the headings
* @param div This parameter is the created div holding the html rows to be injected into the HTML DOM
* @function arrayLength This function returns the length of the array of rows to be rendered. This length is used in styling the grid
* @function internalFormat This function returns the formatted html string containing all the rows of records
*/
export class RenderTableRows implements HasFormatMethod {
private returnStr = "";
private arrLength = 0;

constructor( recordsStr: string ){
let records = document.querySelector('#records') as HTMLDivElement;
let navigation = document.querySelector('#navigation') as HTMLDivElement;
let myArr = JSON.parse(recordsStr);

records.style.display = "grid";
records.style.gridTemplateRows = "repeat(auto-fill, "+(100/(myArr.length+2))+"%)";
records.style.height = "100%";
navigation.style.height = (100/(myArr.length+2))+"%";
let headings = document.querySelector('#headings') as HTMLDivElement;
headings.style.height = 100/(myArr.length+2)+"%";

for(let i=0;i<myArr.length;i++) {
for(let j=0;j<myArr[i].length;j++) {
this.arrLength = myArr[i].length;
this.returnStr +=
"<div><p>"+myArr[i][j]+"</p></div>";
}

let div = document.createElement('div');
div.innerHTML = this.returnStr;
div.className = "tablecell";
div.style.gridTemplateColumns = "repeat("+this.arrLength+", 1fr)";
records.append(div);
this.returnStr = "";
}
}

arrayLength() {
return this.arrLength;
}

internalFormat() {
return this.returnStr;
}
}
}
34 changes: 34 additions & 0 deletions classes/table-heading-string.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions classes/table-heading-string.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions classes/table-heading-string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/// <reference path="../interfaces/has-format-method.ts" />

namespace HFM {
/**
* This class is used to create the html string containing the column headings of the grid
* @param returnStr This parameter holds formatted html string containing the column headings to be injected into the DOM
* @param arrLength This parameter holds length of the array containing the column headings
* @param myArr This parameter is the array of the parsed string of headings fetched from the back-end
* @function arrayLength This function returns the length of the array of headings to be rendered
* @function internalFormat This function returns the formatted html string containing all the column headings
*/
export class TableHeadingString implements HasFormatMethod {
private returnStr = "";
private arrLength = 0;

constructor( headingsStr: string){
let myArr = JSON.parse(headingsStr);
this.arrLength = myArr.length;

for(let i=0;i<myArr.length;i++){
this.returnStr +=
"<div><p><b>"+myArr[i]+"</b></p></div>";
}
}

arrayLength() {
return this.arrLength;
}

internalFormat() {
return this.returnStr;
}
}
}
55 changes: 48 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<title>JS Onboard Project</title>
<script type="text/javascript" charset="utf-8" src="third_party/jquery-2.0.3.min.js"></script>
</head>
<head>
<title>JS Onboard Project</title>
<script type="text/javascript" charset="utf-8" src="third_party/jquery-2.0.3.min.js"></script>
<script type="module" src="app.js" defer></script>
<script type="text/javascript" src="interfaces/has-format-method.js"></script>
<script type="text/javascript" src="classes/render-table-headings.js"></script>
<script type="text/javascript" src="classes/table-heading-string.js"></script>
<script type="text/javascript" src="classes/get-column-headings.js"></script>
<script type="text/javascript" src="classes/render-table-rows.js"></script>
<link rel="stylesheet" href="main.css">
</head>
<body>
<!-- This section contains all the navigation tools of the grid -->
<div id="navigation" class="navigation">

<!-- This div contains the buttons to navigate directly to the beginning or the end of the entire data-set -->
<div class="filters">
<button class="button" id="gotostart">Go to Start</button>
<button class="button" id="gotoend">Go to End</button>
</div>

<body>
<p>Hello</p>
</body>
<!-- This div contains the form for navigating to the specified ID in the form as the start ID of the records showing -->
<div id="form" class="form">
<label>Start from ID: </label>
<input type="number" pattern="^[0-9]$" class="startfrom" id="startfrom" name="startfrom" placeholder="0" autofocus />
<input type="submit" class="submit" id="submit" value="Submit" />
</div>

<!-- This div contains the section for navigating left and right pages through the data -->
<div class="pagination">
<svg id="leftarrow" class="arrow" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M12 0c6.623 0 12 5.377 12 12s-5.377 12-12 12-12-5.377-12-12 5.377-12 12-12zm0 1c6.071 0 11 4.929 11 11s-4.929 11-11 11-11-4.929-11-11 4.929-11 11-11zm3 5.753l-6.44 5.247 6.44 5.263-.678.737-7.322-6 7.335-6 .665.753z"/></svg>
<div id="values" class="values">
<p id="fromID" name="fromID"></p>
<p>-</p>
<p id="toID" name="toID"></p>
<p>of</p>
<p id="numofrecords" name="numofrecords"></p>
</div>
<svg id="rightarrow" class="arrow" width="24" height="24" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M12 0c6.623 0 12 5.377 12 12s-5.377 12-12 12-12-5.377-12-12 5.377-12 12-12zm0 1c6.071 0 11 4.929 11 11s-4.929 11-11 11-11-4.929-11-11 4.929-11 11-11zm-3 5.753l6.44 5.247-6.44 5.263.678.737 7.322-6-7.335-6-.665.753z"/></svg>
</div>
</div>

<!-- This div contains the table with the column headings and the records -->
<div id="app">
<div id="table" class="table">
<div id="headings" class="headings"></div>
<div id="records" class="records"></div>
</div>
</div>
</body>
</html>

1 change: 1 addition & 0 deletions insomnia.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions interfaces/has-format-method.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions interfaces/has-format-method.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading