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

#20 - add pages for every tab #36

Merged
merged 74 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
ac77275
added home placeholder+route
Wiktor-Wojciechowski Jun 14, 2024
6b32d04
added a test link
Wiktor-Wojciechowski Jun 14, 2024
51474d6
added navbar home rawlog table page placeholders; added temporary ico…
Wiktor-Wojciechowski Jun 18, 2024
aebdbe6
added repositories, authors placeholders; updated home and navbar pages
Wiktor-Wojciechowski Jun 18, 2024
2fc0bf2
added footer to defaultlayout; cleaned up home; cleaned up navbar
Wiktor-Wojciechowski Jun 18, 2024
8c9e6f7
added file input to home
Wiktor-Wojciechowski Jun 18, 2024
fe2947d
Merge branch 'main' of https://github.com/blumilksoftware/gha-analyze…
Wiktor-Wojciechowski Jun 18, 2024
afda10c
home cleanup
Wiktor-Wojciechowski Jun 18, 2024
31b3c3e
moved bottom buttons from home to defaultlayout
Wiktor-Wojciechowski Jun 18, 2024
ccb7818
cleanup
Wiktor-Wojciechowski Jun 18, 2024
d9b0db1
changed script to script setup, removed export in defaultlayout
Wiktor-Wojciechowski Jun 18, 2024
12f62db
changed table, testing data passing
Wiktor-Wojciechowski Jun 19, 2024
65a0710
added repositories view
Wiktor-Wojciechowski Jun 24, 2024
af36d25
added authors page
Wiktor-Wojciechowski Jun 24, 2024
6b485fe
cleanup
Wiktor-Wojciechowski Jun 24, 2024
fa21417
added table page
Wiktor-Wojciechowski Jun 24, 2024
a5257cc
changed default layout
Wiktor-Wojciechowski Jun 24, 2024
16adec9
fixed sorting in table
Wiktor-Wojciechowski Jun 24, 2024
5606ed1
added pinia
Wiktor-Wojciechowski Jun 24, 2024
604879c
moved logs sample to logsStore
Wiktor-Wojciechowski Jun 24, 2024
eac0595
laout fix in home
Wiktor-Wojciechowski Jun 24, 2024
97e443c
cleanup
Wiktor-Wojciechowski Jun 24, 2024
2103e8a
added functions to modify logs (need fixing)
Wiktor-Wojciechowski Jun 24, 2024
c0e04ba
modified the store to make the pages update along the data
Wiktor-Wojciechowski Jun 25, 2024
85d77f5
cleanup
Wiktor-Wojciechowski Jun 25, 2024
b362489
made table reactive to log changes
Wiktor-Wojciechowski Jun 25, 2024
4115bb1
made repositories and authors reactive to log changes
Wiktor-Wojciechowski Jun 25, 2024
6770e1b
Merge branch 'main' of https://github.com/blumilksoftware/gha-analyze…
Wiktor-Wojciechowski Jun 25, 2024
ca44af2
added active link indicator
Wiktor-Wojciechowski Jun 25, 2024
486e9f4
cleanup
Wiktor-Wojciechowski Jun 25, 2024
e8b8ef1
layout changes, elements dis/appear depending on whether the logs are…
Wiktor-Wojciechowski Jun 25, 2024
a591ddd
added icons
Wiktor-Wojciechowski Jun 25, 2024
c974363
added titles to pages
Wiktor-Wojciechowski Jun 25, 2024
12d3728
fixed recursive rerenders in table page
Wiktor-Wojciechowski Jun 25, 2024
ac4af10
added icons, fixed icons not displaying on table page
Wiktor-Wojciechowski Jun 26, 2024
bc1dd22
cleanup
Wiktor-Wojciechowski Jun 26, 2024
0411cc9
fixed repositories not displaying colors
Wiktor-Wojciechowski Jun 26, 2024
dbebf97
fixed broken sorting on table page
Wiktor-Wojciechowski Jun 26, 2024
b541805
changed logsStore file type from js to ts
Wiktor-Wojciechowski Jun 26, 2024
27b6ac7
lint cleanup
Wiktor-Wojciechowski Jun 26, 2024
8741761
In response to PR comments, moved sample data from DefaultLayout to a…
Wiktor-Wojciechowski Jun 27, 2024
a6ff7fc
lint cleanup
Wiktor-Wojciechowski Jun 27, 2024
77f5770
fixed lint warnings
Wiktor-Wojciechowski Jun 27, 2024
3271534
Update resources/data/sampleData.json
Wiktor-Wojciechowski Jun 27, 2024
40cd13a
moved colors from pages to tailwind config; changed module.exports to…
Wiktor-Wojciechowski Jun 27, 2024
fa862bd
Merge branch '#20-add-pages-for-every-tab' of https://github.com/blum…
Wiktor-Wojciechowski Jun 27, 2024
c2a0922
colors can now be fetched from api
Wiktor-Wojciechowski Jul 1, 2024
296faef
added logs controller
Wiktor-Wojciechowski Jul 1, 2024
8006913
cleanup
Wiktor-Wojciechowski Jul 1, 2024
c08fc38
cleanup
Wiktor-Wojciechowski Jul 1, 2024
eab59af
updated files and paths
Wiktor-Wojciechowski Jul 2, 2024
1c667cf
changed colors json, colors still not working
Wiktor-Wojciechowski Jul 2, 2024
5c04736
added a colors service, added authors repositories table ccontrollers
Wiktor-Wojciechowski Jul 3, 2024
0931cf0
Merge branch 'main' of https://github.com/blumilksoftware/gha-analyze…
Wiktor-Wojciechowski Jul 4, 2024
4feafd2
Merge branch 'main' of https://github.com/blumilksoftware/gha-analyze…
PrabuckiDominik Aug 5, 2024
55eadc6
add workflow actor
AmonDeShir Aug 5, 2024
6ee07e2
fix code style
AmonDeShir Aug 5, 2024
d7e5e81
Rewrite frontend
AmonDeShir Aug 5, 2024
b4bf28c
remove unused dependencies
AmonDeShir Aug 5, 2024
91e77a8
remove pinia
AmonDeShir Aug 5, 2024
a4eb92c
remove ColorsService
AmonDeShir Aug 5, 2024
3fdda78
fix code style
AmonDeShir Aug 5, 2024
f7ed354
move GitHub to separate component
AmonDeShir Aug 6, 2024
7314da5
create table component
AmonDeShir Aug 6, 2024
c68dbda
remove empty line
AmonDeShir Aug 6, 2024
ba6f532
Merge branch 'main' of https://github.com/blumilksoftware/gha-analyze…
AmonDeShir Aug 6, 2024
74e0c94
move interfaces to a separate folder
AmonDeShir Aug 6, 2024
7cbe2dc
move actor interface to a separate file
AmonDeShir Aug 6, 2024
d503916
Merge branch 'main' of https://github.com/blumilksoftware/gha-analyze…
AmonDeShir Aug 6, 2024
60ef2ec
reduce nested loops
AmonDeShir Aug 6, 2024
d5128db
move minutes and price calculations to model
AmonDeShir Aug 6, 2024
cb8784f
move job price calculation and workflow name to model
AmonDeShir Aug 6, 2024
6ebf293
move data processing to resources
AmonDeShir Aug 7, 2024
e849bdb
Add return type to lambdas
AmonDeShir Aug 7, 2024
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
71 changes: 71 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"@tailwindcss/typography": "^0.5.10",
"laravel-vite-plugin": "^1.0.2",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"papaparse": "^5.4.1",
"pinia": "^2.1.7",
"tailwindcss": "^3.4.1",
"vue": "^3.4.21"
},
Expand Down
Binary file added resources/assets/images/blumilk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/images/units/ubuntu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/images/units/windows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions resources/css/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

