diff --git a/.gitignore b/.gitignore index 6c3b648..29f1b5f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ public/build yarn-error.log release .todo -dist \ No newline at end of file +dist +pnpm-lock.yaml \ No newline at end of file diff --git a/readme.md b/README.md similarity index 100% rename from readme.md rename to README.md diff --git a/app/backend/plugins/inputs.ts b/app/backend/plugins/inputs.ts index cf23aa9..84593dc 100644 --- a/app/backend/plugins/inputs.ts +++ b/app/backend/plugins/inputs.ts @@ -20,4 +20,9 @@ export const inputs = { type: "git", placeholder: "Indirizzo", }, + id: { + name: "ID", + type: "text", + placeholder: "ID", + }, }; diff --git a/app/backend/plugins/plugins.ts b/app/backend/plugins/plugins.ts index 9aecbfb..da9629f 100644 --- a/app/backend/plugins/plugins.ts +++ b/app/backend/plugins/plugins.ts @@ -23,7 +23,7 @@ const plugins = [ { name: "Git", icon: "", - inputs: [i.git], + inputs: [i.git, i.id], envBound: false, }, ]; diff --git a/app/frontend/components/App.svelte b/app/frontend/components/App.svelte index 5c61da5..04d03ec 100644 --- a/app/frontend/components/App.svelte +++ b/app/frontend/components/App.svelte @@ -1,5 +1,6 @@
diff --git a/app/frontend/components/NewEnviroments/NewEnviroments.svelte b/app/frontend/components/NewEnviroments/NewEnviroments.svelte index 2644a1b..2926123 100644 --- a/app/frontend/components/NewEnviroments/NewEnviroments.svelte +++ b/app/frontend/components/NewEnviroments/NewEnviroments.svelte @@ -73,7 +73,9 @@ enviroments = enviroments.filter((e, i) => i != id); - selectedEnv = enviroments.length - 1; + setTimeout(() => { + selectedEnv = enviroments.length - 1; + }, 500); } function setEnvName(envId: number) { @@ -86,7 +88,7 @@ {#each enviroments as enviroment, envId}
(selectedEnv = envId)} in:fly={{ x: -500 }} out:fly={{ x: -500 }} diff --git a/app/frontend/components/NewEnviroments/newEnviroments.scss b/app/frontend/components/NewEnviroments/newEnviroments.scss index 5f5ca9a..7b8bd75 100644 --- a/app/frontend/components/NewEnviroments/newEnviroments.scss +++ b/app/frontend/components/NewEnviroments/newEnviroments.scss @@ -1,8 +1,9 @@ @import "../../scss/variables.scss"; .enviroment { + transition: 0.5s; padding: 15px; - + margin: 10px; display: flex; justify-content: center; flex-direction: column; @@ -40,13 +41,17 @@ } } } + + &.selectedEnv { + box-shadow: 0px 0px 2px 2px $color_4; + } } .newEnviroment { transition: 0.2s; font-family: NerdFont; border: 2px dashed $color_7; - margin-right: 10px; + margin: 10px; border-radius: 10px; padding: 20px; display: flex; diff --git a/app/frontend/components/NewInput/NewInput.svelte b/app/frontend/components/NewInput/NewInput.svelte index 97d5108..fb2010d 100644 --- a/app/frontend/components/NewInput/NewInput.svelte +++ b/app/frontend/components/NewInput/NewInput.svelte @@ -22,25 +22,8 @@ switch (type) { case "ip": - err = !(regexIP.test(value) || regexAddress.test(value)); - break; case "git": - try { - let addr = value; - const addrArray = addr.split("/"); - const flavour = addrArray[2].split(".")[0]; - let owner = ""; - let repo = ""; - - if (flavour == "github") { - owner = addrArray[3]; - repo = addrArray[4].split(".")[0]; - } - err = false; - } catch { - err = true; - } - + err = !(regexIP.test(value) || regexAddress.test(value)); break; } @@ -48,9 +31,8 @@ if (!envBound) { state.standalonePlugins[pluginId].inputs[inputId].value = value; } else { - state.enviroments[envId].plugins[pluginId].inputs[ - inputId - ].value = value; + state.enviroments[envId].plugins[pluginId].inputs[inputId].value = + value; } return state; diff --git a/app/frontend/components/NewPlugin/NewPlugin.svelte b/app/frontend/components/NewPlugin/NewPlugin.svelte index 16fc370..49b428a 100644 --- a/app/frontend/components/NewPlugin/NewPlugin.svelte +++ b/app/frontend/components/NewPlugin/NewPlugin.svelte @@ -1,14 +1,16 @@ -
-

deletePlugin()}> - {plugin.name} -

