Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
Desktop Client
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SpinShare
Desktop Client
Commits
6e4abc76
Commit
6e4abc76
authored
Apr 11, 2021
by
Laura Heimann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
further work on the library database
parent
9e188be4
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
262 additions
and
65 deletions
+262
-65
src/App.vue
src/App.vue
+1
-1
src/main.js
src/main.js
+0
-4
src/modules/module.library.js
src/modules/module.library.js
+140
-55
src/router/index.js
src/router/index.js
+14
-3
src/views/LibraryUpdate.vue
src/views/LibraryUpdate.vue
+99
-0
src/views/Login.vue
src/views/Login.vue
+8
-2
No files found.
src/App.vue
View file @
6e4abc76
<
template
>
<
template
>
<div
id=
"app"
tabindex=
"-1"
v-on:keydown.esc=
"closeOverlays()"
>
<div
id=
"app"
tabindex=
"-1"
v-on:keydown.esc=
"closeOverlays()"
>
<main
:class=
"(['Login'].indexOf($route.name) > -1) ? 'hide-navigation' : ''"
>
<main
:class=
"(['L
ibraryUpdate', 'L
ogin'].indexOf($route.name) > -1) ? 'hide-navigation' : ''"
>
<Navigation
v-bind:downloadQueueCount=
"downloadQueue.length"
v-bind:downloadOverlayShown=
"showDownloadOverlay"
/>
<Navigation
v-bind:downloadQueueCount=
"downloadQueue.length"
v-bind:downloadOverlayShown=
"showDownloadOverlay"
/>
<router-view
:key=
"$route.fullPath"
/>
<router-view
:key=
"$route.fullPath"
/>
</main>
</main>
...
...
src/main.js
View file @
6e4abc76
...
@@ -8,10 +8,6 @@ import VueTilt from 'vue-tilt.js';
...
@@ -8,10 +8,6 @@ import VueTilt from 'vue-tilt.js';
import
{
ipcRenderer
}
from
'
electron
'
;
import
{
ipcRenderer
}
from
'
electron
'
;
import
VueObserveVisibility
from
'
vue-observe-visibility
'
;
import
VueObserveVisibility
from
'
vue-observe-visibility
'
;
import
{
VTooltip
,
VPopover
,
VClosePopover
}
from
'
v-tooltip
'
;
import
{
VTooltip
,
VPopover
,
VClosePopover
}
from
'
v-tooltip
'
;
import
ChartLibrary
from
'
@/modules/module.library.js
'
;
let
chartLibrary
=
new
ChartLibrary
();
chartLibrary
.
updateLibrary
();
Vue
.
use
(
VueTilt
);
Vue
.
use
(
VueTilt
);
Vue
.
use
(
VueObserveVisibility
);
Vue
.
use
(
VueObserveVisibility
);
...
...
src/modules/module.library.js
View file @
6e4abc76
...
@@ -12,6 +12,9 @@ class ChartLibrary {
...
@@ -12,6 +12,9 @@ class ChartLibrary {
const
userDataPath
=
app
.
getPath
(
'
userData
'
);
const
userDataPath
=
app
.
getPath
(
'
userData
'
);
this
.
path
=
path
.
join
(
userDataPath
,
'
ChartLibrary.sqlite
'
);
this
.
path
=
path
.
join
(
userDataPath
,
'
ChartLibrary.sqlite
'
);
this
.
db
=
null
;
this
.
db
=
null
;
this
.
databaseReady
=
false
;
this
.
databaseUpdating
=
false
;
this
.
databaseUpdateProgress
=
0
;
}
}
async
getLibrary
()
{
async
getLibrary
()
{
...
@@ -22,14 +25,16 @@ class ChartLibrary {
...
@@ -22,14 +25,16 @@ class ChartLibrary {
this
.
db
.
serialize
(()
=>
{
this
.
db
.
serialize
(()
=>
{
this
.
createDatabaseIfNotExists
();
this
.
createDatabaseIfNotExists
();
console
.
log
(
"
[ChartLibrary] Check Library Cleanness
"
);
// TODO: Check if Database is up to date and update if not
// TODO: Check if Database is up to date and update if not
this
.
db
.
get
(
'
SELECT * FROM meta
'
,
(
err
,
row
)
=>
{
this
.
db
.
all
(
"
SELECT * FROM meta
"
,
(
err
,
rows
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
"
[ChartLibrary]
"
+
err
.
message
);
console
.
error
(
"
[ChartLibrary]
"
+
err
.
message
);
}
}
console
.
log
(
row
);
console
.
log
(
row
s
);
});
})
.
run
()
;
// TODO: Get Library
// TODO: Get Library
});
});
...
@@ -50,47 +55,106 @@ class ChartLibrary {
...
@@ -50,47 +55,106 @@ class ChartLibrary {
} */
} */
}
}
async
updateLibrary
()
{
updateLibrary
()
{
console
.
log
(
"
[ChartLibrary] Library Refresh
"
);
let
userSettings
=
new
UserSettings
(
);
this
.
connectToDatabase
(
);
console
.
log
(
"
[ChartLibrary] Library Refresh
"
);
this
.
connectToDatabase
(()
=>
{
this
.
db
.
serialize
(()
=>
{
this
.
db
.
serialize
(()
=>
{
this
.
createDatabaseIfNotExists
();
this
.
createDatabaseIfNotExists
();
// TODO: Update Library and Save to DB
this
.
databaseReady
=
false
;
});
this
.
closeDatabase
(
);
console
.
log
(
"
[ChartLibrary] Updating Meta
"
);
/*
let
folderMD5
=
md5
(
userSettings
.
get
(
'
gameDirectory
'
));
let userSettings = new UserSettings();
let
clientVersion
=
app
.
getVersion
();
let data = {
folderMD5: "",
this
.
db
.
run
(
`
charts: []
INSERT OR REPLACE INTO meta (key, value)
};
VALUES ('folderMD5', '
${
folderMD5
}
'), ('databaseVersion', 1), ('clientVersion', '
${
clientVersion
}
');
`
);
// Clear previous entries
/* this.db.run(`
DELETE FROM charts;
VACUUM;
`); */
console
.
log
(
"
[ChartLibrary] Reading Charts
"
);
this
.
databaseUpdating
=
true
;
data.folderMD5 = md5(userSettings.get('gameDirectory')
);
this
.
db
.
run
(
"
BEGIN TRANSACTION
"
);
// Find all SRTB files
// Find all SRTB files
let
srtbFiles
=
glob
.
sync
(
path
.
join
(
userSettings
.
get
(
'
gameDirectory
'
),
"
*.srtb
"
));
let
srtbFiles
=
glob
.
sync
(
path
.
join
(
userSettings
.
get
(
'
gameDirectory
'
),
"
*.srtb
"
));
srtbFiles.forEach((file
) => {
srtbFiles
.
forEach
((
file
,
index
)
=>
{
// Parse SRTB file
// Parse SRTB file
try
{
try
{
data.charts.push(this.parseSRTBFile(file));
let
chartData
=
this
.
parseSRTBFile
(
file
);
this
.
db
.
run
(
`
INSERT INTO charts (
title,
subtitle,
artist,
charter,
hasEasyDifficulty,
hasNormalDifficulty,
hasHardDifficulty,
hasExpertDifficulty,
hasXDDifficulty,
easyDifficulty,
normalDifficulty,
hardDifficulty,
expertDifficulty,
XDDifficulty,
srtbHash,
srtbPath,
oggPath,
coverPath
) VALUES (
'
${
chartData
.
title
}
',
'
${
chartData
.
subtitle
}
',
'
${
chartData
.
artist
}
',
'
${
chartData
.
charter
}
',
'
${
chartData
.
hasEasyDifficulty
}
',
'
${
chartData
.
hasNormalDifficulty
}
',
'
${
chartData
.
hasHardDifficulty
}
',
'
${
chartData
.
hasExpertDifficulty
}
',
'
${
chartData
.
hasXDDifficulty
}
',
'
${
chartData
.
easyDifficulty
}
',
'
${
chartData
.
normalDifficulty
}
',
'
${
chartData
.
hardDifficulty
}
',
'
${
chartData
.
expertDifficulty
}
',
'
${
chartData
.
XDDifficulty
}
',
'
${
chartData
.
srtbHash
}
',
'
${
chartData
.
srtbPath
}
',
'
${
chartData
.
oggPath
}
',
'
${
chartData
.
coverPath
}
',
);
`
);
console
.
log
(
`[ChartLibrary] Progress:
${
index
}
/
${
srtbFiles
.
length
}
`
);
this
.
databaseUpdateProgress
=
srtbFiles
.
length
/
index
*
100
;
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
console
.
error
(
error
);
}
}
});
});
console.log("[ChartLibrary] Library Refresh Done.
");
this
.
db
.
run
(
"
COMMIT
"
);
// Save changes
this
.
databaseUpdating
=
false
;
fs.writeFileSync(this.path, JSON.stringify(data));
this
.
databaseReady
=
true
;
console.log("[ChartLibrary] Wrote Library to: " + this.path);
return data;
console
.
log
(
"
[ChartLibrary] Library Refresh Done.
"
);
*/
this
.
closeDatabase
();
});
});
}
}
parseSRTBFile
(
srtbFilePath
)
{
parseSRTBFile
(
srtbFilePath
)
{
...
@@ -112,18 +176,15 @@ class ChartLibrary {
...
@@ -112,18 +176,15 @@ class ChartLibrary {
expertDifficulty
:
0
,
expertDifficulty
:
0
,
XDDifficulty
:
0
,
XDDifficulty
:
0
,
srtbHash
:
""
,
srtbHash
:
""
,
paths
:
{
srtbPath
:
""
,
srtb
:
""
,
oggPath
:
""
,
ogg
:
""
,
coverPath
:
""
,
cover
:
""
,
coverBase64
:
""
,
}
}
}
let
srtbRawData
=
fs
.
readFileSync
(
srtbFilePath
,
"
utf-8
"
);
let
srtbRawData
=
fs
.
readFileSync
(
srtbFilePath
,
"
utf-8
"
);
let
srtbData
=
JSON
.
parse
(
srtbRawData
);
let
srtbData
=
JSON
.
parse
(
srtbRawData
);
data
.
paths
.
srtb
=
srtbFilePath
;
data
.
srtbPath
=
srtbFilePath
;
data
.
srtbHash
=
md5
(
srtbData
);
data
.
srtbHash
=
md5
(
srtbData
);
srtbData
.
largeStringValuesContainer
.
values
.
forEach
(
lSV
=>
{
srtbData
.
largeStringValuesContainer
.
values
.
forEach
(
lSV
=>
{
...
@@ -137,14 +198,7 @@ class ChartLibrary {
...
@@ -137,14 +198,7 @@ class ChartLibrary {
data
.
artist
=
lSVData
.
artistName
;
data
.
artist
=
lSVData
.
artistName
;
data
.
charter
=
lSVData
.
charter
;
data
.
charter
=
lSVData
.
charter
;
data
.
paths
.
cover
=
glob
.
sync
(
path
.
join
(
userSettings
.
get
(
'
gameDirectory
'
),
"
AlbumArt
"
,
lSVData
.
albumArtReference
.
assetName
+
'
.*
'
))[
0
];
data
.
coverPath
=
glob
.
sync
(
path
.
join
(
userSettings
.
get
(
'
gameDirectory
'
),
"
AlbumArt
"
,
lSVData
.
albumArtReference
.
assetName
+
'
.*
'
))[
0
];
if
(
data
.
paths
.
cover
!=
undefined
)
{
try
{
data
.
paths
.
coverBase64
=
"
data:image/jpg;base64,
"
+
fs
.
readFileSync
(
data
.
paths
.
cover
,
{
encoding
:
'
base64
'
})
}
catch
(
error
)
{
console
.
error
(
error
);
}
}
lSVData
.
difficulties
.
forEach
(
difficulty
=>
{
lSVData
.
difficulties
.
forEach
(
difficulty
=>
{
if
(
difficulty
.
_active
)
{
if
(
difficulty
.
_active
)
{
...
@@ -204,7 +258,7 @@ class ChartLibrary {
...
@@ -204,7 +258,7 @@ class ChartLibrary {
// Parse ClipInfo
// Parse ClipInfo
if
(
lSV
.
key
.
includes
(
"
ClipInfo
"
))
{
if
(
lSV
.
key
.
includes
(
"
ClipInfo
"
))
{
data
.
paths
.
ogg
=
glob
.
sync
(
path
.
join
(
userSettings
.
get
(
'
gameDirectory
'
),
"
AudioClips
"
,
lSVData
.
clipAssetReference
.
assetName
+
'
.*
'
))[
0
];
data
.
oggPath
=
glob
.
sync
(
path
.
join
(
userSettings
.
get
(
'
gameDirectory
'
),
"
AudioClips
"
,
lSVData
.
clipAssetReference
.
assetName
+
'
.*
'
))[
0
];
}
}
});
});
...
@@ -213,12 +267,14 @@ class ChartLibrary {
...
@@ -213,12 +267,14 @@ class ChartLibrary {
return
data
;
return
data
;
}
}
connectToDatabase
()
{
connectToDatabase
(
callback
)
{
this
.
db
=
new
sqlite3
.
Database
(
this
.
path
,
(
err
)
=>
{
this
.
db
=
new
sqlite3
.
Database
(
this
.
path
,
(
err
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
"
[ChartLibrary]
"
+
err
.
message
);
console
.
error
(
"
[ChartLibrary]
"
+
err
.
message
);
}
}
console
.
log
(
'
[ChartLibrary] Connected to Database
'
);
console
.
log
(
'
[ChartLibrary] Connected to Database
'
);
callback
();
});
});
}
}
...
@@ -233,9 +289,38 @@ class ChartLibrary {
...
@@ -233,9 +289,38 @@ class ChartLibrary {
createDatabaseIfNotExists
()
{
createDatabaseIfNotExists
()
{
// TODO: Finalize Database Structure
// TODO: Finalize Database Structure
this
.
db
.
prepare
(
`
this
.
db
.
run
(
`
CREATE TABLE IF NOT EXISTS meta (folderMD5 TEXT, clientVersion TEXT);
CREATE TABLE IF NOT EXISTS meta (
`
).
run
().
finalize
();
key TEXT,
value TEXT
);
`
);
this
.
db
.
run
(
`
CREATE TABLE IF NOT EXISTS charts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
subtitle TEXT,
artist TEXT,
charter TEXT,
hasEasyDifficulty INTEGER,
hasNormalDifficulty INTEGER,
hasHardDifficulty INTEGER,
hasExpertDifficulty INTEGER,
hasXDDifficulty INTEGER,
easyDifficulty INTEGER,
normalDifficulty INTEGER,
hardDifficulty INTEGER,
expertDifficulty INTEGER,
XDDifficulty INTEGER,
srtbHash TEXT,
srtbPath TEXT,
oggPath TEXT,
coverPath TEXT
);
`
);
console
.
log
(
"
[ChartLibrary] Created Tables
"
);
}
}
}
}
...
...
src/router/index.js
View file @
6e4abc76
...
@@ -11,6 +11,7 @@ import ViewStartupHotThisWeekSongs from '../views/StartupHotThisWeekSongs.vue';
...
@@ -11,6 +11,7 @@ import ViewStartupHotThisWeekSongs from '../views/StartupHotThisWeekSongs.vue';
import
ViewStartupHotThisMonthSongs
from
'
../views/StartupHotThisMonthSongs.vue
'
;
import
ViewStartupHotThisMonthSongs
from
'
../views/StartupHotThisMonthSongs.vue
'
;
import
ViewSearch
from
'
../views/Search.vue
'
;
import
ViewSearch
from
'
../views/Search.vue
'
;
import
ViewLibrary
from
'
../views/Library.vue
'
;
import
ViewLibrary
from
'
../views/Library.vue
'
;
import
ViewLibraryUpdate
from
'
../views/LibraryUpdate.vue
'
;
import
ViewSongDetail
from
'
../views/SongDetail.vue
'
;
import
ViewSongDetail
from
'
../views/SongDetail.vue
'
;
import
ViewSongDetailReviews
from
'
../views/SongDetailReviews.vue
'
;
import
ViewSongDetailReviews
from
'
../views/SongDetailReviews.vue
'
;
import
ViewSongDetailSpinPlays
from
'
../views/SongDetailSpinPlays.vue
'
;
import
ViewSongDetailSpinPlays
from
'
../views/SongDetailSpinPlays.vue
'
;
...
@@ -29,6 +30,12 @@ Vue.use(VueAxios, axios);
...
@@ -29,6 +30,12 @@ Vue.use(VueAxios, axios);
const
routes
=
[{
const
routes
=
[{
path
:
'
/
'
,
path
:
'
/
'
,
name
:
'
Index
'
,
redirect
:
{
name
:
'
LibraryUpdate
'
},
},
{
path
:
'
/login
'
,
name
:
'
Login
'
,
name
:
'
Login
'
,
component
:
ViewLogin
component
:
ViewLogin
},
{
},
{
...
@@ -74,7 +81,11 @@ const routes = [{
...
@@ -74,7 +81,11 @@ const routes = [{
name
:
'
Library
'
,
name
:
'
Library
'
,
component
:
ViewLibrary
component
:
ViewLibrary
},
{
},
{
path
:
'
/song/:id
'
,
path
:
'
/libraryUpdate
'
,
name
:
'
LibraryUpdate
'
,
component
:
ViewLibraryUpdate
},
{
path
:
'
/song/:id?
'
,
name
:
'
SongDetail
'
,
name
:
'
SongDetail
'
,
component
:
ViewSongDetail
,
component
:
ViewSongDetail
,
redirect
:
{
redirect
:
{
...
@@ -94,7 +105,7 @@ const routes = [{
...
@@ -94,7 +105,7 @@ const routes = [{
}
}
]
]
},
{
},
{
path
:
'
/user/:id
'
,
path
:
'
/user/:id
?
'
,
name
:
'
UserDetail
'
,
name
:
'
UserDetail
'
,
component
:
ViewUserDetail
,
component
:
ViewUserDetail
,
redirect
:
{
redirect
:
{
...
@@ -127,7 +138,7 @@ const routes = [{
...
@@ -127,7 +138,7 @@ const routes = [{
}
}
]
]
},
{
},
{
path
:
'
/playlist/:id
'
,
path
:
'
/playlist/:id
?
'
,
name
:
'
PlaylistDetail
'
,
name
:
'
PlaylistDetail
'
,
component
:
ViewPlaylistDetail
,
component
:
ViewPlaylistDetail
,
},
{
},
{
...
...
src/views/LibraryUpdate.vue
0 → 100644
View file @
6e4abc76
<
template
>
<div
class=
"section-libraryUpdate"
>
<div
class=
"login-box login-loading"
>
<Loading
/>
</div>
</div>
</
template
>
<
script
>
import
{
remote
,
ipcRenderer
}
from
'
electron
'
;
import
ChartLibrary
from
'
@/modules/module.library.js
'
;
import
Loading
from
'
@/components/Loading.vue
'
;
export
default
{
name
:
'
LibraryUpdate
'
,
components
:
{
Loading
},
mounted
:
function
()
{
setTimeout
(
function
()
{
console
.
log
(
'
[LibraryUpdate] Updating Library
'
);
let
chartLibrary
=
new
ChartLibrary
();
chartLibrary
.
updateLibrary
();
console
.
log
(
"
[LibraryUpdate] Redirect to Login
"
);
},
1000
);
}
}
</
script
>
<
style
scoped
lang=
"less"
>
.section-libraryUpdate {
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
display: flex;
justify-content: center;
align-items: center;
& .loading {
background: black;
}
& .login-box {
width: 500px;
background: #000;
border-radius: 6px;
padding: 40px;
& .logo {
text-align: center;
margin-bottom: 30px;
& img {
height: 50px;
}
}
& .explaination {
line-height: 1.5;
}
& .error {
border: 2px solid #fb1357;
padding: 15px;
background: #fb1357;
border-radius: 4px;
margin-bottom: 15px;
}
& .connectcodeInput {
font-size: 42px;
background: transparent;
border: 0px;
width: 100%;
text-align: center;
color: #fff;
padding: 15px;
margin-top: 30px;
margin-bottom: 15px;
letter-spacing: 0.15em;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
}
& .actions {
display: flex;
flex-direction: row-reverse;
}
&.login-loading {
padding: 60px;
}
}
}
</
style
>
\ No newline at end of file
src/views/Login.vue
View file @
6e4abc76
<
template
>
<
template
>
<section
class=
"section-login"
>
<section
class=
"section-login"
>
<div
class=
"login-box login-loading"
v-if=
"chartLibraryLoading"
>
<Loading
/><br
/>
ChartLibrary Loading
</div>
<div
class=
"login-box login-loading"
v-if=
"apiLoginLoading"
>
<div
class=
"login-box login-loading"
v-if=
"apiLoginLoading"
>
<Loading
/>
<Loading
/>
</div>
</div>
...
@@ -46,7 +50,9 @@
...
@@ -46,7 +50,9 @@
let
ssapi
=
new
SSAPI
();
let
ssapi
=
new
SSAPI
();
let
userSettings
=
new
UserSettings
();
let
userSettings
=
new
UserSettings
();
if
(
!
userSettings
.
get
(
"
connectToken
"
))
{
console
.
log
(
"
[Login] Check Login
"
);
/* if(!userSettings.get("connectToken")) {
this.showLoginBox();
this.showLoginBox();
} else {
} else {
ssapi.validateConnectToken(userSettings.get("connectToken")).then((data) => {
ssapi.validateConnectToken(userSettings.get("connectToken")).then((data) => {
...
@@ -58,7 +64,7 @@
...
@@ -58,7 +64,7 @@
}).catch(() => {
}).catch(() => {
this.showLoginBox();
this.showLoginBox();
});
});
}
}
*/
},
},
methods
:
{
methods
:
{
connect
:
function
()
{
connect
:
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment