Skip to content

Commit

Permalink
fixed scrolling on page notes . increased number of notes in dashboar…
Browse files Browse the repository at this point in the history
…d . changed the license . fixed some styles . fixed submitiing new note . working on prventing on ENTER
  • Loading branch information
taricov committed Nov 24, 2023
1 parent a108054 commit 9edfd74
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 39 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Anthony Fu
Copyright (c) 2023 Taric Ov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Binary file removed src/assets/sound effects/connect.mp3
Binary file not shown.
Binary file removed src/assets/sound effects/connect.wav
Binary file not shown.
Binary file removed src/assets/sound effects/connected2.mp3
Binary file not shown.
Binary file removed src/assets/sound effects/newNote.mp3
Binary file not shown.
Binary file removed src/assets/sound effects/newNote2.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion src/components/Connector.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- eslint-disable unused-imports/no-unused-vars -->
<script setup lang="ts">
import connectSound from '../assets/sound effects/connected2.mp3'
import connectSound from '../assets/sound_effects/connected2.mp3'
import { getUserData, setUserData } from '../logic/utils'
import { CreateUser, GetUser } from '../logic/dbSDK'
import type { User } from '../logic/types'
Expand Down
6 changes: 3 additions & 3 deletions src/components/VueCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let editedNote: any
<template>
<v-card
variant="tonal"
class="!min-h-[148px] group !bg-slate-900 !text-slate-300 !transition-all duration-300 shadow-lg hover:-translate-y-1 transform !z-10"
class="group flex flex-col !bg-slate-900 !text-slate-300 !transition-all duration-300 shadow-lg hover:-translate-y-1 transform !z-10 space-y-3 py-3"
>
<div class="group-hover:opacity-100 opacity-30 mt-4 transition duration-300">
{{ num }}
Expand All @@ -29,14 +29,14 @@ let editedNote: any
</div>
</v-container>

<v-container class="mt-5">
<v-container class="mt-5 flex-1">
<p class="text-lg font-semibold">
{{ author }}
</p>
<p class="italic hover:opacity-100 opacity-50 transition duration-300">
{{ path?.split("?")[0].split("owner")[1] ?? path?.split("?")[0].split(".com")[1] }}
</p>
<v-chip class="text-md my-2">
<v-chip class="text-xs my-2">
{{ date }}
</v-chip>
<p class="text-md h-15 px-3 py-2 my-2 line-clamp-3">
Expand Down
5 changes: 2 additions & 3 deletions src/contentScripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { onMessage } from 'webext-bridge/content-script'
import 'vuetify/styles'
import { createVuetify } from 'vuetify'
Expand All @@ -11,11 +10,11 @@ import { setupApp } from '~/logic/common-setup'