kamilpiech97 marked this conversation as resolved.
Show resolved Hide resolved

3 changes: 3 additions & 0 deletions resources/data/sampleData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"sample": "Date,Product,SKU,Quantity,Unit Type,Price Per Unit ($),Multiplier,Owner,Repository Slug,Username,Actions Workflow,Notes\n2022-05-20,Actions,Compute - UBUNTU,2,minute,0.008,1.0,galaxy,trantor,octocat,.github/workflows/check-pr.yml,\n2022-05-20,Actions,Compute - UBUNTU,9,minute,0.008,1.0,galaxy,caprica,octocat,.github/workflows/check-pr.yml,\n2022-05-20,Actions,Compute - UBUNTU,8,minute,0.008,1.0,galaxy,mustafar,octocat,.github/workflows/test.yml,\n2022-05-20,Actions,Compute - UBUNTU,9,minute,0.008,1.0,galaxy,caprica,octocat,.github/workflows/lint.yml,\n2022-05-20,Actions,Compute - UBUNTU,3,minute,0.008,1.0,galaxy,trantor,octocat,.github/workflows/behat.yml,\n2022-05-20,Actions,Compute - UBUNTU,3,minute,0.008,1.0,galaxy,mustafar,octocat,.github/workflows/check-pr.yml,\n2022-05-20,Actions,Compute - UBUNTU,2,minute,0.008,1.0,galaxy,trantor,octocat,.github/workflows/behat.yml,\n2022-05-20,Actions,Compute - UBUNTU,15,minute,0.008,1.0,galaxy,caprica,octocat,.github/workflows/lint.yml,\n2022-05-20,Actions,Compute - WINDOWS,7,minute,0.016,1.0,galaxy,mustafar,octocat,.github/workflows/test-windows.yml,\n2022-05-20,Actions,Compute - UBUNTU,11,minute,0.008,1.0,galaxy,caprica,octocat,.github/workflows/check-pr.yml,\n2022-05-20,Actions,Compute - UBUNTU,2,minute,0.008,1.0,galaxy,mustafar,octocat,.github/workflows/test.yml,\n2022-05-20,Actions,Compute - UBUNTU,1,minute,0.008,1.0,galaxy,trantor,dependabot[bot],.github/workflows/check-pr.yml,\n2022-05-20,Actions,Compute - UBUNTU,7,minute,0.008,1.0,galaxy,trantor,octocat,.github/workflows/behat.yml,"
}
165 changes: 165 additions & 0 deletions resources/js/Pages/Authors.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<script setup>
import Papa from 'papaparse'
import moment from 'moment'
import { computed, ref, watch } from 'vue'
import { useLogsStore } from '@/Stores/logsStore'
import { Head } from '@inertiajs/vue3'

