Commit 7f9463a6 authored by SpinShare's avatar SpinShare

fixed DeleteOverlay

parent 0fbd4383
...@@ -2,13 +2,11 @@ ...@@ -2,13 +2,11 @@
<div id="app"> <div id="app">
<main> <main>
<Navigation /> <Navigation />
<router-view /> <router-view ref="currentView" />
</main> </main>
<ContextMenu> <ContextMenu>
</ContextMenu> </ContextMenu>
<DeleteOverlay v-if="showDeleteOverlay" v-bind:deleteFiles="deleteFiles" />
</div> </div>
</template> </template>
...@@ -21,77 +19,27 @@ ...@@ -21,77 +19,27 @@
import Navigation from '@/components/Navigation/Navigation.vue'; import Navigation from '@/components/Navigation/Navigation.vue';
import ContextMenu from '@/components/ContextMenu/ContextMenu.vue'; import ContextMenu from '@/components/ContextMenu/ContextMenu.vue';
import DeleteOverlay from '@/components/Overlays/DeleteOverlay.vue';
export default { export default {
name: 'App', name: 'App',
components: { components: {
Navigation, Navigation,
ContextMenu, ContextMenu
DeleteOverlay
}, },
data: function() { data: function() {
return { return {
downloadQueue: [], downloadQueue: []
showDeleteOverlay: false,
deleteFiles: []
} }
}, },
mounted: function() { mounted: function() {
this.$root.$on('download', (url) => { this.$root.$on('download', (url) => {
this.addToQueue(url); this.addToQueue(url);
}); });
this.$root.$on('delete', (file) => {
this.$data.showDeleteOverlay = true;
this.$data.deleteFiles = this.getConnectedFiles(file);
console.log(this.$data.deleteFiles);
});
this.$root.$on('deleteDeny', () => {
this.$data.showDeleteOverlay = false;
this.$data.deleteFiles = "";
});
this.$root.$on('deleteConfirmed', () => {
this.$data.deleteFiles.forEach((file) => {
fs.unlinkSync(file);
});
this.$data.showDeleteOverlay = false;
this.$data.deleteFiles = "";
});
}, },
methods: { methods: {
addToQueue: function(url) { addToQueue: function(url) {
this.$data.downloadQueue.push(url); this.$data.downloadQueue.push(url);
console.log("Added " + url + " to queue"); console.log("Added " + url + " to queue");
},
getConnectedFiles: function(srtbFilePath) {
let userSettings = new UserSettings();
let srtbContent = JSON.parse( fs.readFileSync(srtbFilePath) );
let connectedFiles = [];
connectedFiles.push(srtbFilePath);
let stringValueContainers = srtbContent['largeStringValuesContainer'].values;
stringValueContainers.forEach((stringValueContainer) => {
if(stringValueContainer.key == "SO_TrackInfo_TrackInfo") {
let rawTrackInfo = JSON.parse( stringValueContainer.val );
let coverPath = glob.sync(path.join(userSettings.get('gameDirectory'), "AlbumArt", rawTrackInfo.albumArtReference.assetName + ".*"))[0];
if(coverPath) {
connectedFiles.push(coverPath);
}
}
if(stringValueContainer.key.includes("SO_ClipInfo")) {
let rawClipInfo = JSON.parse( stringValueContainer.val );
let clipPath = glob.sync(path.join(userSettings.get('gameDirectory'), "AudioClips", rawClipInfo.clipAssetReference.assetName + ".*"))[0];
if(clipPath) {
connectedFiles.push(clipPath);
}
}
});
return connectedFiles;
} }
}, },
watch: { watch: {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</div> </div>
</div> </div>
<div class="delete-actions"> <div class="delete-actions">
<button class="button">Delete</button> <button class="button" v-on:click="confirm()">Delete</button>
<button class="button" v-on:click="close()">Close</button> <button class="button" v-on:click="close()">Close</button>
</div> </div>
</div> </div>
...@@ -27,10 +27,11 @@ ...@@ -27,10 +27,11 @@
], ],
methods: { methods: {
confirm() { confirm() {
this.$root.$emit('deleteConfirm'); console.log("confirm");
this.$parent.$emit('deleteConfirm');
}, },
close() { close() {
this.$root.$emit('deleteDeny'); this.$parent.$emit('deleteDeny');
} }
} }
} }
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
x: e.pageX, x: e.pageX,
y: e.pageY, y: e.pageY,
items: [ items: [
{ icon: "delete", title: "Delete", method: () => { this.$root.$emit('delete', this.$props.file); } } { icon: "delete", title: "Delete", method: () => { this.$parent.$parent.$emit('delete', this.$props.file); } }
]}); ]});
} }
} }
......
...@@ -14,17 +14,20 @@ ...@@ -14,17 +14,20 @@
v-bind="song" /> v-bind="song" />
</template> </template>
</SongRow> </SongRow>
<DeleteOverlay v-if="showDeleteOverlay" v-bind:deleteFiles="deleteFiles" />
</section> </section>
</template> </template>
<script> <script>
import glob from 'glob';
import fs from 'fs'; import fs from 'fs';
import glob from 'glob';
import path from 'path'; import path from 'path';
import UserSettings from '@/modules/module.usersettings.js'; import UserSettings from '@/modules/module.usersettings.js';
import SRXD from '@/modules/module.srxd.js'; import SRXD from '@/modules/module.srxd.js';
import DeleteOverlay from '@/components/Overlays/DeleteOverlay.vue';
import SongRow from '@/components/Song/SongRow.vue'; import SongRow from '@/components/Song/SongRow.vue';
import SongLocalItem from '@/components/Song/SongLocalItem.vue'; import SongLocalItem from '@/components/Song/SongLocalItem.vue';
import SongInstallItem from '@/components/Song/SongInstallItem.vue'; import SongInstallItem from '@/components/Song/SongInstallItem.vue';
...@@ -33,16 +36,37 @@ ...@@ -33,16 +36,37 @@
name: 'Library', name: 'Library',
data: function() { data: function() {
return { return {
librarySongs: [] librarySongs: [],
showDeleteOverlay: false,
deleteFiles: []
} }
}, },
components: { components: {
SongRow, SongRow,
SongLocalItem, SongLocalItem,
SongInstallItem SongInstallItem,
DeleteOverlay
}, },
mounted: function() { mounted: function() {
this.refreshLibrary(); this.refreshLibrary();
this.$on('delete', (file) => {
this.$data.showDeleteOverlay = true;
this.$data.deleteFiles = this.getConnectedFiles(file);
console.log(this.$data.deleteFiles);
});
this.$on('deleteDeny', () => {
this.$data.showDeleteOverlay = false;
this.$data.deleteFiles = "";
});
this.$on('deleteConfirm', () => {
this.$data.deleteFiles.forEach((file) => {
fs.unlinkSync(file);
});
this.refreshLibrary();
this.$data.showDeleteOverlay = false;
this.$data.deleteFiles = "";
});
}, },
methods: { methods: {
refreshLibrary: function() { refreshLibrary: function() {
...@@ -96,6 +120,36 @@ ...@@ -96,6 +120,36 @@
}); });
return trackInfo; return trackInfo;
},
getConnectedFiles: function(srtbFilePath) {
let userSettings = new UserSettings();
let srtbContent = JSON.parse( fs.readFileSync(srtbFilePath) );
let connectedFiles = [];
connectedFiles.push(srtbFilePath);
let stringValueContainers = srtbContent['largeStringValuesContainer'].values;
stringValueContainers.forEach((stringValueContainer) => {
if(stringValueContainer.key == "SO_TrackInfo_TrackInfo") {
let rawTrackInfo = JSON.parse( stringValueContainer.val );
let coverPath = glob.sync(path.join(userSettings.get('gameDirectory'), "AlbumArt", rawTrackInfo.albumArtReference.assetName + ".*"))[0];
if(coverPath) {
connectedFiles.push(coverPath);
}
}
if(stringValueContainer.key.includes("SO_ClipInfo")) {
let rawClipInfo = JSON.parse( stringValueContainer.val );
let clipPath = glob.sync(path.join(userSettings.get('gameDirectory'), "AudioClips", rawClipInfo.clipAssetReference.assetName + ".*"))[0];
if(clipPath) {
connectedFiles.push(clipPath);
}
}
});
return connectedFiles;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment