Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a list of vehicles #43

Merged
merged 6 commits into from
Aug 9, 2023
Merged

Added a list of vehicles #43

merged 6 commits into from
Aug 9, 2023

Conversation

n1kPLV
Copy link
Contributor

@n1kPLV n1kPLV commented Jul 26, 2023

fixes #38, closes #38

@n1kPLV n1kPLV mentioned this pull request Jul 23, 2023
@n1kPLV n1kPLV linked an issue Jul 27, 2023 that may be closed by this pull request
Copy link
Contributor Author

@n1kPLV n1kPLV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Größtenteils UI Änderungen.

Interessant sind insbesondere Website/src/app/list/page.tsx, sowie Website/src/components/dynlist.tsx

Rein kosmetisch sind die Änderungen in Website/src/components/layout_base.tsx, Website/src/app/layout.tsx, Website/src/pages/_app.tsx, und Website/src/pages/_document.tsx

Previously, each popup, even if closed was its own React root, which could have a negative performance impact.
@n1kPLV n1kPLV added the web label Jul 30, 2023
Copy link
Member

@NiklasRentzCAU NiklasRentzCAU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general the structuring looks fine to allow for a modular website. Some general comments about the code:

All code should have a header comment indicating the copyright and used license, as the code from our other repositories does as well. Something like this:

/*
 * KIELER RailTrail
 *
 * http://rtsys.informatik.uni-kiel.de/kieler
 * 
 * Copyright 2023 by
 * + Kiel University
 *   + Department of Computer Science
 *     + Real-Time and Embedded Systems Group
 * 
 * This code is provided under the terms of the Eclipse Public License 2.0 (EPL-2.0).
 */

Please document your code. I will not do a more rigorous review, as that would require me to understand what each part does from the naming and the code alone, which I would prefer not to have to do. Please start writing code in a style where you always document the code as you write it, that is a good habit to have to write readable code that not only others, but also you will be able to understand later. We will further review the code style once there are comments.

Some more questions arising in the structure:

  • why is there an app/components and a components folder? Should there be a difference between these?
  • is the pages folder supposed to hold all pages in the end? Or do you want to organize this via their use/components? Please choose one style.
  • lib as a source folder name can be dangerous in the TypeScript world, as many projects compile their code into a lib folder by default and developers may be accustomed to this, maybe a better name would be utils or similar.

children: React.ReactNode
}) {
return (
<div className='h-full min-h-screen flex flex-initial flex-col'>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To organize the styling between the different files all the stylings should be structured into .css files and only referenced by their class here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WON'T FIX: this sort of styling is only used for this component. There is absolutely nothing gained by defining a custom CSS class page_container that magically applies the same style. Additionally, I would then have to look at two different files to figure out why something is styled like it is. (Also it would defy the use of tailwind for this page)

I would argue, that it also helps with maintainability, as there are no 'orphaned' CSS styles hanging around in a CSS file somewhere, that might still be in use

However, (not in this case, but maybe for some other thing) I should move some duplicated layout things into a component or a layout.tsx file.

import Header from "@/app/components/header";
import Footer from "@/app/components/footer";

export default function Layout({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick look through this shows me that there are practically no comments in the code and no documentation for the public API. That makes it a lot harder to understand and also review code such as this. Please comment your code.


export default RootLayout;
export default function RootLayout({children,}: { children: React.ReactNode }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming here seems inconsistent: the layout_base file contains theLayout and the layout file the RootLayout.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files named layout.ts(x) (in the app-directory) have special meaning in next.js as these define a component that "wrapps" all page components in subdirectories. As I however need to use the same layout in both the app-, as well as the pages-directory. I factored the relevant parts into a component.

However I agree that naming things is hard

init_data = (token && track_selected) ? await getInitData(token, track_id) : undefined;
server_vehicles = (token && track_selected) ? await getVehicleData(token, track_id) : [];
} catch (e) {
console.error('Catched e:', e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error messages should be a bit more informative about the context in which they occurred.

@n1kPLV
Copy link
Contributor Author

n1kPLV commented Jul 31, 2023

Some thoughts on the general comments, also why some of these are impossible to resolve without switching the currently used framework (nextjs)

Next does routing based on directory structure. The modern way to do this is the app/-directory, which holds, unless otherwise noted, server-Side components (see https://nextjs.org/docs/app/building-your-application/routing ). Components co-located in subdirectories of the app-directory also become server components, unless they are explicitly declared as client components, using "use client". However, this hasn't quite reached the feature parity and library support as the older pages/-directory. I only need to use such features for logging out, so I do not plan on moving all pages there.

However, I should probably move all components into the app/components- folder, as this should not make a difference.

I will also try to add more comments, however we could probably start a long discussion about the amount of comments that are necessary. I guess we both want to avoid that.

@n1kPLV n1kPLV merged commit c23b078 into development Aug 9, 2023
3 checks passed
@JulianGrabitzky JulianGrabitzky deleted the 38-vehicle-list branch August 16, 2023 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List of vehicles
2 participants