// Firefox `browser.tabs.executeScript()` requires scripts return a primitive value
(() => {
console.info('[vitesse-webext] Hello world from content script')
// console.info('[vitesse-webext] Hello world from content script')

// communication example: send previous tab title from background page
onMessage('tab-prev', ({ data }) => {
console.log(`[vitesse-webext] Navigate from page "${data.title}"`)
// console.log(`[vitesse-webext] Navigate from page "${data.title}"`)
})

// mount component to context window
Expand Down
72 changes: 49 additions & 23 deletions src/contentScripts/views/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
<script setup lang="ts">
import 'uno.css'
import { useClipboard, useMagicKeys, whenever } from '@vueuse/core'
import newNoteSound from '../../assets/sound effects/newNote.mp3'
// import notes from '../../fakedata'
import newNoteSound from '../../assets/sound_effects/newNote.mp3'
import { CreateNote, GetNotes } from '../../logic/daftraApi'
// import { currPageNotes } from '../../logic/utils'
import type { NoteDataApi, User } from '../../logic/types'
import { GetUser } from '~/logic/dbSDK'
import { extractBody, extractColor, extractPath, getUserData } from '~/logic/utils'
Expand All @@ -21,7 +19,7 @@ const noteTextarea = ref<HTMLTextAreaElement>()
const notingDisabled = ref<boolean>(true)
const apikey = ref<string>('')
const subD = ref<string>('')
const moduleKey = ref<string>('')
const moduleKey = ref<Number | null>(null)
const form = ref<HTMLFormElement>()
const isLoading = ref<boolean>(false)
const loadingNotes = ref<boolean>(false)
Expand Down Expand Up @@ -61,15 +59,15 @@ onMounted(async () => {
// const chromeStorage2: any = await getStorageValuePromise('email')
isConnected.value = !!sec1 && !!sec2
userE.value = sec3
console.log('Connected', isConnected.value, userE.value)

if (isConnected && userE.value) {
const user: User = await GetUser('email', userE.value.userEmail)
// console.log(user)
notingDisabled.value = false
moduleKey.value = user.documents[0].dnote_module_key
apikey.value = user.documents[0].api_key
apikey.value = user.documents[0].apikey
subD.value = user.documents[0].subdomain
console.log(user)
const allNotesReq = await GetNotes(subD.value, apikey.value, moduleKey.value)
const allNotes = await allNotesReq.json()
apiNotes.value = allNotes.data
Expand All @@ -81,10 +79,13 @@ onMounted(async () => {
}
})

const addNote = async (): Promise<void> => {
const addNote = async (e: KeyboardEvent): Promise<void> => {
e.preventDefault()
if (e.key === 'ENTER' && e.ctrlKey)
console.log(e)

const VClipboard = useClipboard()
VClipboard.copy(newNote.value)
console.log(VClipboard.text)
form.value?.reset()
const today = new Date()
const formattedToday = today.toISOString().split('T')[0]
Expand All @@ -95,32 +96,39 @@ const addNote = async (): Promise<void> => {
generated: '1',
code: '1',
},
budget: { currency: 'EGP' },
title: `Note no. ${noteNun}`,
start_date: formattedToday,
description: `${newNote.value}|path:${thisPath}`,
staff_id: '0',

}
// console.log('USER', document.querySelector('#main-content > div > div.header.clearfix > div > div > div.col-md-4.col-sm-4.col-xs-5 > div > ul > li.dropdown'))
const msgSound: any = new Audio(newNoteSound)
msgSound.play()
loadingNotes.value = true
const secrets: any = { userSub: subD.value, noteModuleKey: moduleKey.value, apikey: apikey.value }
const sendNote = await CreateNote(secrets, data)
const sendNoteRes = await sendNote.json()
console.log(sendNoteRes)
// console.log(JSON.stringify(data))
if (!sendNote.ok) {
renderError.value = 'Adding Note Failed!'
setTimeout(() => {
renderError.value = null
}, 10000)
newNote.value = VClipboard.text
console.log(VClipboard.text)
try {
const sendNote = await CreateNote(secrets, data)
const sendNoteRes = await sendNote.json()
// console.log(sendNote, sendNoteRes)
// console.log(JSON.stringify(data))
if (!sendNote.ok) {
console.log(sendNote)
renderError.value = 'Adding Note Failed!'
setTimeout(() => {
newNote.value = VClipboard.text
renderError.value = null
}, 3000)
}
}
catch (err) { console.log('err', err === 'SyntaxError' ? 'yes' : 'no') }
const allNotesReq = await GetNotes(subD.value, apikey.value, moduleKey.value)
const allNotes = await allNotesReq.json()
console.log(allNotes)
apiNotes.value = allNotes.data
loadingNotes.value = false
newNote.value = ''
}

const keys = useMagicKeys()
Expand All @@ -129,9 +137,6 @@ whenever(keys.escape, () => {
})
whenever(keys['\\'], () => {
drawer.value = true
console.log('before', newNote.value)
newNote.value = 'Hello....'
console.log('after', newNote.value)
// noteTextarea.value?.focus()
newNote.value = ''
})
Expand Down Expand Up @@ -184,7 +189,7 @@ whenever(keys['\\'], () => {
<v-window-item
value="page-notes"
>
<v-container class="!bg-slate-100 !bg-opacity-2 text-center ">
<v-container class="!bg-slate-100 !bg-opacity-2 text-center h-[575px] overflow-scroll">
<v-progress-circular v-show="loadingNotes" color="green" indeterminate />
<p v-show="renderError !== null" class="w-full text-center text-red-500 font-semibold">
{{ renderError }}
Expand Down Expand Up @@ -262,6 +267,27 @@ whenever(keys['\\'], () => {
</template>

<style>
::-webkit-scrollbar {
width: .4em;
}

::-webkit-scrollbar-track {
background: rgba(0,0,0,.09)
}

::-webkit-scrollbar-thumb {
background-color:#21a6a7;
border-radius: 15px;
}
::-webkit-scrollbar-button {
background: rgba(0,0,0,.09)
}
::-webkit-scrollbar-corner {
background: rgba(0,0,0,.09)
}
.v-card{
@apply min-h-[150px]
}
.v-navigation-drawer__scrim{
position: fixed
}
Expand Down
1 change: 1 addition & 0 deletions src/logic/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface NoteDataApi {
start_date: string
description: string
staff_id: string
budget: { currency: string }
}

export interface Number {
Expand Down
14 changes: 8 additions & 6 deletions src/options/Options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { GetUser } from '~/logic/dbSDK'
import { extractBody, extractPath, extractTags, getUserData } from '~/logic/utils'

const page = ref<Number>(1)
const notesPerPage = ref<Number>(3)
const notesPerPage = ref<Number>(9)
const notesLen = ref<Number>(0)

const apiNotes = ref<any>([])
Expand All @@ -27,9 +27,10 @@ const selectedColors = ref<String[]>([])
const allPeriods = ref<String[]>(['Last Hour', 'Yesterday', 'Last 5 days', 'Last Week', 'Last 30 days'])
const allRoutes = ref<String[]>(['/work-order', '/dashboard', '/invoices', '/invoices/23'])
const selectedRoutes = ref<String[]>([])
const apikey = ref<string>('')
const subD = ref<string>('')
const moduleKey = ref<string>('')
const apikey = ref<String>('')
const subD = ref<String>('')
const moduleKey = ref<String>('')
const userData = ref<any>(null)

const dateFrom = ref()
const dateTo = ref()
Expand Down Expand Up @@ -97,8 +98,9 @@ onMounted(async () => {
// console.log('authed', userE.value.userEmail)
const user: User = await GetUser('email', userE.value.userEmail)
console.log(user.documents[0])
userData.value = user.documents[0]
moduleKey.value = user.documents[0].dnote_module_key
apikey.value = user.documents[0].api_key
apikey.value = user.documents[0].apikey
subD.value = user.documents[0].subdomain
businessNameKnown.value = user.documents[0].subdomain || null
// console.log(apikey.value, moduleKey.value)
Expand Down Expand Up @@ -137,7 +139,7 @@ onMounted(async () => {
<main class="px-4 py-10 text-center text-gray-700 dark:text-gray-200">
<span v-if="businessNameKnown" class="bg-sky-400 bg-opacity-5 px-3 py-1 w-fit rounded inline-block ">
<p class="text-transparent bg-clip-text bg-gradient-to-r to-emerald-600 from-sky-400 text-lg font-bold md:text-xl lg:text-2xl dark:text-white">
Welcome {{ businessNameKnown }}!
Welcome {{ `${userData?.first_name} ${userData?.last_name}` }}!
</p>
</span>
<h1 class="text-transparent bg-clip-text bg-gradient-to-r to-emerald-600 from-sky-400 mb-4 text-4xl font-extrabold md:text-5xl lg:text-6xl dark:text-white">
Expand Down
2 changes: 1 addition & 1 deletion src/popup/Popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const openOptionsPage = () => {
</span>
</div>
<p class="btn transition duration-300 text-transparent bg-clip-text bg-gradient-to-r from-emerald-200 to-sky-700">
Stay organized
Stay Noted
</p>
<h1 class="text-transparent bg-clip-text bg-gradient-to-r to-emerald-600 from-sky-400 mb-4 text-4xl font-extrabold md:text-5xl lg:text-6xl dark:text-white">
D-Notes
Expand Down

0 comments on commit 9edfd74

Please sign in to comment.