Commit 00440da2 authored by h3remi7's avatar h3remi7

add download (todo hide model)

parent c8512fac
......@@ -7,7 +7,10 @@
<button type="button" class="btn btn-secondary">正版代购</button>
</div>
<div *ngIf="appsService.getDownloadInfo(routingService.app)">
<progress *ngIf="appsService.getDownloadInfo(routingService.app).status === 'active'" class="progress progress-striped progress-animated" value="{{appsService.getDownloadInfo(mod.id).progress}}" max="100"></progress>
<progress *ngIf="appsService.getDownloadInfo(routingService.app).status === 'active'"
class="progress progress-striped progress-animated"
value="{{appsService.getDownloadInfo(routingService.app).progress}}" max="100">
</progress>
</div>
</div>
<div *ngIf="isInstalled">
......@@ -73,13 +76,14 @@
<!== DEBUG -->
<pre class="debug">
{{appsService.downloadsInfo | json}}
{{appsService.installConfig | json}}
</pre>
<!-- Modal -->
<div class="modal fade" id="install-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<form class="modal-content" (ngSubmit)="install()">
<form class="modal-content" (ngSubmit)="installSubmit(theForm)" #theForm="ngForm">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
......@@ -92,7 +96,7 @@
<h4>安装位置</h4>
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" placeholder="安装位置">
<input type="text" [(ngModel)]="appsService.installConfig.installDir" name="installDir" class="form-control" placeholder="安装位置">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">浏览</button>
</span>
......@@ -101,20 +105,20 @@
<h4>快捷方式</h4>
<div class="checkbox">
<label>
<input type="checkbox" (ngModel)="shortcut.application">
<input type="checkbox" [(ngModel)]="appsService.installConfig.shortcut.application" name="application">
创建应用程序快捷方式
</label>
</div>
<div class="checkbox">
<label>
<input type="checkbox" (ngModel)="shortcut.desktop">
<input type="checkbox" [(ngModel)]="appsService.installConfig.shortcut.desktop" name="desktop">
创建桌面快捷方式
</label>
</div>
<h4>附加内容</h4>
<div *ngFor="let mod of currentApp.references[platform]">
<label>
<input type="checkbox" [(ngModel)]="model" name="{{mod.id}}"
<input type="checkbox" [(ngModel)]="appsService.installConfig.mods[mod.id]" name="{{mod.id}}"
[disabled]="['dependency', 'runtime'].includes(mod.type)">
{{searchApp(mod.id).name[searchApp(mod.id).locales[0]]}}
</label>
......@@ -122,9 +126,10 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary">安装</button>
<button type="submit" [disabled]="!theForm.form.valid" class="btn btn-primary">安装</button>
</div>
<pre>{{model}}</pre>
<!--
-->
</form>
</div>
</div>
......@@ -108,11 +108,26 @@ export class AppDetailComponent {
let uri = this.searchApp(id).download;
if(uri) {
this.appsService.download(id, uri);
} else {
console.log("lost download uri!");
}
}
}
installSubmit(theForm) {
console.log(theForm);
this.install(this.routingService.app);
for(let mod in this.appsService.installConfig.mods) {
if(this.appsService.installConfig.mods[mod]) {
this.install(mod);
}
}
model;
//TODO tar file
}
}
......@@ -39,6 +39,9 @@ export class AppsComponent {
selectApp(id) {
this.routingService.app = id;
this.appsService.createInstllConfig(id);
}
}
......@@ -5,13 +5,15 @@ import {App} from "./app";
import {AppLocal} from "./app-local";
import {TranslateService} from "ng2-translate";
declare var process;
@Injectable()
export class AppsService {
constructor(private http: Http, private translate: TranslateService) {
let loop = setInterval(()=> {
this.aria2.tellActive().then((res)=> {
console.log('res:', res);
//console.log('res:', res);
if(res) {
res.map((v)=>{
let index = this.downloadsInfo.findIndex((info)=>{
......@@ -75,8 +77,8 @@ export class AppsService {
});
};
this._aria2.onmessage = (m)=> {
console.log('IN:', m);
console.log('download infoi:', this.downloadsInfo);
//console.log('IN:', m);
//console.log('download infoi:', this.downloadsInfo);
}
}
......@@ -136,11 +138,11 @@ export class AppsService {
}
download(id, uri) {
console.log(id);
console.log(uri);
//console.log(id);
//console.log(uri);
let tmp_gid;
let i = this.downloadsInfo.findIndex((v)=>{return v.id == id});
console.log(i);
//console.log(i);
if(this.downloadsInfo.findIndex((v)=>{return v.id == id}) !== -1) {
console.log("this app downloading")
......@@ -149,7 +151,7 @@ export class AppsService {
if (error) {
console.error(error);
}
console.log(gid);
//console.log(gid);
this.downloadsInfo.push({"id": id, "gid": gid, "status": "active", "progress": 0});
});
}
......@@ -165,7 +167,33 @@ export class AppsService {
});
return info;
}
installConfig;
createInstllConfig(id) {
let app = this.data.find((app)=>{return app.id == id;});
let platform = process.platform;
let mods = {};
if(app.references[platform]) {
app.references[platform].map((mod)=>{
mods[mod.id] = false;
});
}
let tmp = {
installDir: __dirname,
shortcut: {
desktop: false,
application: false
},
mods: mods
};
//console.log(tmp);
this.installConfig = tmp;
return tmp;
}
......
......@@ -23,7 +23,7 @@
"references": {
"darwin": [
{
"id": "th105",
"id": "th06",
"type": "optional"
},
{
......@@ -135,13 +135,13 @@
"locales": [
"zh-CN"
],
"download": "",
"download": "http://thief.mycard.moe/metalinks/th12.meta4",
"news": [],
"tags": [
"STG"
],
"local": {
"path": "/foo/bar",
"path": "",
"version": "10.3"
}
},
......@@ -170,7 +170,7 @@
"locales": [
"zh-CN"
],
"download": "",
"download": "http://thief.mycard.moe/metalinks/th11.meta4",
"news": [],
"tags": [
"STG"
......@@ -205,7 +205,7 @@
"locales": [
"zh-CN"
],
"download": "",
"download": "http://thief.mycard.moe/metalinks/th10.meta4",
"news": [
{
"title": "News Title",
......
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