const logsStore = useLogsStore()
const logs = computed(() => logsStore.getLogs)

const colors = [
'bg-gray-400',
'bg-blue-400',
'bg-red-400',
'bg-green-400',
'bg-yellow-400',
'bg-indigo-400',
'bg-purple-400',
'bg-pink-400',
]
Wiktor-Wojciechowski marked this conversation as resolved.
Show resolved Hide resolved

var tables = ref({
logs: {
items: [],
sort: 'date',
order: 'asc',
},
})
var dictionaries = ref({
authors: {},
repositories: {},
})

function parseLineToLog (line) {
const repository = {
slug: line[7] + '/' + line[8],
name: line[8],
namespace: line[7] ? line[7] : 'unknown',
color: colors[repositories.value.length % colors.length],
}

if (!dictionaries.value.repositories[repository.name]) {
dictionaries.value.repositories[repository.name] = repository
dictionaries.value.repositories = JSON.parse(JSON.stringify(dictionaries.value.repositories))
} else {
repository.color = dictionaries.value.repositories[repository.name].color
}

let author = line[9]
if (author === 'dependabot[bot]') {
author = 'dependabot'
}

if (!dictionaries.value.authors[author]) {
dictionaries.value.authors[author] = author
dictionaries.value.authors = JSON.parse(JSON.stringify(dictionaries.value.authors))
}

return {
date: line[0],
dateForHumans: moment(line[0]).fromNow(),
product: line[1],
repository: repository,
slug: repository.slug,
quantity: parseInt(line[3]),
unit: line[2].replace('Compute - ', '').toLowerCase(),
price: line[5],
total: (line[3] * line[5]).toFixed(3),
author: author,
workflow: line[10],
notes: line[11],
}
}

function quantityPerAuthor (author) {
return tables.value.logs.items.filter(log => log.author === author).reduce((a, b) => a + parseInt(b.quantity), 0)
}
function pricePerAuthor (author) {
return tables.value.logs.items.filter(log => log.author === author).reduce((a, b) => a + parseFloat(b.total), 0).toFixed(3)
}

const sortedLogs = computed(() => {
let data = tables.value.logs.items

if (tables.value.logs.sort) {
data = data.sort((a, b) => {
if (!isNaN(a[tables.value.logs.sort]) && !isNaN(b[tables.value.logs.sort])) {
return a[tables.value.logs.sort] > b[tables.value.logs.sort] ? 1 : -1
}

return b[tables.value.logs.sort] > a[tables.value.logs.sort] ? 1 : -1
})
}

if (tables.value.logs.order === 'desc') {
data = data.reverse()
}

return data
})

const repositories = computed(() => {
return Object.values(dictionaries.value.repositories).sort((a, b) => a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1)
})

const authors = computed(() => {
return Object.values(dictionaries.value.authors).sort((a, b) => a.toLowerCase() > b.toLowerCase() ? 1 : -1)
})

const totalQuantity = computed(() => {
return tables.value.logs.items.reduce((a, b) => a + parseInt(b.quantity), 0)
})

const totalPrice = computed(() => {
return tables.value.logs.items.reduce((a, b) => a + parseFloat(b.total), 0).toFixed(3)
})

