Skip to content

Commit

Permalink
refactoring / dependency updates / artefact links
Browse files Browse the repository at this point in the history
  • Loading branch information
con-cis committed Oct 15, 2023
1 parent af2be43 commit c0c9e40
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 34 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [Recommended IDE Setup](#recommended-ide-setup)
- [Procject structure](#procject-structure)
- [Build](#build)
- [Automatic generated builds](#automatic-generated-builds)
- [License](#license)
- [Disclaimer](#disclaimer)

Expand Down Expand Up @@ -135,6 +136,9 @@ $ npm run build:mac
$ npm run build:linux
```

### Automatic generated builds

Links to automated generated builds for [mac os, windows and linux](https://github.com/con-cis/mc-docu/actions/runs/6487526125) from the CI action workflow
## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@electron-toolkit/preload": "^2.0.0",
"@electron-toolkit/utils": "^2.0.1",
"electron-updater": "^6.1.4",
"vuetify": "^3.3.20",
"vuetify": "^3.3.21",
"xml2js": "^0.6.2"
},
"devDependencies": {
Expand All @@ -52,7 +52,7 @@
"typescript": "^5.2.2",
"vite": "^4.4.11",
"vue": "^3.3.4",
"vue-tsc": "^1.8.18"
"vue-tsc": "^1.8.19"
},
"license": "MIT",
"keywords": [
Expand Down
4 changes: 3 additions & 1 deletion src/enums/ApiResponses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export enum ApiResponses {
enum ApiResponses {
OPERATION_CANCELLED = 'Operation cancelled',
RESOLVED_SUCCESSFULLY = 'Resolved successfully',
ERROR_RESOLVING_CONFIG = 'Error while resolving config file'
}

export default ApiResponses
23 changes: 14 additions & 9 deletions src/main/modules/fileHandling/FileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { processJsonFile } from '../jsonProcessing/JsonProcessingService'
import { processXmlFile } from '../xmlProcessing/XmlProcessingService'
import { openFileDialog, saveFileDialog } from './FileDialogService'
import { BrowserWindow, ipcMain } from 'electron'
import ApiResponses from '../../../enums/ApiResponses'

async function readFileAndProcess(filePath: string) {
try {
Expand All @@ -23,19 +24,22 @@ async function readFileAndProcess(filePath: string) {
}

function getFileType(content: string) {
let format: string
if (isJSON(content)) {
return 'JSON'
format = 'JSON'
} else if (isXML(content)) {
return 'XML'
format = 'XML'
} else {
return 'unknown format'
format = 'unknown format'
}
return format
}

export async function openFile() {
try {
const result = await openFileDialog()
const mainWindow = BrowserWindow.getFocusedWindow()
let status: string

if (!result.canceled) {
const filePath = result.filePaths[0]
Expand All @@ -45,14 +49,15 @@ export async function openFile() {
metadata: processedResult.metadata
}
mainWindow?.webContents.send('get-config', dataObject)
return 'Resolved successfully'
status = ApiResponses.RESOLVED_SUCCESSFULLY
} else {
mainWindow?.webContents.send('get-config', null)
return 'Operation cancelled'
status = ApiResponses.OPERATION_CANCELLED
}
return status
} catch (error) {
console.error('Error:', error)
return 'Error while resolving config file'
return ApiResponses.ERROR_RESOLVING_CONFIG
}
}

Expand All @@ -65,13 +70,13 @@ export async function saveFile(data: string) {
const filePath = result.filePath
await fs.writeFile(filePath, data)
console.info('Successfully saved')
return 'Resolved successfully'
return ApiResponses.RESOLVED_SUCCESSFULLY
} else {
return 'Operation cancelled'
return ApiResponses.OPERATION_CANCELLED
}
} catch (error) {
console.error('Error:', error)
return 'Error while resolving config file'
return ApiResponses.ERROR_RESOLVING_CONFIG
}
}

Expand Down
33 changes: 20 additions & 13 deletions src/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DataTable from './components/DataTable.vue';
import { checkboxOptionsData } from './data/checkboxOptionsData';
import { ConfigData } from 'src/types/ConfigData';
import { ChannelData } from 'src/models';
import { ApiResponses } from '../../enums/ApiResponses';
import ApiResponses from '../../enums/ApiResponses';
import '@mdi/font/css/materialdesignicons.css';
const search = ref('');
Expand All @@ -17,9 +17,16 @@ const timeout = ref(5000);
const hasErrors = ref(false);
const wasSuccessful = ref(false);
const DEFAULT_COLUMNS = [
"id",
"connectorName",
"transportName",
"inboundDataType",
"outboundDataType",
"enabled"
];
const filterColumns = ref<string[]>(["id", "connectorName", "transportName", "inboundDataType", "outboundDataType",
"enabled"]);
const filterColumns = ref<string[]>(DEFAULT_COLUMNS);
const handleFilterColumnChange = (key: string) => {
if (!filterColumns.value.includes(key)) {
Expand All @@ -29,14 +36,6 @@ const handleFilterColumnChange = (key: string) => {
}
}
const handleSelectAll = () => {
filterColumns.value = checkboxOptionsData.map(option => option.key);
}
const handleSelectNone = () => {
filterColumns.value = [];
}
const handleExportFile = async () => {
try {
const response = await window.api.onSaveFileDialog(JSON.stringify(configData.value));
Expand All @@ -59,6 +58,14 @@ const handleExportFile = async () => {
}
};
const handleSelectAll = () => {
filterColumns.value = checkboxOptionsData.map(option => option.key);
}
const handleSelectNone = () => {
filterColumns.value = [];
}
</script>

<template>
Expand Down Expand Up @@ -89,8 +96,8 @@ const handleExportFile = async () => {

<v-app-bar>
<v-app-bar-nav-icon @click="drawer = !drawer"></v-app-bar-nav-icon>
<v-app-bar-title v-if="configData === null">
<v-card :title="'Mirth Connect Channel Overview'"></v-card>
<v-app-bar-title v-if="configData === null">
<v-card :title="'Mirth Connect Channel Overview'"></v-card>
</v-app-bar-title>
<v-app-bar-title v-else>
<v-card :title="'Mirth Connect Channel Overview'"
Expand Down
13 changes: 4 additions & 9 deletions src/renderer/src/components/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { VDataTable } from 'vuetify/labs/VDataTable';
import { ChannelData } from '../../../models';
import { ConfigData } from '../../../types/ConfigData';
import { headerData } from '../data/headerData';
import { ApiResponses } from '../../../enums/ApiResponses';
import ApiResponses from '../../../enums/ApiResponses';
const channels = ref<ChannelData | any>(null);
const isLoading = ref(false);
Expand Down Expand Up @@ -40,11 +40,9 @@ function fetchConfig() {
}
const filteredHeaders = computed(() => {
const preservedHeaderKeys = ["annotation", "data-table-expand", "name"];
return headers.value.filter((item: any) => {
return props.columnFilter!.includes(item.key) ||
item.key === "annotation" ||
item.key === "data-table-expand" ||
item.key === "name";
return props.columnFilter!.includes(item.key) || preservedHeaderKeys.includes(item.key);
});
});
Expand All @@ -59,20 +57,17 @@ const openFileDialog = async () => {
const response = await window.api.onOpenFileDialog();
switch (response) {
case ApiResponses.RESOLVED_SUCCESSFULLY:
isLoading.value = false;
break;
case ApiResponses.ERROR_RESOLVING_CONFIG:
isLoading.value = false;
hasErrors.value = true;
break;
case ApiResponses.OPERATION_CANCELLED:
isLoading.value, hasErrors.value = false;
break;
default:
isLoading.value = false;
hasErrors.value = true;
break;
}
isLoading.value = false;
};
// Not implemented yet
Expand Down

0 comments on commit c0c9e40

Please sign in to comment.