Delete ScriptAccounts from Filesystem
All checks were successful
E2E Testing / test (push) Successful in 1m36s
All checks were successful
E2E Testing / test (push) Successful in 1m36s
This commit is contained in:
parent
03bc18e679
commit
c4085a7cf9
14
app/DeleteModel.js
Normal file
14
app/DeleteModel.js
Normal file
@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DeleteTransaction = void 0;
|
||||
const path = require("node:path");
|
||||
const fs = require("fs");
|
||||
class DeleteTransaction {
|
||||
static deleteScriptAccount(projectDir, componentName) {
|
||||
const filename = path.join(projectDir, "script-accounts", componentName + ".json");
|
||||
fs.unlinkSync(filename);
|
||||
console.log("Delete ", filename);
|
||||
}
|
||||
}
|
||||
exports.DeleteTransaction = DeleteTransaction;
|
||||
//# sourceMappingURL=DeleteModel.js.map
|
10
app/DeleteModel.ts
Normal file
10
app/DeleteModel.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import * as path from "node:path";
|
||||
import * as fs from "fs";
|
||||
|
||||
export class DeleteTransaction {
|
||||
static deleteScriptAccount(projectDir: string, componentName: string) {
|
||||
const filename = path.join(projectDir, "script-accounts", componentName + ".json")
|
||||
fs.unlinkSync(filename)
|
||||
console.log("Delete ", filename)
|
||||
}
|
||||
}
|
18
app/main.ts
18
app/main.ts
@ -1,9 +1,11 @@
|
||||
import {app, BrowserWindow, screen, Menu, ipcMain, dialog, globalShortcut} from 'electron';
|
||||
import {app, BrowserWindow, dialog, globalShortcut, ipcMain, Menu, screen} from 'electron';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import {json} from "node:stream/consumers";
|
||||
import {StorageModel} from "../src/app/game-model/fs/StorageModel";
|
||||
import {SaveProject} from "./SaveProject";
|
||||
import {DeleteModel} from "../src/app/game-model/fs/DeleteModel";
|
||||
import {ModelComponentType} from "../src/app/game-model/ModelComponentType";
|
||||
import {DeleteTransaction} from "./DeleteModel";
|
||||
|
||||
let win: BrowserWindow | null = null;
|
||||
const args = process.argv.slice(1),
|
||||
@ -99,6 +101,11 @@ function createWindow(): BrowserWindow {
|
||||
SaveProject.saveProject(projectDirectory, storageModels);
|
||||
})
|
||||
|
||||
ipcMain.on('delete-component', (event, deletedComponent: DeleteModel) => {
|
||||
console.log("Delete Model: ", deletedComponent)
|
||||
deleteComponent(deletedComponent);
|
||||
})
|
||||
|
||||
const menuTemplate = [
|
||||
{
|
||||
label: 'File',
|
||||
@ -207,3 +214,10 @@ function openProjectFromFile(openProjectDir: string) {
|
||||
function saveProject() {
|
||||
win!.webContents.send('get-project-data')
|
||||
}
|
||||
|
||||
function deleteComponent(component: DeleteModel) {
|
||||
console.log("Delete Component")
|
||||
if(component.modeltype == ModelComponentType.SCRIPTACCOUNT) {
|
||||
DeleteTransaction.deleteScriptAccount(projectDirectory, component.componentName);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import {LoadedProject} from "../../app/LoadedProject";
|
||||
import {ProcessLoadedProject} from "./game-model/fs/ProcessLoadedProject";
|
||||
import {StoreProject} from "./game-model/fs/store/StoreProject";
|
||||
import {Gamesystem} from "./game-model/gamesystems/Gamesystem";
|
||||
import {DeleteModel} from "./game-model/fs/DeleteModel";
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@ -115,6 +116,7 @@ export class AppComponent implements OnInit{
|
||||
if(res != undefined && res) {
|
||||
if(affectedModelComponent instanceof ScriptAccount) {
|
||||
this.gameModel!.removeScriptAccount(affectedModelComponent);
|
||||
this.electronService.ipcRenderer.send('delete-component', new DeleteModel(affectedModelComponent.componentName, ModelComponentType.SCRIPTACCOUNT))
|
||||
} else if(affectedModelComponent instanceof Gamesystem) {
|
||||
this.gameModel!.removeGamesystem(affectedModelComponent);
|
||||
this.gamesystemOverview!.refresh()
|
||||
|
12
src/app/game-model/fs/DeleteModel.ts
Normal file
12
src/app/game-model/fs/DeleteModel.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import {ModelComponentType} from "../ModelComponentType";
|
||||
|
||||
export class DeleteModel {
|
||||
componentName: string
|
||||
modeltype: ModelComponentType
|
||||
|
||||
|
||||
constructor(componentName: string, modeltype: ModelComponentType) {
|
||||
this.componentName = componentName;
|
||||
this.modeltype = modeltype;
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"componentName": "Temperature",
|
||||
"componentDescription": "",
|
||||
"minValue": -50,
|
||||
"maxValue": 70
|
||||
}
|
Loading…
Reference in New Issue
Block a user