mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-06 00:00:44 +00:00
some changes / fixes
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
"main": "index.js",
|
||||
"author": "mbecker20",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "tsc && node build/main.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/dockerode": "^3.3.3",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
import { Component, createEffect, createResource, Match, Switch } from "solid-js";
|
||||
import { client, redirectTo } from "../..";
|
||||
import { Component, createResource, Match, Switch } from "solid-js";
|
||||
import { client } from "../..";
|
||||
import styles from "./App.module.css";
|
||||
import UserInfo from "../UserInfo";
|
||||
import { User } from "@oauth2/types"
|
||||
import { User } from "@monitor/types"
|
||||
import Login from "../Login";
|
||||
|
||||
const App: Component = () => {
|
||||
const [user, { mutate }] = createResource(() => client.getUser());
|
||||
|
||||
createEffect(() => {
|
||||
if (redirectTo && user()) {
|
||||
location.replace(`${redirectTo.url}/?token=${client.token}`)
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<div class={styles.App}>
|
||||
<Switch>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Component } from "solid-js";
|
||||
import { loginGithub, loginGoogle } from "../util/helpers";
|
||||
import { loginGithub } from "../util/helpers";
|
||||
import Input from "./util/Input";
|
||||
import Grid from "./util/layout/Grid";
|
||||
import { createStore } from "solid-js/store";
|
||||
import Flex from "./util/layout/Flex";
|
||||
import { client, pushNotification } from "..";
|
||||
import { User } from "@oauth2/types";
|
||||
import { User } from "@monitor/types";
|
||||
|
||||
const Login: Component<{ setUser: (user: User | false) => void }> = (p) => {
|
||||
const [info, set] = createStore({
|
||||
@@ -60,7 +60,6 @@ const Login: Component<{ setUser: (user: User | false) => void }> = (p) => {
|
||||
<button onClick={signup}>sign up</button>
|
||||
</Flex>
|
||||
<button onClick={loginGithub}>log in with github</button>
|
||||
<button onClick={loginGoogle}>log in with google</button>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, Show } from "solid-js";
|
||||
import { getAuthProvider } from "../util/helpers";
|
||||
import Flex from "./util/layout/Flex";
|
||||
import Grid from "./util/layout/Grid";
|
||||
import { User } from "@oauth2/types";
|
||||
import { User } from "@monitor/types";
|
||||
import { pushNotification } from "..";
|
||||
|
||||
const UserInfo: Component<{ user: User; logout: () => void }> = (p) => {
|
||||
@@ -15,9 +15,6 @@ const UserInfo: Component<{ user: User; logout: () => void }> = (p) => {
|
||||
<img src={p.user.avatar} style={{ width: "2rem", height: "2rem" }} />
|
||||
</Show>
|
||||
</Flex>
|
||||
<Show when={p.user.email}>
|
||||
<div>email: {p.user.email}</div>
|
||||
</Show>
|
||||
<button style={{ width: "100%" }} onClick={() => {
|
||||
p.logout();
|
||||
pushNotification("ok", "logged out");
|
||||
|
||||
@@ -4,12 +4,10 @@ import { render } from 'solid-js/web';
|
||||
import './index.css';
|
||||
import App from './components/App/App';
|
||||
import Client from './util/client';
|
||||
import { getRedirectTo } from './util/helpers';
|
||||
import makeNotifications from './components/util/notification/Notifications';
|
||||
|
||||
export const URL = "http://localhost:2020";
|
||||
export const client = new Client(URL);
|
||||
export const redirectTo = getRedirectTo();
|
||||
|
||||
export const { Notifications, pushNotification } = makeNotifications();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios from "axios";
|
||||
import { URL } from "..";
|
||||
import { User } from "@oauth2/types";
|
||||
import { User } from "@monitor/types";
|
||||
|
||||
export default class Client {
|
||||
token = localStorage.getItem("access_token");
|
||||
|
||||
@@ -1,44 +1,21 @@
|
||||
import { client, redirectTo, URL } from "..";
|
||||
import { User } from "@oauth2/types";
|
||||
import axios from "axios";
|
||||
import { URL } from "..";
|
||||
import { User } from "@monitor/types";
|
||||
|
||||
export function combineClasses(...classes: (string | undefined)[]) {
|
||||
return classes.filter((c) => (c ? true : false)).join(" ");
|
||||
}
|
||||
|
||||
export function getAuthProvider(user: User) {
|
||||
if (user.githubID) return "Github";
|
||||
else if (user.googleID) return "Google";
|
||||
else return "Local";
|
||||
export function inPx(num: number) {
|
||||
return `${num}px`;
|
||||
}
|
||||
|
||||
export function getRedirectTo() {
|
||||
const params = new URLSearchParams(location.search);
|
||||
const redirect = params.get("redirect");
|
||||
if (redirect) {
|
||||
if (redirect === "consumer") {
|
||||
return {
|
||||
service: "consumer",
|
||||
url: "http://localhost:3000"
|
||||
}
|
||||
}
|
||||
}
|
||||
export function getAuthProvider(user: User) {
|
||||
if (user.githubID) return "Github";
|
||||
else return "Local";
|
||||
}
|
||||
|
||||
export function loginGithub() {
|
||||
window.location.replace(
|
||||
`${URL}/login/github${redirectTo ? "/" + redirectTo.service : ""}`
|
||||
`${URL}/login/github`
|
||||
);
|
||||
}
|
||||
|
||||
export function loginGoogle() {
|
||||
window.location.replace(
|
||||
`${URL}/login/google${
|
||||
redirectTo ? "/" + redirectTo.service : ""
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
||||
export function inPx(num: number) {
|
||||
return `${num}px`;
|
||||
}
|
||||
@@ -4,6 +4,9 @@
|
||||
"main": "index.js",
|
||||
"author": "mbecker20",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "tsc && node build/main.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/dockerode": "^3.3.3",
|
||||
"typescript": "^4.6.2"
|
||||
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
export type User = {
|
||||
_id: string;
|
||||
username: string;
|
||||
githubID?: string;
|
||||
avatar?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user