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 parking section #34

Merged
merged 13 commits into from
Oct 18, 2024
60 changes: 43 additions & 17 deletions package-lock.json

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

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nethlink",
"version": "0.3.1",
"version": "0.3.2-0",
"description": "NethLink app",
"main": "./out/main/main.js",
"license": "UNLICENSED",
Expand All @@ -24,9 +24,11 @@
"publish:minor": "npm version minor --allow-same-version -m v%s --force",
"publish:major": "npm version major --allow-same-version -m v%s --force",
"publish:patch": "npm version patch --allow-same-version -m v%s --force",
"publish:build": "npm version prepatch --allow-same-version -m v%s --force",
"publish:git": "npm version from-git --allow-same-version -m v%s --force",
"postversion": "git add . && git push --follow-tags && git push --tags",
"build": "rm -rf out && rm -rf dist && npm run typecheck && electron-vite build",
"build:w": "del /s /q out && del /s /q dist && npm run typecheck && electron-vite build",
"build": "rm -rf out && rm -rf dist && npm run typecheck && npm run publish:build && electron-vite build",
"build:w": "del /s /q out && del /s /q dist && npm run typecheck && npm run publish:build && electron-vite build",
"postinstall": "electron-builder install-app-deps",
"build:unpack": "npm run build && electron-builder --dir",
"build:win": "npm run build:w && electron-builder --win",
Expand Down Expand Up @@ -67,6 +69,7 @@
"electron-vite": "^2.0.0",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.33.2",
"framer-motion": "^11.11.8",
"i18next": "^22.4.9",
"i18next-browser-languagedetector": "^7.0.1",
"i18next-electron-fs-backend": "^3.0.1",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@
"Pick up": "Pick up",
"Parking": "Parking",
"Hold": "Hold",
"No parked call": "No parked calls found",
"Click and hold to take current parking in call": "Click and hold to take current parking in call"
},
"Devices": {
Expand Down
1 change: 1 addition & 0 deletions public/locales/it/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@
"Pick up": "Riprendi",
"Parking": "Parcheggio",
"Hold": "Tieni premuto",
"No parked call": "Nessuna chimata parcheggiata trovata",
edospadoni marked this conversation as resolved.
Show resolved Hide resolved
"Click and hold to take current parking in call": "Clicca e tieni premuto per riprendere la chiamata parcheggiata"
},
"Devices": {
Expand Down
86 changes: 52 additions & 34 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,49 +209,58 @@ function attachOnReadyProcess() {

async function startApp(attempt = 0) {
const data = store.getFromDisk()
store.updateStore(data, 'startApp')
log('START APP, retry:', attempt)
if (!store.store.connection) {
log('NO CONNECTION', attempt, store.store)
if (attempt >= 3)
SplashScreenController.instance.window.emit(IPC_EVENTS.SHOW_NO_CONNECTION)
retryAppStart = setTimeout(() => {
startApp(++attempt)
}, 1000)
} else {
if (retryAppStart) {
clearTimeout(retryAppStart)
}
const auth: AuthAppData | undefined = store.store['auth']
await getPermissions()
if (auth?.isFirstStart !== undefined && !auth?.isFirstStart) {
const isLastUserLogged = await AccountController.instance.autoLogin()
if (isLastUserLogged) {
ipcMain.emit(IPC_EVENTS.LOGIN, undefined, { showNethlink: true })
if (checkData(data)) {
store.updateStore(data, 'startApp')
log('START APP, retry:', attempt)
if (!store.store.connection) {
log('NO CONNECTION', attempt, store.store)
if (attempt >= 3)
SplashScreenController.instance.window.emit(IPC_EVENTS.SHOW_NO_CONNECTION)
retryAppStart = setTimeout(() => {
startApp(++attempt)
}, 1000)
} else {
if (retryAppStart) {
clearTimeout(retryAppStart)
}
const auth: AuthAppData | undefined = store.store['auth']
await getPermissions()
if (auth?.isFirstStart !== undefined && !auth?.isFirstStart) {
const isLastUserLogged = await AccountController.instance.autoLogin()
if (isLastUserLogged) {
ipcMain.emit(IPC_EVENTS.LOGIN, undefined, { showNethlink: true })
} else {
store.updateStore({
auth: {
...store.store['auth']!,
lastUser: undefined,
lastUserCryptPsw: undefined
},
account: undefined,
theme: 'system',
connection: store.store['connection'] || false,
}, 'showLogin')
showLogin()
}
} else {
store.updateStore({
auth: {
...store.store['auth']!,
lastUser: undefined,
lastUserCryptPsw: undefined
},
account: undefined,
theme: 'system',
connection: store.store['connection'] || false,
}, 'showLogin')
await resetApp()
showLogin()
}
} else {
await resetApp()
showLogin()
SplashScreenController.instance.window.quit(true)
//once the loading is complete I enable the ability to click on the icon in the tray
TrayController.instance.updateTray({
enableShowButton: true
})
}
} else {
await resetApp()
showLogin()
SplashScreenController.instance.window.quit(true)
//once the loading is complete I enable the ability to click on the icon in the tray
TrayController.instance.updateTray({
enableShowButton: true
})
}

}

app.on('window-all-closed', () => {
Expand Down Expand Up @@ -417,7 +426,7 @@ function attachThemeChangeListener() {
store.set('theme', updatedSystemTheme)
}
//update theme state on the store
TrayController.instance.changeIconByTheme(updatedSystemTheme)
TrayController.instance?.changeIconByTheme(updatedSystemTheme)
})
}
/**
Expand Down Expand Up @@ -485,5 +494,14 @@ async function checkForUpdate() {
}
}

function checkData(data: any): boolean {
log({ data })
return data.hasOwnProperty('account') &&
data.hasOwnProperty('auth') &&
data.hasOwnProperty('theme') &&
data.hasOwnProperty('connection')
}

//BEGIN APP
startup()

1 change: 1 addition & 0 deletions src/renderer/public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@
"Pick up": "Pick up",
"Parking": "Parking",
"Hold": "Hold",
"No parked call": "No parked calls found",
"Click and hold to take current parking in call": "Click and hold to take current parking in call"
},
"Devices": {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/public/locales/it/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@
"Pick up": "Riprendi",
"Parking": "Parcheggio",
"Hold": "Tieni premuto",
"No parked call": "Nessuna chimata parcheggiata trovata",
edospadoni marked this conversation as resolved.
Show resolved Hide resolved
"Click and hold to take current parking in call": "Clicca e tieni premuto per riprendere la chiamata parcheggiata"
},
"Devices": {
Expand Down
19 changes: 19 additions & 0 deletions src/renderer/src/components/EmptyList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IconProp } from "@fortawesome/fontawesome-svg-core"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"


export interface EmptyListProps {
icon: IconProp,
text: string
}
export const EmptyList = ({ icon, text }: EmptyListProps) => {

return (
<div className="flex flex-col justify-between items-center gap-5 py-[28px] bg-hoverLight dark:bg-hoverDark min-h-[132px] mt-4 rounded-lg ml-5 mr-3">
<div className="text-emptyIconLight dark:text-emptyIconDark">
<FontAwesomeIcon icon={icon} className="text-[28px] " />
</div>
<span className="text-center text-emptyTextLight dark:text-emptyTextDark text-sm">{text}</span>
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,36 @@ export function LastCall({
const handleCreateContact = () => {
handleSelectedCallContact(
(call.direction === 'in' ? call.src : call.dst) || '',
call.direction === 'out'
? call?.dst_cnam || call?.dst_ccompany
: call.direction === 'in'
? call?.cnam || call?.ccompany
call.direction === 'in'
? call?.cnam || call?.ccompany
: call.direction === 'out'
? call?.dst_cnam || call?.dst_ccompany
: undefined
)
showContactForm()
}

const getCallName = (call: LastCallData) => {
return `${call.direction === 'in'
? (call.cnam || call.ccompany || t('Common.Unknown'))
: call.direction === 'out'
? (call.dst_cnam || call.dst_ccompany || t('Common.Unknown'))
: t('Common.Unknown')
}`
}

return (
<div className="group">
<div
className={`flex flex-grow gap-3 min-h-[72px] p-2 ${className}`}
onMouseEnter={() => {
if (call.username === t('Common.Unknown')) {
if (
call.direction === 'in'
? !(call.src || call.ccompany)
: call.direction === 'out'
? !(call.dst_cnam || call.dst_ccompany)
: false
) {
setShowCreateButton(() => true)
}
}}
Expand Down Expand Up @@ -130,9 +145,9 @@ export function LastCall({
</div>
<div className="flex flex-col gap-1 dark:text-titleDark text-titleLight">
<p className={`tooltip-username-${call?.username} font-medium text-[14px] leading-5`}>
{truncate(call.username, 13)}
{truncate(getCallName(call), 13)}
</p>
<Tooltip anchorSelect={`.tooltip-username-${call?.username}`}>{call.username}</Tooltip>
<Tooltip anchorSelect={`.tooltip-username-${call?.username}`}>{getCallName(call)}</Tooltip>
<div className="flex flex-row gap-2 items-center">
<div className={`h-4 w-4 call_${call.uniqueid?.replace('.', '_')}`}>
{call.disposition === 'NO ANSWER' ? (
Expand Down
Loading
Loading