Commit 1c09ffdc authored by 神楽坂玲奈's avatar 神楽坂玲奈

Merge branch 'v3' of github.com:mycard/mycard into v3

parents 4136eb34 cf943090
<h1>{{currentApp.name}}</h1> <h1>{{currentApp.name}}</h1>
<div *ngIf="currentApp.status.status === 'init'"> <div *ngIf="currentApp.status.status === 'init'">
<button type="button" class="btn btn-primary" data-toggle="modal" (click)="updateInstallConfig()" <button type="button" class="btn btn-primary" data-toggle="modal" (click)="updateInstallConfig(currentApp)"
data-target="#install-modal">安装 data-target="#install-modal">安装
</button> </button>
<button type="button" class="btn btn-secondary">导入</button> <button type="button" class="btn btn-secondary">导入</button>
...@@ -73,58 +73,53 @@ ...@@ -73,58 +73,53 @@
<br> <br>
</div>--> </div>-->
<div *ngIf="mods && mods.length">
<h2>Mods</h2> <div *ngIf="currentApp.isInstalled()">
<h2>本地文件</h2>
<button (click)="appsService.browse(currentApp)" type="button" class="btn btn-secondary">浏览本地文件</button>
<button type="button" class="btn btn-secondary">校验完整性</button>
<button (click)="uninstall(currentApp)" type="button" class="btn btn-secondary">
{{'uninstall'|translate}}
</button>
<div *ngIf="mods">
<h2>{{'mods'|translate}}</h2>
<table class="table table-striped"> <table class="table table-striped">
<thead class="thead-inverse"> <thead class="thead-inverse">
<tr> <tr>
<th>#</th> <th>#</th>
<th>名称</th> <th>名称</th>
<th>类型</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let mod of mods; let i = index"> <tr *ngFor="let mod of mods; let i = index">
<th scope="row">{{i + 1}}</th> <th scope="row">{{i + 1}}</th>
<td>{{'app.' + mod.id + '.name' | translate}}</td> <td>{{mod.name}}</td>
<td>{{mod.type}}</td> <td *ngIf="mod.isInstalled()">
<td *ngIf="checkInstall(mod.id)"> <button type="button" (click)="uninstall(mod)" class="btn btn-danger btn-sm">卸载</button>
<button type="button" class="btn btn-danger btn-sm">卸载</button>
</td> </td>
<td *ngIf="!checkInstall(mod.id)"> <td *ngIf="!mod.isInstalled()">
<button *ngIf="!appsService.getDownloadInfo(mod.id)" (click)="install(mod.id)" type="button" <button (click)="installMod(mod)" type="button" *ngIf="mod.status.status==='init'"
class="btn btn-primary btn-sm">安装 class="btn btn-primary btn-sm">安装
</button> </button>
<progress <progress *ngIf="mod.status.status==='downloading'"
*ngIf="appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'active'"
class="progress progress-striped progress-animated" class="progress progress-striped progress-animated"
value="{{appsService.getDownloadInfo(mod.id).progress}}" max="100"></progress> value="{{mod.status.progress}}" max="{{mod.status.total}}"></progress>
<div *ngIf="appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'wait'"> <div *ngIf="mod.status.status==='waiting'">
等待安装... 等待安装...
</div> </div>
<div *ngIf="appsService.getDownloadInfo(mod.id) && appsService.getDownloadInfo(mod.id).status === 'install'">
正在安装...
</div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div *ngIf="currentApp.isInstalled()">
<h2>本地文件</h2>
<button (click)="appsService.browse(currentApp)" type="button" class="btn btn-secondary">浏览本地文件</button>
<button type="button" class="btn btn-secondary">校验完整性</button>
<button (click)="uninstall(currentApp)" type="button" class="btn btn-secondary">
{{'uninstall'|translate}}
</button>
</div> </div>
<div class="modal fade" id="install-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" <div class="modal fade" id="install-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
*ngIf="installConfig"> *ngIf="installConfig">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<form id="install-form" class="modal-content" (ngSubmit)="install()" #theForm="ngForm"> <form id="install-form" class="modal-content" (ngSubmit)="install(currentApp)" #theForm="ngForm">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
......
...@@ -32,11 +32,11 @@ export class AppDetailComponent implements OnInit { ...@@ -32,11 +32,11 @@ export class AppDetailComponent implements OnInit {
ngOnInit() { ngOnInit() {
} }
updateInstallConfig() { updateInstallConfig(app: App) {
this.installConfig = new InstallConfig(this.currentApp); this.installConfig = new InstallConfig(app);
this.installConfig.installLibrary = this.settingsService.getDefaultLibrary().path; this.installConfig.installLibrary = this.settingsService.getDefaultLibrary().path;
this.installConfig.references = []; this.installConfig.references = [];
for (let reference of this.currentApp.references.values()) { for (let reference of app.references.values()) {
this.installConfig.references.push(new InstallConfig(reference)) this.installConfig.references.push(new InstallConfig(reference))
} }
} }
...@@ -49,58 +49,33 @@ export class AppDetailComponent implements OnInit { ...@@ -49,58 +49,33 @@ export class AppDetailComponent implements OnInit {
return this.currentApp.news; return this.currentApp.news;
} }
get mods() { get mods(): App[] {
// let contains = ["optional", "language", "emulator"]; return this.appsService.findChildren(this.currentApp);
//
// let currentApp = this.appsService.currentApp;
// if (currentApp) {
// if (currentApp.references[process.platform] && currentApp.references[process.platform].length > 0) {
// let refs = currentApp.references[process.platform];
// refs = refs.filter((ref)=> {
// return contains.includes(ref.type);
// });
// refs = refs.map((ref)=> {
// let tmp = Object.create(ref);
// switch (tmp.type) {
// case "optional":
// tmp.type = "选项";
// break;
// case "language":
// tmp.type = "语言";
// break;
// default:
// break;
// }
// //console.log(tmp.type);
// return tmp;
// });
// return refs;
//return this.currentApp.references[process.platform];
// }
// }
return [];
} }
async installMod(mod: App) {
this.updateInstallConfig(mod);
await this.install(mod);
}
async uninstall(app: App) { async uninstall(app: App) {
if (confirm("确认删除?")) { if (confirm("确认删除?")) {
await this.installService.uninstall(app); await this.installService.uninstall(app);
this.currentApp.status.status = "init"; app.status.status = "init";
} }
} }
async install() { async install(targetApp: App) {
$('#install-modal').modal('hide'); $('#install-modal').modal('hide');
let currentApp = this.currentApp;
let options = this.installConfig; let options = this.installConfig;
let dependencies = currentApp.findDependencies(); let dependencies = targetApp.findDependencies();
let apps = dependencies.concat(currentApp).filter((app) => { let apps = dependencies.concat(targetApp).filter((app) => {
return !app.isInstalled() return !app.isInstalled()
}); });
if (options) {
for (let reference of options.references) { for (let reference of options.references) {
if (reference.install && !reference.app.isInstalled()) { if (reference.install && !reference.app.isInstalled()) {
apps.push(reference.app); apps.push(reference.app);
...@@ -109,11 +84,12 @@ export class AppDetailComponent implements OnInit { ...@@ -109,11 +84,12 @@ export class AppDetailComponent implements OnInit {
})) }))
} }
} }
}
let downloadPath = path.join(this.installConfig.installLibrary, "downloading"); let downloadPath = path.join(this.installConfig.installLibrary, "downloading");
try { try {
let downloadApps = await this.downloadService.addUris(apps, downloadPath); let downloadApps = await this.downloadService.addUris(apps, downloadPath);
for(let app of apps) { for (let app of apps) {
this.downloadService.getProgress(app) this.downloadService.getProgress(app)
.subscribe((progress) => { .subscribe((progress) => {
app.status.status = "downloading"; app.status.status = "downloading";
...@@ -138,18 +114,18 @@ export class AppDetailComponent implements OnInit { ...@@ -138,18 +114,18 @@ export class AppDetailComponent implements OnInit {
return this.installService.add(completeApp, options); return this.installService.add(completeApp, options);
}); });
})); }));
for(let app of apps){ for (let app of apps) {
new Promise(async (resolve,reject)=>{ new Promise(async(resolve, reject) => {
await this.installService.getComplete(app); await this.installService.getComplete(app);
app.status.status='ready'; app.status.status = 'ready';
resolve(); resolve();
}) })
} }
await this.installService.getComplete(currentApp); await this.installService.getComplete(targetApp);
currentApp.status.status = "ready"; targetApp.status.status = "ready";
this.ref.detectChanges(); this.ref.detectChanges();
} catch (e) { } catch (e) {
new Notification(currentApp.name, {body: "下载失败"}); new Notification(targetApp.name, {body: "下载失败"});
} }
} }
......
...@@ -99,4 +99,5 @@ export class App { ...@@ -99,4 +99,5 @@ export class App {
} }
return []; return [];
} }
} }
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"cancel": "取消", "cancel": "取消",
"install": "安装", "install": "安装",
"uninstall": "卸载", "uninstall": "卸载",
"mods":"附加模块",
"general": "常规", "general": "常规",
"updates": "更新", "updates": "更新",
"local files": "本地文件", "local files": "本地文件",
......
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