-
- {#each plugin.inputs as input, inputId} - - {/each} +{#if plugin.name == "Git"} + {#if !(openGitlab || openGitHub)} +
+
{ + openGitlab = true; + }} + > +  +
+
{ + openGitHub = true; + }} + > +  +
+
+ {/if} + {#if openGitlab || openGitHub} +
+

deletePlugin()}> + {openGitlab ? "GitLab" : "GitHub"} +

+
+ + {#if openGitlab} + + {/if} +
+
+ {/if} +{:else} +
+

deletePlugin()}> + {plugin.name} +

+
+ {#each plugin.inputs as input, inputId} + + {/each} +
-
+{/if} diff --git a/app/frontend/components/SearchProjects/searchProjects.scss b/app/frontend/components/SearchProjects/searchProjects.scss new file mode 100644 index 0000000..a4ff285 --- /dev/null +++ b/app/frontend/components/SearchProjects/searchProjects.scss @@ -0,0 +1,10 @@ +@import "../../scss/variables.scss"; + +.searchProjects { + background: $color_2; + height: 60px; + border-radius: 60px; + padding: 20px 30px; + font-size: 20px; + margin-left: 30px; +} diff --git a/app/frontend/components/StandalonePlugins/Git/Git.svelte b/app/frontend/components/StandalonePlugins/Git/Git.svelte index 687d5d7..6d22ef5 100644 --- a/app/frontend/components/StandalonePlugins/Git/Git.svelte +++ b/app/frontend/components/StandalonePlugins/Git/Git.svelte @@ -1,91 +1,73 @@ @@ -109,9 +91,9 @@
-
{repo}
- {#if description} -
{description}
+
{repoName}
+ {#if repoDescription} +
{repoDescription}
{/if}
@@ -145,7 +127,7 @@ {/if}
- {#if commits} + {#if commits[0]}
{#each commits as commit, i}
{commit.author.login}
- {emoji.replace_colons(commit.commit.message)} + {emoji.replace_colons(commit.title)}
- - {commit.author.login} + - {commit.author_name}
{commit.date} @@ -175,7 +157,7 @@ {/each}
{:else} - loading + {/if} {:else}
@@ -187,35 +169,39 @@ {:else}
- {#each commits as commit, i} - {#if i < commitPerPlugin} -
(i < commitPerPlugin ? (open = true) : "")} - > -
- {commit.author.login} -
- -
-
- {emoji.replace_colons(commit.commit.message)} + {#if commits[0]} + {#each commits as commit, i} + {#if i < commitPerPlugin} +
(i < commitPerPlugin ? (open = true) : "")} + > +
+ {commit.author_name}
-
- {commit.author.login}
-
- {commit.date} + +
+
+ {emoji.replace_colons(commit.title)} +
+
- {commit.author_name}
+
+ {commit.date} +
-
- {/if} - {/each} + {/if} + {/each} + {:else} + + {/if}
{/if} diff --git a/app/frontend/components/StandalonePlugins/Git/git.scss b/app/frontend/components/StandalonePlugins/Git/git.scss index da144e3..a83389a 100644 --- a/app/frontend/components/StandalonePlugins/Git/git.scss +++ b/app/frontend/components/StandalonePlugins/Git/git.scss @@ -1,11 +1,14 @@ @import "../../../scss/variables.scss"; .notFound { - background: $color_5; + border: 2px solid $color_5; + color: $color_5; font-size: 20px; text-align: center; - padding: 20px; + padding: 30px 40px; border-radius: 10px; + width: fit-content; + margin: 0 auto; } .close { @@ -131,10 +134,10 @@ .author { position: relative; - width: 20%; + width: fit-content; .propic { - height: 100%; + height: 150px; border-right: 5px solid $color_7; } } @@ -142,24 +145,26 @@ .message { width: 80%; font-size: 20px; - margin-left: 20px; padding: 20px; overflow-y: scroll; position: relative; + display: flex; + flex-wrap: wrap; + justify-content: space-between; + margin: 10px; .text { border-bottom: 3px dashed $color_7; margin-bottom: 10px; overflow-x: scroll; + width: 100%; } - .name { - margin-top: 10px; - } + .name, .date { - position: absolute; - bottom: 10px; - right: 10px; + display: flex; + justify-content: center; + align-items: center; } } diff --git a/app/frontend/components/Updater/Updater.svelte b/app/frontend/components/Updater/Updater.svelte index de344e7..83d7a74 100644 --- a/app/frontend/components/Updater/Updater.svelte +++ b/app/frontend/components/Updater/Updater.svelte @@ -66,15 +66,6 @@
{/if} - diff --git a/app/frontend/scss/animations.scss b/app/frontend/scss/animations.scss index 99885ce..7c8c29a 100644 --- a/app/frontend/scss/animations.scss +++ b/app/frontend/scss/animations.scss @@ -6,3 +6,29 @@ transform: rotate(360deg); } } + +@-webkit-keyframes sk-cubeGridScaleDelay { + 0%, + 70%, + 100% { + -webkit-transform: scale3D(1, 1, 1); + transform: scale3D(1, 1, 1); + } + 35% { + -webkit-transform: scale3D(0, 0, 1); + transform: scale3D(0, 0, 1); + } +} + +@keyframes sk-cubeGridScaleDelay { + 0%, + 70%, + 100% { + -webkit-transform: scale3D(1, 1, 1); + transform: scale3D(1, 1, 1); + } + 35% { + -webkit-transform: scale3D(0, 0, 1); + transform: scale3D(0, 0, 1); + } +} diff --git a/app/frontend/scss/index.scss b/app/frontend/scss/index.scss index 0ca56d9..a5bb54a 100644 --- a/app/frontend/scss/index.scss +++ b/app/frontend/scss/index.scss @@ -1 +1,10 @@ @import "../scss/variables.scss"; + +.footer { + position: fixed; + left: 30px; + bottom: 30px; + display: flex; + justify-content: center; + align-items: center; +} diff --git a/app/frontend/scss/variables.scss b/app/frontend/scss/variables.scss index df1212a..5b98157 100644 --- a/app/frontend/scss/variables.scss +++ b/app/frontend/scss/variables.scss @@ -1,8 +1,8 @@ @import "./animations.scss"; // Varibles -$color_1: #06090f; // $color_1: #1b2128; -$color_2: #0d1117; // $color_2: #212931; +$color_1: #1b2128; // $color_1: #1b2128; +$color_2: #212931; // $color_2: #212931; $color_3: #dd83a0; $color_4: #63aec0; $color_5: #e25987; @@ -11,7 +11,7 @@ $color_7: #b877b4; $color_8: #fec262; $color_9: #e5e5e5; -:global(*) { +* { &::-webkit-scrollbar { width: 10px; } diff --git a/app/frontend/services/pluginService.ts b/app/frontend/services/pluginService.ts index 307f4ac..56d57b1 100644 --- a/app/frontend/services/pluginService.ts +++ b/app/frontend/services/pluginService.ts @@ -9,78 +9,4 @@ export module pluginService { .catch((error) => reject(error)); }); } - - export async function getGitInfo(addr: string) { - const addrArray = addr.split("/"); - const flavour = addrArray[2].split(".")[0]; - let owner = null; - let repo = null; - let readme = null; - let description = null; - - if (flavour == "github") { - owner = addrArray[3]; - repo = addrArray[4].split(".")[0]; - - if (owner && repo) { - try { - const readmeData: any = await axios.get( - `https://raw.githubusercontent.com/${owner}/${repo}/master/README.md` - ); - readme = readmeData.data; - } catch (error) { - console.log(error); - } - - const { data } = await axios.get( - `https://api.github.com/repos/${owner}/${repo}` - ); - description = data.description; - } - } - - return { readme, description }; - } - - export async function getGitBranches(addr: string) { - const addrArray = addr.split("/"); - const flavour = addrArray[2].split(".")[0]; - let owner = null; - let repo = null; - let branches = null; - - if (flavour == "github") { - owner = addrArray[3]; - repo = addrArray[4].split(".")[0]; - - if (owner && repo) { - const branchesData: any = await axios.get( - `https://api.github.com/repos/${owner}/${repo}/branches` - ); - branches = branchesData.data; - } - return branches; - } - } - - export async function getGitCommitsByBranch(branch: string, addr: string) { - const addrArray = addr.split("/"); - const flavour = addrArray[2].split(".")[0]; - let owner = null; - let repo = null; - let branches = null; - if (flavour == "github") { - owner = addrArray[3]; - repo = addrArray[4].split(".")[0]; - - if (owner && repo) { - const { data } = await axios.get( - `https://api.github.com/repos/${owner}/${repo}/commits\?sha\=${branch}` - ); - branches = data; - } - } - - return branches; - } } diff --git a/app/frontend/services/pluginServices/gitService.ts b/app/frontend/services/pluginServices/gitService.ts new file mode 100644 index 0000000..ad8c1ea --- /dev/null +++ b/app/frontend/services/pluginServices/gitService.ts @@ -0,0 +1,248 @@ +import axios from "axios"; + +const privateToken = ""; + +export module gitService { + export async function getGitInfo(addr: string, flavour: string, id: string) { + const addrArray = addr.split("/"); + let readme = null; + let repoName = null; + let repoDescription = null; + + switch (flavour) { + case "gitlab": + const giturl = addrArray[0] + "//" + addrArray[2]; + + try { + const { data }: any = await axios.get( + `${giturl}/api/v4/projects/${id}/repository/files/README.md/raw?ref=master`, + { + headers: { + "PRIVATE-TOKEN": privateToken, + }, + } + ); + + readme = data; + } catch (error) { + console.error(error); + } + + try { + const { data } = await axios.get(`${giturl}/api/v4/projects/${id}`, { + headers: { + "PRIVATE-TOKEN": privateToken, + }, + }); + + repoDescription = data.description; + repoName = data.name; + } catch (error) { + console.error(error); + } + break; + case "github": + const owner = addrArray[3]; + const repo = addrArray[4].split(".")[0]; + + if (owner && repo) { + try { + const readmeData: any = await axios.get( + `https://raw.githubusercontent.com/${owner}/${repo}/master/README.md` + ); + readme = readmeData.data; + } catch (error) { + console.log(error); + } + + const { data } = await axios.get( + `https://api.github.com/repos/${owner}/${repo}` + ); + + repoName = data.name; + repoDescription = data.description; + } + break; + + default: + console.error("Unsupported git flavour"); + break; + } + + return { readme, repoName, repoDescription }; + } + + export async function getGitBranches( + addr: string, + flavour: string, + id: string + ) { + const addrArray = addr.split("/"); + let branches = null; + + switch (flavour) { + case "gitlab": + let giturl = addrArray[0] + "//" + addrArray[2]; + + const branchesData = await axios.get( + `${giturl}/api/v4/projects/${id}/repository/branches`, + { + headers: { + "PRIVATE-TOKEN": privateToken, + }, + } + ); + + branches = branchesData.data; + break; + case "github": + let owner = addrArray[3]; + let repo = addrArray[4].split(".")[0]; + + if (owner && repo) { + const branchesData: any = await axios.get( + `https://api.github.com/repos/${owner}/${repo}/branches`, + { + headers: { + "PRIVATE-TOKEN": privateToken, + }, + } + ); + + branches = branchesData.data; + } + break; + + default: + console.error("Unsupported git flavour"); + break; + } + + return branches; + } + + export async function getGitCommitsByBranch( + branchID: string, + addr: string, + id: string, + flavour: string + ) { + const addrArray = addr.split("/"); + let commits = null; + let giturl; + + switch (flavour) { + case "gitlab": + giturl = addrArray[0] + "//" + addrArray[2]; + + const { data } = await axios.get( + `${giturl}/api/v4/projects/${id}/repository/commits`, + { + params: { + ref_name: branchID, + }, + headers: { + "PRIVATE-TOKEN": privateToken, + }, + } + ); + + commits = data; + break; + + case "github": + let owner = addrArray[3]; + let repo = addrArray[4].split(".")[0]; + + if (owner && repo) { + const { data } = await axios.get( + `https://api.github.com/repos/${owner}/${repo}/commits`, + { + params: { + sha: branchID, + }, + } + ); + + commits = data; + } + break; + + default: + break; + } + + const formattedCommits = await formatCommits(commits, flavour, addr); + return formattedCommits; + } +} + +async function formatCommits(commits: any, flavour: string, addr: string) { + const addrArray = addr.split("/"); + let rawDate: Date; + let date: string; + let formattedCommits: any = []; + + switch (flavour) { + case "gitlab": + formattedCommits = await Promise.all( + commits.map(async (commit, i) => { + let formattedCommit = {}; + let giturl = addrArray[0] + "//" + addrArray[2]; + rawDate = new Date(commit.committed_date); + date = + rawDate.getDate() + + "/" + + (rawDate.getMonth() + 1) + + "/" + + rawDate.getFullYear(); + + const avatar = await axios.get(`${giturl}/api/v4/avatar`, { + headers: { + "PRIVATE-TOKEN": privateToken, + }, + params: { + size: "64", + email: commit.committer_email, + }, + }); + + formattedCommit = { + date, + title: commit.title, + author_name: commit.author_name, + author_avatar: avatar.data.avatar_url, + }; + + return formattedCommit; + }) + ); + break; + + case "github": + formattedCommits = commits.map((commit, i) => { + rawDate = new Date(commit.commit.author.date); + date = + rawDate.getDate() + + "/" + + (rawDate.getMonth() + 1) + + "/" + + rawDate.getFullYear(); + commit = { + date, + title: commit.commit.message, + author_name: commit.author.login, + author_avatar: commit.author.avatar_url, + }; + + return commit; + }); + break; + + default: + console.error(`Unsupported git flavour`); + break; + } + + return formattedCommits; +} diff --git a/app/frontend/stores.ts b/app/frontend/stores.ts index ac98292..8f27871 100644 --- a/app/frontend/stores.ts +++ b/app/frontend/stores.ts @@ -11,3 +11,5 @@ export const newProjectStore: Writable = writable({ }); export const projectsStore: Writable = writable([]); + +export const searchProjectsStore: Writable = writable(""); diff --git a/package.json b/package.json index 8848938..843f2b5 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "package-all": "npm run build && electron-builder build -mwl", "package-linux": "npm run build && electron-builder build --linux", "package-win": "npm run build && electron-builder build --win --x64", - "release": "cross-env MODE=prod electron-builder -p always" + "release": "cross-env MODE=prod electron-builder -p always -wl" }, "build": { "productName": "ProjectsBT",