Skip to content

Commit

Permalink
start fixing journey 🚧
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Jun 26, 2024
1 parent 68c952a commit fea4ade
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
48 changes: 33 additions & 15 deletions packages/renderer/src/ArcControlService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const Runs = 'runs';
export const Workflows = 'workflows';

let init: {
arc_root: null | string ,
arc_root: undefined | string ,
busy: boolean,
arc: null | ARC
} = {
arc_root: null ,
arc_root: undefined ,
busy: false,
arc: null
}
Expand All @@ -38,7 +38,7 @@ const ArcControlService = {
props: reactive(init),

closeARC: async() => {
ArcControlService.props.arc_root = null;
ArcControlService.props.arc_root = undefined;
ArcControlService.props.busy = false;
ArcControlService.props.arc = null;
AppProperties.active_assay = null;
Expand Down Expand Up @@ -77,48 +77,60 @@ const ArcControlService = {
},

handleARCContracts: async (contracts: Contract []) => {
console.log("!HandleContracts!")
console.log(contracts.length)
let arc = ArcControlService.props.arc;
let arc_root = ArcControlService.props.arc_root;
if(!arc || !arc_root)
return;

console.log("HandleContracts")
ArcControlService.props.busy = true;
arc.UpdateFileSystem();
for(const contract of contracts) {
console.log(contract.Path)
switch (contract.Operation) {
case 'DELETE':
return await window.ipc.invoke(
await window.ipc.invoke(
'LocalFileSystemService.remove',
relative_to_absolute_path(contract.Path)
);
case 'UPDATE': case 'WRITE':
break;
case 'UPDATE': case 'CREATE':
console.log("UPDATE/CREATE")
if(['ISA_Investigation','ISA_Study','ISA_Assay'].includes(contract.DTOType)){
const buffer = await Xlsx.toBytes(contract.DTO);
return await window.ipc.invoke(
const absolutePath = relative_to_absolute_path(contract.Path)
console.log("path", contract.Path)
console.log("abs-path", absolutePath)
await window.ipc.invoke(
'LocalFileSystemService.writeFile',
[
relative_to_absolute_path(contract.Path),
absolutePath,
buffer,
{}
]
);
break;
} else if(contract.DTOType==='PlainText'){
return await window.ipc.invoke('LocalFileSystemService.writeFile', [
console.log("PLAINTEXT")
await window.ipc.invoke('LocalFileSystemService.writeFile', [
arc_root+'/'+contract.Path,
contract.DTO || '',
{encoding:'UTF-8', flag: 'wx'}
]);
} else {
return console.log('unable to resolve write contract', contract);
}
break;
case 'RENAME':
return await window.ipc.invoke(
await window.ipc.invoke(
'LocalFileSystemService.rename',
[
relative_to_absolute_path(contract.Path),
relative_to_absolute_path(contract.DTO)
]
);
break;
default:
console.log(`Warning. 'handleARCContracts' hit unknown expression for contract type: ${contract.Operation} in ${contract}.`)
break;
Expand All @@ -127,21 +139,27 @@ const ArcControlService = {
},

saveARC: async (options:{
arc_root: string | null,
arc: ARC | void,
force:boolean
arc_root?: string,
arc?: ARC,
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;

ArcControlService.props.busy = true;

arc.UpdateFileSystem();
let contracts = options.force ? arc.GetWriteContracts() : arc.GetUpdateContracts();
console.log("Save ARC")
console.log(contracts)

/// Add default .gitignore if it does not exist
const ignore_exists = await window.ipc.invoke(
Expand Down Expand Up @@ -188,7 +206,7 @@ const ArcControlService = {
ArcInvestigation.init(path.split('/').pop())
);
await ArcControlService.saveARC({
path:path,
arc_root:path,
arc:arc,
force: true
});
Expand Down Expand Up @@ -219,7 +237,7 @@ const ArcControlService = {
const entry = path.replace(ArcControlService.props.arc_root,'');
const ignore_exists = await window.ipc.invoke('LocalFileSystemService.exists', ArcControlService.props.arc_root+'/.gitignore');
if(!ignore_exists)
await ArcControlService.writeARC();
await ArcControlService.saveARC({});

const ignore_string = await window.ipc.invoke('LocalFileSystemService.readFile', ArcControlService.props.arc_root+'/.gitignore');
const line_delimiter = ignore_string.indexOf('\r\n')<0 ? '\n' : '\r\n';
Expand Down
5 changes: 3 additions & 2 deletions packages/renderer/src/views/ArcTreeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const addStudy_ = async (identifier: string, skip_io: boolean | void)=>{
const study = new ArcStudy(identifier,identifier);
ArcControlService.props.arc.ISA.AddRegisteredStudy(study)
if(!skip_io){
await ArcControlService.writeARC();
await ArcControlService.saveARC({});
await ArcControlService.readARC();
AppProperties.active_study = identifier;
}
Expand All @@ -122,6 +122,7 @@ const addAssay = async ()=>{
$q.dialog({
component: NewAssayDialog
}).onOk( async (data: NewAssayInformation) => {
console.log("Add assay")
const assay = new ArcAssay(data.assayIdentifier);
ArcControlService.props.arc.ISA.AddAssay(assay);
Expand All @@ -137,7 +138,7 @@ const addAssay = async ()=>{
}
};
await ArcControlService.writeARC(ArcControlService.props.arc_root, undefined, undefined);
await ArcControlService.saveARC({arc_root: ArcControlService.props.arc_root});
await ArcControlService.readARC();
AppProperties.active_assay = data.assayIdentifier;
});
Expand Down

0 comments on commit fea4ade

Please sign in to comment.