Skip to content

Commit

Permalink
new ARC fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasLukasczyk committed Jul 11, 2024
1 parent f17eb22 commit fd2b750
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
3 changes: 2 additions & 1 deletion packages/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const newLocalArc = async ()=>{
return;
AppProperties.state=AppProperties.STATES.HOME;
await ArcControlService.new_arc(path);
await ArcControlService.newARC(path);
await openLocalArc(path);
};
const showHomeView = ()=>{
Expand Down
29 changes: 12 additions & 17 deletions packages/renderer/src/ArcControlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ArcControlService = {
readARC: async (arc_root: string | void | null) =>{
arc_root = arc_root || ArcControlService.props.arc_root;
if(!arc_root)
return;
return false;

const isARC = await window.ipc.invoke('LocalFileSystemService.exists', arc_root+'/isa.investigation.xlsx');

Expand All @@ -74,26 +74,26 @@ const ArcControlService = {
return true;
},

handleARCContracts: async (contracts: Contract []) => {
let arc = ArcControlService.props.arc;
let arc_root = ArcControlService.props.arc_root;
handleARCContracts: async (contracts: Contract [], arc: ARC, arc_root: string) => {
arc = arc || ArcControlService.props.arc;
arc_root = arc_root || ArcControlService.props.arc_root;
if(!arc || !arc_root)
return;
ArcControlService.props.busy = true;
arc.UpdateFileSystem();
for(const contract of contracts) {
// console.log(contract);
console.log('CONTRACT',contract);
switch (contract.Operation) {
case 'DELETE':
await window.ipc.invoke(
'LocalFileSystemService.remove',
relative_to_absolute_path(contract.Path)
arc_root + '/' +contract.Path
);
break;
case 'UPDATE': case 'CREATE':
if(['ISA_Investigation','ISA_Study','ISA_Assay'].includes(contract.DTOType)){
const buffer = await Xlsx.toBytes(contract.DTO);
const absolutePath = relative_to_absolute_path(contract.Path)
const absolutePath = arc_root + '/' +contract.Path;
await window.ipc.invoke(
'LocalFileSystemService.writeFile',
[
Expand All @@ -117,8 +117,8 @@ const ArcControlService = {
await window.ipc.invoke(
'LocalFileSystemService.rename',
[
relative_to_absolute_path(contract.Path),
relative_to_absolute_path(contract.DTO)
arc_root + '/' + contract.Path,
arc_root + '/' + contract.DTO
]
);
break;
Expand All @@ -135,13 +135,9 @@ const ArcControlService = {
force?:boolean
})=>{
const arc = options.arc || ArcControlService.props.arc;
if(!ArcControlService.props.arc)
ArcControlService.props.arc = arc;
if(!arc)
return;
const arc_root = options.arc_root || ArcControlService.props.arc_root;
if(!ArcControlService.props.arc_root)
ArcControlService.props.arc_root = options.arc_root;
if(!arc_root)
return;

Expand All @@ -153,12 +149,12 @@ const ArcControlService = {
/// Add default .gitignore if it does not exist
const ignore_exists = await window.ipc.invoke(
'LocalFileSystemService.exists',
relative_to_absolute_path('/.gitignore')
arc_root + '/.gitignore'
);
if(!ignore_exists)
contracts.push(gitignoreContract);

await ArcControlService.handleARCContracts(contracts);
await ArcControlService.handleARCContracts(contracts, arc, arc_root);

ArcControlService.props.busy = false;
},
Expand All @@ -181,7 +177,7 @@ const ArcControlService = {
await ArcControlService.handleARCContracts(contracts);
},

new_arc: async (path: string) =>{
newARC: async (path: string) =>{
const arc = new ARC(
ArcInvestigation.init(path.split('/').pop())
);
Expand All @@ -191,7 +187,6 @@ const ArcControlService = {
force: true
});
await ArcControlService.readARC(path);

await window.ipc.invoke('GitService.run', {
args: ['init','-b','main'],
cwd: path
Expand Down

0 comments on commit fd2b750

Please sign in to comment.