Skip to content

Commit

Permalink
Merge pull request #163 from educorvi/develop
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
neferin12 authored Sep 5, 2024
2 parents f3b9e6b + 247bf9e commit de51cf0
Show file tree
Hide file tree
Showing 16 changed files with 330 additions and 253 deletions.
2 changes: 2 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ dev-dist
*.njsproj
*.sln
*.sw?

src/**/*.js
1 change: 1 addition & 0 deletions client/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ declare module 'vue' {
BNavbarNav: typeof import('bootstrap-vue-next')['BNavbarNav']
BNavbarToggle: typeof import('bootstrap-vue-next')['BNavbarToggle']
BNavItemDropdown: typeof import('bootstrap-vue-next')['BNavItemDropdown']
BPopover: typeof import('bootstrap-vue-next')['BPopover']
BRow: typeof import('bootstrap-vue-next')['BRow']
BSpinner: typeof import('bootstrap-vue-next')['BSpinner']
BTab: typeof import('bootstrap-vue-next')['BTab']
Expand Down
14 changes: 7 additions & 7 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
"generateIcons": "yarn dlx vue-pwa-asset-generator --no-manifest -a src/assets/appIcon.png -o public/icons -b \"#FFFFFF\""
},
"dependencies": {
"@educorvi/vue-json-form": "3.0.0-alpha.5",
"@educorvi/vue-json-form": "3.0.0-alpha.6",
"@tsconfig/node-lts": "^18.12.5",
"axios": "^1.7.5",
"axios": "^1.7.7",
"bootstrap": "^5.3.3",
"bootstrap-vue-next": "^0.24.7",
"bootstrap-vue-next": "^0.24.11",
"bootswatch": "^4.6.2",
"file-saver": "^2.0.5",
"humanize-duration": "^3.32.1",
"keycloak-js": "^20.0.5",
"pinia": "^2.1.6",
"pinia": "^2.2.2",
"showdown": "^2.1.0",
"swagger-ui": "^5.17.14",
"swagger-ui-dist": "^5.17.14",
"timeclicker_server": "workspace:^",
"vue": "^3.4.27",
"vue-i18n": "^9.13.1",
"vue-router": "^4.3.2"
"vue": "^3.4.38",
"vue-i18n": "^9.14.0",
"vue-router": "^4.4.3"
},
"devDependencies": {
"@iconify-json/bi": "^1.1.23",
Expand Down
5 changes: 5 additions & 0 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ import { UiError, useErrorStore } from '@/stores/error';
import { useI18n } from 'vue-i18n';
import { useBreakpointStore } from '@/stores/breakpoints';
import axios from 'axios';
import { useToast } from 'bootstrap-vue-next';

const { t } = useI18n();

const kcStore = useKeycloakStore();
const errorStore = useErrorStore();
const bpStore = useBreakpointStore();

errorStore.show = useToast().show;
errorStore.t = t;

let keycloak: Keycloak;

(async () => {
Expand Down
9 changes: 0 additions & 9 deletions client/src/components/ActivityEntryEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,6 @@ function onSubmit(event: Event) {
})
.catch((error) => {
errorStore.setError(new UiError(t('errors.saving_failed'), error));
show?.( {
props: {
title: t('errors.saving_failed'),
variant: 'danger',
value: true,
pos: 'top-center'
}
})
});
}
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/ContractEntryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
hide-footer
no-close-on-backdrop
:title="t('edit_contract_data')"
@hidden="()=>{modalHidden = true}"
@show="()=>{modalHidden = false}"
>
<vue-json-form
v-if="!modalHidden"
class="w-100"
:jsonSchema="jsonSchema"
:uiSchema="uiSchema"
Expand Down Expand Up @@ -35,6 +38,8 @@ const { t } = useI18n();
const jsonSchema = getContractEntryJsonSchema(t);
const uiSchema = getContractEntryUiSchema(t);
const modalHidden = ref(false);
const props = defineProps<{
initialData?: saveContractDataParams;
cleanAfterSubmit?: boolean;
Expand Down
15 changes: 6 additions & 9 deletions client/src/components/HoursEntryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
></b-input>
</b-col>
</b-row>
<b-form-checkbox v-model="vacation">{{
<b-form-checkbox v-model="vacation" :disabled="!vacationAvailable">{{
t('vacation_day')
}}</b-form-checkbox>
<hr />
Expand Down Expand Up @@ -77,6 +77,11 @@ const props = defineProps<{
* Data to initialize the form with if an existing entry is edited
*/
initialData?: WorkingHours;
/**
* Are vacation days available
*/
vacationAvailable: boolean;
}>();
/**
Expand Down Expand Up @@ -130,14 +135,6 @@ function saveEntry(evt: Event) {
})
.catch((error) => {
errorStore.setError(new UiError(t('errors.saving_failed'), error));
show?.({
props: {
title: t('errors.saving_failed'),
variant: 'danger',
value: true,
pos: 'top-center',
},
});
});
}
</script>
Expand Down
23 changes: 13 additions & 10 deletions client/src/components/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
getDurationOrDash(
activity.from,
activity.to,
activity.breakMins * 60 * 1000
activity.breakMins * 60 * 1000,
)
}}
<span
Expand All @@ -62,7 +62,7 @@
(+{{
getHumanizedDuration(
activity.breakMins * 60 * 1000,
['m']
['m'],
)
}}
{{ t('break') }})
Expand All @@ -78,13 +78,13 @@
class="w-50"
variant="outline-secondary"
@click="editActivity(activity)"
>{{ t('edit') }}
>{{ t('edit') }}
</b-button>
<b-button
class="w-50"
variant="outline-danger"
@click="askToDeleteActivity(activity)"
>{{ t('delete') }}
>{{ t('delete') }}
</b-button>
</b-button-group>
</b-card-footer>
Expand All @@ -110,7 +110,7 @@
ok-variant="danger"
:cancel-title="t('cancel')"
centered
>{{ t('delete_prompt') }}
>{{ t('delete_prompt') }}
</b-modal>
</div>
<custom-spinner v-else />
Expand Down Expand Up @@ -158,13 +158,13 @@ const hours = computed(() => {
return (
prev + ((curr.to?.getTime() || 0) - (curr.from?.getTime() || 0))
);
}, 0) - (breaks.value || 0)
}, 0) - (breaks.value || 0),
);
});
function getHumanizedDuration(
duration: number,
units: humanizeDuration.Unit[] = ['h', 'm']
units: humanizeDuration.Unit[] = ['h', 'm'],
) {
return humanizeDuration(duration, {
language: locale.value,
Expand Down Expand Up @@ -223,10 +223,13 @@ function deleteActivity() {
axios
.delete(
import.meta.env.VITE_API_ENDPOINT +
'activities/' +
editableActivity.value.id
'activities/' +
editableActivity.value.id,
)
.then(loadActivities);
.then(loadActivities)
.catch((error) => {
errorStore.setError(new UiError(t('errors.deletion_failed'), error));
});
}
}
Expand Down
5 changes: 5 additions & 0 deletions client/src/i18n/messages/english.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@ export const en = {
manage_activities: 'Manage Activities',
manage_working_hours: 'Manage Working Hours',

manage_entries_for: 'Entries for',

show_note: 'Show note',
hide_note: 'Hide note',

errors: {
saving_failed: 'Failed to save!',
deletion_failed: 'Failed to delete!',
act_failed: 'Activities could not be loaded!',
tasks_failed: 'Tasks could not be loaded!',
hours_failed: 'Hours could not be loaded!',
time_balance_failed: 'Time balance could not be loaded!',
users_failed: 'Users could not be loaded!',
contract_data_failed: 'Contract data could not be loaded!',
token_refresh: 'Failed to refresh token. Please login again...',
Expand Down
4 changes: 4 additions & 0 deletions client/src/i18n/messages/german.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const de = {

manage_activities: 'Aktivitäten verwalten',
manage_working_hours: 'Arbeitszeiten verwalten',
manage_entries_for: 'Einträge für',

dashboard: 'Dashboard',

Expand All @@ -46,10 +47,13 @@ export const de = {

errors: {
saving_failed: 'Speichern fehlgeschlagen!',
deletion_failed: 'Löschen fehlgeschlagen!',
act_failed: 'Aktivitäten konnten nicht geladen werden!',
tasks_failed: 'Aufgaben konnten nicht geladen werden!',
users_failed: 'Nutzer konnten nicht geladen werden!',
contract_data_failed: 'Vertragsdaten konnten nicht geladen werden!',
hours_failed: 'Arbeitszeiten konnten nicht geladen werden!',
time_balance_failed: 'Zeitsaldo konnte nicht geladen werden!',
token_refresh:
'Anmeldetoken konnte nicht erneuert werden. Bitte melden Sie sich erneut an.',
auth_endpoint:
Expand Down
21 changes: 21 additions & 0 deletions client/src/stores/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { defineStore } from 'pinia';
import { useToast } from 'bootstrap-vue-next';
import { useI18n } from 'vue-i18n';

export class UiError {
readonly message: string;
Expand All @@ -13,15 +15,34 @@ export class UiError {
}
}
}

export const useErrorStore = defineStore('error', {
state: () => {
return {
errors: [] as UiError[],
show: undefined as ReturnType<typeof useToast>['show'],
t: undefined as ReturnType<typeof useI18n>['t'] | undefined
};
},
actions: {
setError(uiError: UiError) {
this.errors.push(uiError);
if (!this.show) {
console.log('No toast service available');
}
this.show?.({
props: {
title: this.t?.('error') || 'Error',
body: uiError.message,
variant: 'danger',
pos: 'top-center',
value: 10000,
interval: 100,
progressProps: {
variant: 'warning',
},
},
});
},
removeError(e: UiError) {
this.errors = this.errors.filter((i) => i != e);
Expand Down
Loading

0 comments on commit de51cf0

Please sign in to comment.