generated from maximegris/angular-electron
-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notice for IFTTT change of feature #175
- Loading branch information
Showing
3 changed files
with
75 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,53 @@ | ||
import {Component, Inject, OnInit} from '@angular/core'; | ||
import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap'; | ||
import {Device} from '../../types'; | ||
import {DeviceManagerService, DevModeService} from '../../core/services'; | ||
import {DeviceManagerService, DevModeStatus} from '../../core/services'; | ||
import {noop} from 'rxjs'; | ||
import {save as showSaveDialog} from '@tauri-apps/api/dialog' | ||
import {writeTextFile} from '@tauri-apps/api/fs'; | ||
import renewScriptTemplate from './renew-script.sh'; | ||
import Mustache from 'mustache'; | ||
|
||
@Component({ | ||
selector: 'app-renew-script', | ||
templateUrl: './renew-script.component.html', | ||
styleUrls: ['./renew-script.component.scss'] | ||
selector: 'app-renew-script', | ||
templateUrl: './renew-script.component.html', | ||
styleUrls: ['./renew-script.component.scss'] | ||
}) | ||
export class RenewScriptComponent implements OnInit { | ||
|
||
public renewScriptContent?: string; | ||
public devModeToken?: string; | ||
public renewScriptContent?: string; | ||
|
||
constructor( | ||
public modal: NgbActiveModal, | ||
private deviceManager: DeviceManagerService, | ||
private devMode: DevModeService, | ||
@Inject('device') public device: Device | ||
) { | ||
} | ||
constructor( | ||
public modal: NgbActiveModal, | ||
private deviceManager: DeviceManagerService, | ||
@Inject('device') public device: Device, | ||
@Inject('devMode') public devMode: DevModeStatus, | ||
) { | ||
} | ||
|
||
ngOnInit(): void { | ||
this.devMode.status(this.device).then(({token}) => this.devModeToken = token); | ||
this.deviceManager.readPrivKey(this.device).then(key => { | ||
this.renewScriptContent = Mustache.render(renewScriptTemplate, { | ||
device: this.device, | ||
keyContent: key.trim(), | ||
}, undefined, { | ||
escape: (v) => v, | ||
}); | ||
}); | ||
} | ||
ngOnInit(): void { | ||
this.deviceManager.readPrivKey(this.device).then(key => { | ||
this.renewScriptContent = Mustache.render(renewScriptTemplate, { | ||
device: this.device, | ||
keyContent: key.trim(), | ||
}, undefined, { | ||
escape: (v) => v, | ||
}); | ||
}); | ||
} | ||
|
||
async copyScript(content: string): Promise<void> { | ||
await navigator.clipboard.writeText(content); | ||
} | ||
async copyScript(content: string): Promise<void> { | ||
await navigator.clipboard.writeText(content); | ||
} | ||
|
||
saveScript(content: string): void { | ||
showSaveDialog({ | ||
defaultPath: `renew-devmode-${this.device.name}.sh` | ||
}).then(value => { | ||
if (!value) { | ||
return; | ||
} | ||
return writeTextFile(value, content); | ||
}).catch(noop); | ||
} | ||
saveScript(content: string): void { | ||
showSaveDialog({ | ||
defaultPath: `renew-devmode-${this.device.name}.sh` | ||
}).then(value => { | ||
if (!value) { | ||
return; | ||
} | ||
return writeTextFile(value, content); | ||
}).catch(noop); | ||
} | ||
} |