Skip to content

Commit 739de90

Browse files
Merge pull request #88 from ronellecaguioa/description
Description
2 parents 23943b4 + 73125b9 commit 739de90

11 files changed

Lines changed: 134 additions & 45 deletions

File tree

app/components/Applications.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ const Applications = () => {
2323
};
2424

2525
// Handle clicks on Application cards
26-
const handleClick = (app: string, i: number) => {
26+
const handleClick = (selectedApp: string, i: number) => {
2727
setIndex(i);
28-
setApp(app);
28+
setApp(selectedApp);
29+
console.log('handle', selectedApp)
2930
setOpen(true);
3031
};
3132

@@ -56,18 +57,18 @@ const Applications = () => {
5657

5758
return (
5859
<>
59-
{applications.map((app: string, i: number | any | string | undefined) => (
60+
{applications.map((app: string[], i: number | any | string | undefined) => (
6061
<Grid item xs={6} key={i}>
6162
<Paper
6263
className={classes.paper}
6364
id={i}
6465
key={i}
65-
onClick={(event: React.MouseEvent<HTMLElement>) => handleClick(app, i)}
66+
onClick={(event: React.MouseEvent<HTMLElement>) => handleClick(app[0], i)}
6667
>
67-
{app}
68+
{app[0]}
6869
<IconButton
6970
aria-label="Delete"
70-
onClick={(event: React.MouseEvent<HTMLElement>) => confirmDelete(app, i)}
71+
onClick={(event: React.MouseEvent<HTMLElement>) => confirmDelete(app[0], i)}
7172
color="primary"
7273
>
7374
<DeleteForeverOutlinedIcon className={classes.hover} />

app/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ApplicationContext } from '../context/ApplicationContext';
55
import '../stylesheets/Header.scss';
66

77
export interface HeaderProps {
8-
app: string;
8+
app: string[];
99
service: string;
1010
live: boolean;
1111
setLive: React.Dispatch<React.SetStateAction<boolean>>;

app/containers/GraphsContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import RouteTrace from '../charts/RouteTrace';
1818
import '../stylesheets/GraphsContainer.scss';
1919

2020
export interface Params {
21-
app: string;
21+
app: any;
2222
service: string;
2323
}
2424

app/context/DashboardContext.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface IFields {
1313
database: string;
1414
URI: string;
1515
name: string;
16+
description: string;
1617
}
1718

1819
export const DashboardContext = createContext<any>(null);
@@ -39,8 +40,11 @@ const DashboardContextProvider = ({ children }: Props) => {
3940
* of applications
4041
*/
4142
const addApp = (fields: IFields) => {
42-
const { database, URI, name } = fields;
43-
const result = ipcRenderer.sendSync('addApp', JSON.stringify([name, database, URI]));
43+
const { database, URI, name, description } = fields;
44+
const result = ipcRenderer.sendSync(
45+
'addApp',
46+
JSON.stringify([name, database, URI, description])
47+
);
4448
setApplications(result);
4549
};
4650

app/modals/AddModal.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface IFields {
66
database: string;
77
URI: string;
88
name: string;
9+
description: string;
910
}
1011

1112
interface IDashboard {
@@ -16,7 +17,7 @@ interface AddModalProps {
1617
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
1718
}
1819

19-
type InputElement = React.ChangeEvent<HTMLSelectElement | HTMLInputElement>;
20+
type InputElement = React.ChangeEvent<HTMLSelectElement | HTMLInputElement | HTMLTextAreaElement>;
2021
type FormElement = React.FormEvent<HTMLFormElement>;
2122

2223
const AddModal: React.FC<AddModalProps> = ({ setOpen }) => {
@@ -25,6 +26,7 @@ const AddModal: React.FC<AddModalProps> = ({ setOpen }) => {
2526
database: 'SQL',
2627
URI: '',
2728
name: '',
29+
description: '',
2830
});
2931

3032
// Submit form data and save to database
@@ -43,23 +45,24 @@ const AddModal: React.FC<AddModalProps> = ({ setOpen }) => {
4345
});
4446
};
4547

46-
const { database, URI, name } = fields;
48+
const { database, URI, name, description } = fields;
4749
return (
4850
<div className="add-container">
4951
<div className="add-header">
5052
<h2>Add an Application</h2>
5153
<p>Enter the database information used to track the service</p>
5254
</div>
5355
<form onSubmit={handleSubmit}>
54-
<div className="input-field">
55-
<label htmlFor="db-type">Type</label>
56+
<p>Required*</p>
57+
<div>
58+
<label htmlFor="db-type">Type<span>*</span></label>
5659
<select id="db-type" name="database" value={database} onChange={e => handleChange(e)}>
5760
<option value="SQL">SQL</option>
5861
<option value="MongoDB">MongoDB</option>
5962
</select>
6063
</div>
61-
<div className="input-field">
62-
<label htmlFor="db-uri">URI</label>
64+
<div>
65+
<label htmlFor="db-uri">URI<span>*</span></label>
6366
<input
6467
id="db-uri"
6568
name="URI"
@@ -69,8 +72,8 @@ const AddModal: React.FC<AddModalProps> = ({ setOpen }) => {
6972
required
7073
/>
7174
</div>
72-
<div className="input-field">
73-
<label htmlFor="db-name">Name</label>
75+
<div>
76+
<label htmlFor="db-name">Name<span>*</span></label>
7477
<input
7578
id="db-name"
7679
type="text"
@@ -81,6 +84,16 @@ const AddModal: React.FC<AddModalProps> = ({ setOpen }) => {
8184
required
8285
/>
8386
</div>
87+
<div>
88+
<label htmlFor="db-desc">Description</label>
89+
<textarea
90+
id="db-desc"
91+
name="db-desc"
92+
value={description}
93+
onChange={e => handleChange(e)}
94+
placeholder="Add a short description"
95+
/>
96+
</div>
8497
<button>Submit</button>
8598
</form>
8699
</div>

app/stylesheets/AddModal.scss

Lines changed: 55 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
@import './constants.scss';
22

33
.add-container {
4-
@include centerModal();
4+
@include centerModal(30%, 500px);
55

66
/* Header */
77
.add-header {
8+
width: 100%;
89
padding: 20px 30px;
910
text-align: center;
1011
border-bottom: thin solid $lightgray;
@@ -19,48 +20,85 @@
1920

2021
/* Form */
2122
form {
22-
@include centerWithFlex(center, column);
23-
padding: 0 30px;
23+
@include centerWithFlex($direction: column);
24+
padding: 20px 30px;
25+
width: 100%;
26+
27+
p,
28+
span {
29+
color: rgb(211, 0, 0);
30+
}
31+
32+
span {
33+
font-weight: 300;
34+
font-size: 80%;
35+
}
36+
37+
p {
38+
align-self: flex-start;
39+
}
2440

2541
div {
42+
@include centerWithFlex();
43+
44+
// <select /> margins
2645
&:first-of-type {
27-
margin-top: 0;
46+
margin-top: 20px;
47+
}
48+
49+
// <textarea>
50+
&:last-of-type {
51+
@include centerWithFlex($justify: flex-start, $align: flex-start);
2852
}
2953

3054
@include centerWithFlex(space-between);
3155
width: 100%;
3256
margin: 15px 0;
3357

34-
/* Text input */
35-
input {
36-
height: 30px;
37-
border: thin solid $lightgray;
38-
border-radius: 3px;
39-
flex: 1;
40-
font-family: inherit;
58+
select,
59+
input,
60+
textarea {
4161
font-size: 100%;
4262
padding: 5px;
63+
border: thin solid $lightgray;
64+
flex: 1;
65+
border-radius: 3px;
4366
}
4467

45-
/* Select field */
68+
// Select field
4669
select {
47-
appearance: none;
4870
cursor: pointer;
4971
height: 30px;
50-
border: thin solid $lightgray;
51-
flex: 1;
52-
font-size: 100%;
72+
margin: 0;
73+
appearance: none;
74+
transition: 0.2s;
75+
76+
&:hover {
77+
background-color: darken(#fff, 5%);
78+
}
79+
}
80+
81+
// Text input
82+
input {
83+
height: 30px;
84+
}
85+
86+
// Textarea
87+
textarea {
88+
resize: none;
89+
height: 90px;
5390
}
5491

5592
label {
56-
width: 100px;
93+
width: 140px;
5794
font-size: 135%;
5895
font-weight: 400;
5996
}
6097
}
6198

6299
/* Submit button */
63100
button {
101+
height: 40px;
64102
font-size: 115%;
65103
width: 50%;
66104
color: #fff;

app/stylesheets/Header.scss

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,37 @@ select {
2626
appearance: none;
2727
cursor: pointer;
2828
margin: 15px auto;
29+
30+
&:hover {
31+
background-color: darken(#fff, 5%);
32+
}
2933
}
3034

3135
.header-btns {
3236
display: flex;
3337

3438
button {
39+
&:first-of-type {
40+
position: absolute;
41+
top: 25px;
42+
left: 130px;
43+
background-color: transparent;
44+
border: 2px solid $sidebarblue;
45+
color: $sidebarblue;
46+
transition: 0.1s;
47+
48+
&:hover {
49+
background-color: $sidebarblue;
50+
color: #fff;
51+
}
52+
}
53+
3554
margin: 0 10px;
36-
font-size: 115%;
55+
font-size: 110%;
3756
letter-spacing: 1px;
38-
padding: 10px;
57+
padding: 12px;
3958
font-weight: 300;
59+
border-radius: 30px;
4060

4161
/* Live data dot */
4262
.dot {

app/stylesheets/MainContainer.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@
1616
@include centerWithFlex(center);
1717
width: 100%;
1818
padding: 10px;
19-
border-top: thin solid $lightgray;
2019
}
2120
}

app/stylesheets/constants.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ $headergray: #e8e8e8;
44
$lightgray: #c3c3c3;
55
$boxshadow: 2px 2px 6px rgb(187, 187, 187);
66

7-
@mixin centerWithFlex($justify: center, $direction: row) {
7+
@mixin centerWithFlex($justify: center, $direction: row, $align: center) {
88
display: flex;
9-
align-items: center;
9+
align-items: $align;
1010
justify-content: $justify;
1111
flex-direction: $direction;
1212
}
1313

14-
@mixin centerModal($width: auto) {
14+
@mixin centerModal($width: auto, $minwidth: 400px) {
1515
@include centerWithFlex(center, column);
1616
position: absolute;
1717
top: 50%;
1818
left: 50%;
1919
transform: translate(-50%, -50%);
2020
border-radius: 5px;
2121
width: $width;
22+
min-width: $minwidth;
2223
min-height: 100px;
2324
background-color: #f4f4f4;
2425
}

electron/routes/dashboard.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ipcMain, IpcMainEvent } from 'electron';
2+
import moment from 'moment';
23
import path from 'path';
34
import fs from 'fs';
45
/**
@@ -15,6 +16,12 @@ ipcMain.on('addApp', (message: IpcMainEvent, application: any) => {
1516

1617
// Add new applicaiton to list
1718
const newApp = JSON.parse(application);
19+
20+
// Add a creation date to the application
21+
const createdOn = moment().format('lll');
22+
newApp.push(createdOn);
23+
24+
// Add app to list of applications
1825
state.services.push(newApp);
1926

2027
// Update settings.json with new list
@@ -37,7 +44,7 @@ ipcMain.on('getApps', message => {
3744
);
3845

3946
// Destructure list of services from state to be rendered on the dashboard
40-
const dashboardList = state.services.map((arr: string[]) => arr[0]);
47+
const dashboardList = state.services.map((arr: string[]) => [arr[0], arr[3], arr[4]]);
4148

4249
// Sync event - return new applications list
4350
message.returnValue = dashboardList;

0 commit comments

Comments
 (0)