parseLogs()

watch (logs, () => {
parseLogs()
})

function parseLogs(){
const data = Papa.parse(logs.value)
const parsedData = data.data

var parsed = parsedData.slice(1,-1).map((line) => parseLineToLog(line))
tables.value.logs.items = parsed
}

</script>

<template>
<Head>
<title>Authors</title>
</Head>
<table v-if="sortedLogs.length > 0" class="w-full border-collapse border table-fixed mt-4 text-sm">
<thead>
<tr class="text-left">
<th class="w-1/2 border p-2">Author</th>
<th class="border p-2">Quantity</th>
<th class="border p-2 text-gray-500 font-normal">Quantity per cent</th>
<th class="border p-2">Total price</th>
<th class="border p-2 text-gray-500 font-normal">Price per cent</th>
</tr>
</thead>
<tbody>
<tr v-for="author in authors" :key="author" class="h-12">
<td class="border p-2">
<a v-if="author" :href="'https://github.com/' + author" class="flex items-center" target="_blank">
<img :src="'https://github.com/' + author + '.png'" class="size-6 rounded-full mr-2" :alt="author">
{{ author }}
</a>
<span v-else class="ml-8">unknown author</span>
</td>
<td class="border p-2">{{ quantityPerAuthor(author) }}</td>
<td class="border p-2 text-gray-500">{{ (quantityPerAuthor(author) * 100 / totalQuantity).toFixed(2) }}%</td>
<td class="border p-2">${{ pricePerAuthor(author) }}</td>
<td class="border p-2 text-gray-500">{{ (pricePerAuthor(author) * 100 / totalPrice).toFixed(2) }}%</td>
</tr>
</tbody>
</table>
<h1 v-else>No logs loaded</h1>
</template>
72 changes: 72 additions & 0 deletions resources/js/Pages/DefaultLayout.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script setup>
import { useLogsStore } from '@/Stores/logsStore'
import Navbar from './Navbar.vue'
import { ref } from 'vue'

const {clearLogs, setLogs} = useLogsStore()

const files = ref([])
const fileInput = ref(null)

const sampleDataURL = '../../data/sampleData.json'

async function fetchData(data) {
try {
const response = await fetch(new URL(data, import.meta.url).href)
const jsonData = await response.json()
return jsonData

} catch (error) {
console.error('Error loading data:', error)
}
}

async function seed () {
const jsonData = await fetchData(sampleDataURL)
const sample = jsonData.sample

setLogs(sample)

}
function clear () {
clearLogs()
}

const triggerFileInput = () => {
fileInput.value.click()
}

const onFileChange = (event) => {
const selectedFiles = Array.from(event.target.files)
files.value.push(...selectedFiles)
}
</script>

<template>
<Navbar />
<main class="container my-4 mx-auto bg-white rounded-xl p-4 shadow flex">
<div class="flex-1 p-4">
<slot />
</div>
</main>
<div class="container mt-6 mb-12 mx-auto">
<div class="block uppercase text-white font-semibold text-xs tracking-widest">
<nav class="flex items-center justify-end space-x-4">
<span class="cursor-pointer px-8 py-4 rounded-md bg-blue-400/50 hover:bg-blue-400/25" @click="clear">Clear Data</span>
<span class="cursor-pointer px-8 py-4 rounded-md bg-blue-400/50 hover:bg-blue-400/25" @click="triggerFileInput">
Upload CSV file
<input id="uploader" ref="fileInput" type="file" accept=".csv" class="hidden" @change="onFileChange">
</span>
<span class="cursor-pointer px-8 py-4 rounded-md bg-blue-400/50 hover:bg-blue-400/25" @click="seed">Seed Example Data</span>
</nav>
</div>
</div>
<footer>
<div class="w-full flex items-center justify-center text-white">
<span class="mr-2 font-semibold text-xs tracking-widest">developed by</span>
<a href="https://blumilk.pl/" target="_blank">
<img class="w-32" src="../../assets/images/blumilk.png" alt="Blumilk">
</a>
</div>
</footer>
</template>
16 changes: 16 additions & 0 deletions resources/js/Pages/Home.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup>
import { Head } from '@inertiajs/vue3'
import { useLogsStore } from '../Stores/logsStore'
import { computed } from 'vue'

const logsStore = useLogsStore()
const logs = computed(() => logsStore.getLogs)

</script>

<template>
<Head>
<title>GitHub Action simple analyzer</title>
</Head>
<textarea class="w-full text-xs font-mono shadow border rounded-xl p-3" :value="logs" rows="20" />
</template>
Loading
Loading