Compare commits

...

10 Commits

Author SHA1 Message Date
MathieuG-P b5a08584a0 bumb version 2023-01-17 23:02:45 +01:00
MathieuG-P 78568cd235 Merge pull request #118 from Zagrios/bugfix/can-clone-with-same-name/113
bugfix/can-clone-with-same-name/113
2023-01-17 22:58:25 +01:00
MathieuG-P 8e86d4a7c5 change versions file system 2023-01-17 22:57:43 +01:00
MathieuG-P 7a2639f772 Merge pull request #117 from Zagrios/bugfix/wrong-placement-tooltip-version/115
bugfix/wrong-placement-tooltip-version/115
2023-01-17 20:28:43 +01:00
MathieuG-P 535430d0c5 better version tooltip 2023-01-17 20:28:14 +01:00
MathieuG-P b82ddc1c59 Merge pull request #110 from Zagrios/hotfix/fix-tab-navigation
hotfix/fix-tab-navigation
2023-01-16 21:24:02 +01:00
MathieuG-P f4dc6ab838 fix tab navigation 2023-01-16 21:23:28 +01:00
MathieuG-P 62dde63206 Merge pull request #109 from Zagrios/hotfix/improve-nav-bar-static-button
hotfix/improve-nav-bar-static-button
2023-01-16 20:58:24 +01:00
MathieuG-P 5c034013fe improve nav-bar static buttons 2023-01-16 20:57:38 +01:00
MathieuG-P 23717c15d1 Create SECURITY.md 2023-01-14 22:15:00 +01:00
11 changed files with 111 additions and 54 deletions
+9
View File
@@ -0,0 +1,9 @@
# Reporting Security Issues
If you discover a security issue in BSManager, please report it by sending an
email to [contact@bsmanager.io](mailto:contact@bsmanager.io).
This will allow us to assess the risk, and make a fix available before we add a
bug report to the GitHub repository.
Thanks for helping make BSManager safe for everyone.
+4
View File
@@ -13,6 +13,10 @@
"refuse": "Refuse",
"apply": "Apply"
},
"nav-bar":{
"add-version": "Add a version",
"settings": "Settings"
},
"pages": {
"version-viewer": {
"launch-mods": {
+4
View File
@@ -13,6 +13,10 @@
"refuse": "Rechazar",
"apply": "Aplicar"
},
"nav-bar":{
"add-version": "Agregar una versión",
"settings": "Ajustes"
},
"pages": {
"version-viewer": {
"launch-mods": {
+4
View File
@@ -13,6 +13,10 @@
"refuse": "Refuser",
"apply": "Appliquer"
},
"nav-bar":{
"add-version": "Ajouter une version",
"settings": "Paramètres"
},
"pages": {
"version-viewer": {
"launch-mods": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "bs-manager",
"version": "1.0.0-alpha.5",
"version": "1.0.0-alpha.6",
"description": "A foundation for scalable desktop apps",
"main": "./dist/main/main.js",
"author": {
+48 -33
View File
@@ -5,7 +5,6 @@ import { SteamService } from "./steam.service";
import { UtilsService } from "./utils.service";
import { BS_APP_ID, OCULUS_BS_DIR } from "../constants";
import path from "path";
import { createInterface } from "readline";
import { createReadStream } from "fs";
import fs from "fs-extra";
import { ConfigurationService } from "./configuration.service";
@@ -14,6 +13,7 @@ import { BsmException } from "shared/models/bsm-exception.model";
import log from "electron-log";
import { OculusService } from "./oculus.service";
import { DownloadLinkType } from "shared/models/mods";
import sanitize from "sanitize-filename";
export class BSLocalVersionService{
@@ -47,21 +47,27 @@ export class BSLocalVersionService{
if(!this.utilsService.pathExist(versionFilePath)){ return null; }
const versionsAvailable = await this.remoteVersionService.getAvailableVersions();
return new Promise<string>(resolve => {
const readLine = createInterface({ input: createReadStream(versionFilePath) });
const stream = createReadStream(versionFilePath);
let findVersion: string = null;
readLine.on('line', (line) => {
stream.on('data', (line) => {
line = line.toString();
for(const version of versionsAvailable){
if(line.includes(version.BSVersion)){
findVersion = version.BSVersion;
readLine.close();
stream.close();
stream.destroy();
break;
}
}
});
readLine.on('close', () => {
stream.on('end', () => {
if(findVersion){ resolve(findVersion) }
resolve(findVersion);
});
stream.on('close', () => {
if(findVersion){ resolve(findVersion) }
resolve(findVersion);
})
})
}
@@ -92,11 +98,11 @@ export class BSLocalVersionService{
}
private removeSpecialChar(seq: string): string{
return seq.replace( /[<>:"\/\\|?*]+/g, '' );
return sanitize(seq);
}
public getVersionFolder(version: BSVersion){
return version.name ? `${version.BSVersion}-${version.name}` : version.BSVersion;
public getVersionFolder(version: BSVersion): string{
return version.name ?? version.BSVersion;
}
public getVersionType(version: BSVersion): DownloadLinkType{
@@ -107,8 +113,10 @@ export class BSLocalVersionService{
private async getSteamVersion(): Promise<BSVersion>{
const steamBsFolder = await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber");
if(!steamBsFolder || !this.utilsService.pathExist(steamBsFolder)){ return null; }
const steamBsVersion = await this.getVersionOfBSFolder(steamBsFolder);
if(!steamBsVersion){ return null; }
const version = await this.remoteVersionService.getVersionDetails(steamBsVersion);
if(!version){ return null; }
@@ -127,30 +135,37 @@ export class BSLocalVersionService{
public async getInstalledVersions(): Promise<BSVersion[]>{
const versions: BSVersion[] = [];
const steamVersion = await this.getSteamVersion();
if(steamVersion){ versions.push(steamVersion); }
const oculusVersion = await this.getOculusVersion();
if(oculusVersion){ versions.push(oculusVersion); }
const versions: BSVersion[] = [];
if(!this.utilsService.pathExist(this.installLocationService.versionsDirectory)){ return versions }
const steamVersion = await this.getSteamVersion();
if(steamVersion){ versions.push(steamVersion); }
const folderInInstallation = this.utilsService.listDirsInDir(this.installLocationService.versionsDirectory);
for(const f of folderInInstallation){
log.info("try get version from folder", f);
let version = await this.remoteVersionService.getVersionDetails(f);
if(version){ version = this.getCustomVersions().find(v => v.BSVersion === version.BSVersion && v.name === version.name) ?? version; }
else { version = this.getCustomVersions().find(v => {
const [version, ...rest] = f.split("-");
if(rest.length < 1){ return false; }
const name = rest.join("-");
return name === v.name && version === v.BSVersion;
})
}
version && versions.push(version);
};
this.setCustomVersions(versions.filter(v => !!v.name || !!v.color));
return versions;
const oculusVersion = await this.getOculusVersion();
if(oculusVersion){ versions.push(oculusVersion); }
if(!this.utilsService.pathExist(this.installLocationService.versionsDirectory)){ return versions }
const folderInInstallation = this.utilsService.listDirsInDir(this.installLocationService.versionsDirectory, true);
for(const f of folderInInstallation){
log.info("try get version from folder", f);
const rawVersion = await this.getVersionOfBSFolder(f);
if(!rawVersion){ continue; }
const bsVersion = {...await this.remoteVersionService.getVersionDetails(rawVersion)};
if(!bsVersion){ continue; }
bsVersion.name = path.basename(f) !== bsVersion.BSVersion ? path.basename(f) : undefined;
const customVersion = this.getCustomVersions().find(custom => custom.BSVersion === bsVersion.BSVersion && custom.name === bsVersion.name);
if(customVersion){
bsVersion.color = customVersion.color;
}
versions.push(bsVersion);
};
this.setCustomVersions(versions.filter(v => !!v.color));
return versions;
}
public async deleteVersion(version: BSVersion): Promise<boolean>{
@@ -177,13 +192,14 @@ export class BSLocalVersionService{
return editedVersion;
}
if(this.utilsService.pathExist(newPath)){ throw {title: "VersionAlreadExist"} as BsmException; }
if(this.utilsService.pathExist(newPath) && newPath === oldPath){ throw {title: "VersionAlreadExist"} as BsmException; }
return rename(oldPath, newPath).then(() => {
this.deleteCustomVersion(version);
this.addCustomVersion(editedVersion);
return editedVersion;
}).catch((err: Error) => {
log.error("edit version error", err, version, name, color);
throw {title: "CantRename", error: err} as BsmException;
});
}
@@ -198,7 +214,6 @@ export class BSLocalVersionService{
if(originPath === newPath){
this.deleteCustomVersion(version);
this.addCustomVersion(cloneVersion);
return cloneVersion;
}
if(this.utilsService.pathExist(newPath)){ throw {title: "VersionAlreadExist"} as BsmException; }
@@ -207,7 +222,7 @@ export class BSLocalVersionService{
this.addCustomVersion(cloneVersion);
return cloneVersion;
}).catch((err: Error) => {
log.error("CLONE", err, version);
log.error("clone version error", err, version, name, color);
throw {title: "CantClone", error: err} as BsmException
})
}
@@ -120,7 +120,7 @@ export function MapsPlaylistsPanel({version}: Props) {
<div className="w-full h-full flex flex-col items-center justify-center">
<nav className="w-full shrink-0 flex h-9 justify-center px-40 gap-2 mb-3 text-main-color-1 dark:text-white">
<div className="h-full rounded-full bg-light-main-color-2 dark:bg-main-color-2 grow p-[6px]">
<input type="text" className="h-full w-full bg-light-main-color-1 dark:bg-main-color-1 rounded-full px-2" placeholder={t("pages.version-viewer.maps.search-bar.search-placeholder")} value={tabIndex === 0 ? mapSearch : playlistSearch} onChange={e => handleSearch(e.target.value)}/>
<input type="text" className="h-full w-full bg-light-main-color-1 dark:bg-main-color-1 rounded-full px-2" placeholder={t("pages.version-viewer.maps.search-bar.search-placeholder")} value={tabIndex === 0 ? mapSearch : playlistSearch} onChange={e => handleSearch(e.target.value)} tabIndex={-1}/>
</div>
<BsmDropdownButton className="h-full relative z-[1] flex justify-center" buttonClassName="flex items-center justify-center h-full rounded-full px-2 py-1" icon="filter" text="pages.version-viewer.maps.search-bar.filters-btn" withBar={false}>
<FilterPanel className="absolute top-[calc(100%+3px)] origin-top w-[500px] h-fit p-2 rounded-md shadow-md shadow-black" filter={mapFilter} onChange={setMapFilter}/>
@@ -81,11 +81,9 @@ export function BsVersionItem(props: {version: BSVersion}) {
const renderVersionText = () => {
if(props.version.name){
return (
<Tippy content={props.version.BSVersion} placement="right-end" arrow={false} className="font-bold !bg-main-color-3" duration={[200, 0]}>
<div className="h-8 flex items-center dark:text-gray-200 text-gray-800 overflow-hidden">
<div ref={ref} className='whitespace-nowrap font-bold tracking-wide w-full text-center' style={{fontSize}}>{props.version.name}</div>
</div>
</Tippy>
<div className="h-8 flex items-center dark:text-gray-200 text-gray-800 overflow-hidden">
<div ref={ref} className='whitespace-nowrap font-bold tracking-wide w-full text-center' style={{fontSize}}>{props.version.name}</div>
</div>
)
}
return (
@@ -98,10 +96,20 @@ export function BsVersionItem(props: {version: BSVersion}) {
return (
<NavBarItem onCancel={cancel} progress={downloading ? downloadPercent : 0} isActive={isActive() && !downloading} isDownloading={downloading}>
<Link onDoubleClick={handleDoubleClick} to={`/bs-version/${props.version.BSVersion}`} state={props.version} className="w-full flex items-center justify-start content-center max-w-full">
{renderIcon()}
{renderVersionText()}
</Link>
{props.version.name ? (
<Tippy content={props.version.BSVersion} placement="right-end" arrow={false} className="font-bold !bg-main-color-3" duration={[100, 0]} animation="shift-away-subtle">
<Link onDoubleClick={handleDoubleClick} to={`/bs-version/${props.version.BSVersion}`} state={props.version} className="w-full flex items-center justify-start content-center max-w-full">
{renderIcon()}
{renderVersionText()}
</Link>
</Tippy>
) : (
<Link onDoubleClick={handleDoubleClick} to={`/bs-version/${props.version.BSVersion}`} state={props.version} className="w-full flex items-center justify-start content-center max-w-full">
{renderIcon()}
{renderVersionText()}
</Link>
)}
</NavBarItem>
)
}
@@ -7,12 +7,20 @@ import { useObservable } from 'renderer/hooks/use-observable.hook';
import { BsManagerIcon } from './bsmanager-icon.component';
import { MapsNavBarItem } from './nav-bar-items/maps-nav-bar-item.component';
import { NavBarSpliter } from './nav-bar-spliter.component';
import { useThemeColor } from 'renderer/hooks/use-theme-color.hook';
import Tippy from '@tippyjs/react';
import { useTranslation } from 'renderer/hooks/use-translation.hook';
import { I18nService } from 'renderer/services/i18n.service';
export function NavBar() {
const bsVersionServoce = BSVersionManagerService.getInstance();
const bsVersionServoce = BSVersionManagerService.getInstance();
const installedVersions = useObservable(bsVersionServoce.installedVersions$);
const installedVersions = useObservable(bsVersionServoce.installedVersions$);
const color = useThemeColor("first-color");
const t = useTranslation();
const _ = useObservable(I18nService.getInstance().currentLanguage$)
return (
<nav id='nav-bar' className='z-10 flex flex-col h-full max-h-full items-center p-1 bg-light-main-color-1 dark:bg-main-color-1'>
@@ -23,13 +31,17 @@ export function NavBar() {
{installedVersions && installedVersions.map((version) => <BsVersionItem key={JSON.stringify(version)} version={version}/>)}
</ol>
<NavBarSpliter/>
<div className='w-full pb-2 flex flex-col items-center content-center justify-start gap-2'>
<Link to="blah">
<BsmIcon icon='add' className='text-blue-500 h-[34px]'/>
</Link>
<Link to="settings">
<BsmIcon icon='settings' className='text-blue-500 h-7'/>
</Link>
<div className='w-full pb-2 flex flex-col items-center content-center justify-start gap-1'>
<Tippy placement="right" content={t("nav-bar.add-version")}>
<Link className='rounded-md w-9 h-9 flex justify-center items-center hover:bg-light-main-color-3 dark:hover:bg-main-color-3' to="blah">
<BsmIcon icon='add' className='text-blue-500 h-[34px]' style={{color}}/>
</Link>
</Tippy>
<Tippy placement="right" content={t("nav-bar.settings")}>
<Link className='rounded-md w-9 h-9 flex justify-center items-center hover:bg-light-main-color-3 dark:hover:bg-main-color-3' to="settings">
<BsmIcon icon='settings' className='text-blue-500 h-7' style={{color}}/>
</Link>
</Tippy>
</div>
</nav>
)
@@ -2,7 +2,7 @@ import { CSSProperties } from "react";
export function SettingIcon(props: {className?: string, style?: CSSProperties}) {
return (
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" height="40" width="40">
<svg className={props.className} style={props.style} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
<path fill="currentColor" d="M16.5 35.833 15.792 30.792Q15 30.542 14.104 30.042Q13.208 29.542 12.542 28.958L7.875 31.042L4.375 24.875L8.542 21.792Q8.458 21.375 8.438 20.896Q8.417 20.417 8.417 20Q8.417 19.625 8.438 19.146Q8.458 18.667 8.542 18.208L4.375 15.125L7.875 9L12.542 11.042Q13.25 10.458 14.125 9.979Q15 9.5 15.792 9.208L16.5 4.167H23.5L24.208 9.208Q25.042 9.542 25.875 10Q26.708 10.458 27.375 11.042L32.125 9L35.625 15.125L31.375 18.208Q31.5 18.667 31.521 19.125Q31.542 19.583 31.542 20Q31.542 20.417 31.5 20.854Q31.458 21.292 31.375 21.792L35.583 24.875L32.083 31.042L27.375 28.917Q26.667 29.542 25.854 30.042Q25.042 30.542 24.208 30.792L23.5 35.833ZM19.958 24.792Q21.958 24.792 23.375 23.396Q24.792 22 24.792 20Q24.792 18 23.375 16.604Q21.958 15.208 19.958 15.208Q17.958 15.208 16.562 16.604Q15.167 18 15.167 20Q15.167 22 16.562 23.396Q17.958 24.792 19.958 24.792Z"/>
</svg>
)
+1
View File
@@ -14,6 +14,7 @@ import { MapsPage } from "../pages/maps-page.component";
import "tailwindcss/tailwind.css";
import { BsmIframeView } from "../components/shared/iframe-view.component";
import 'tippy.js/dist/tippy.css';
import 'tippy.js/animations/shift-away-subtle.css';
import { MapsManagerService } from "renderer/services/maps-manager.service";
import { PlaylistsManagerService } from "renderer/services/playlists-manager.service";
import { ModelsManagerService } from "renderer/services/models-manager.service";