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

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

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