mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-15 23:41:55 +00:00
Implement separate deploy button
This commit is contained in:
parent
fcb48fa6fb
commit
c508f367d9
@ -9,7 +9,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div (keypress)="setButtonStateDirty(); resetAutoSaveCountdown()"
|
||||
<div (keypress)="setSaveButtonStateDirty(); setDeployButtonStateTodeploy(); resetAutoSaveCountdown()"
|
||||
ace-editor
|
||||
[(text)]="code"
|
||||
[mode]="language"
|
||||
@ -18,13 +18,25 @@
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="btn-group flex-wrap">
|
||||
<button type="submit"
|
||||
class="btn btn-secondary"
|
||||
(click)="sendCode(); deployCode()"
|
||||
[disabled]="deployButtonState === 'DEPLOYING'"
|
||||
[class.btn-success]="deployButtonState === 'DEPLOYED'"
|
||||
[class.btn-info]="deployButtonState === 'DEPLOYING'"
|
||||
[class.disabled]="deployButtonState === 'DEPLOYING'"
|
||||
><span *ngIf="deployButtonState === 'TODEPLOY'">Deploy</span>
|
||||
<span *ngIf="deployButtonState === 'DEPLOYED'">Deploy</span>
|
||||
<span *ngIf="deployButtonState === 'DEPLOYING'"><div class="loader"></div>Reloading app...</span></button>
|
||||
<button (click)="sendCode()"
|
||||
[disabled]="saveButtonState === 'SAVING'"
|
||||
type="submit"
|
||||
class="btn btn-secondary"
|
||||
[class.btn-success]="saveButtonState === 'SAVED'"
|
||||
[class.btn-info]="saveButtonState === 'SAVING'"
|
||||
[class.btn-warning]="saveButtonState === 'SAVING'"
|
||||
[class.disabled]="saveButtonState === 'SAVING'"
|
||||
><span *ngIf="saveButtonState === 'DIRTY'">Save</span>
|
||||
<span *ngIf="saveButtonState === 'SAVED'">Save</span>
|
||||
<span *ngIf="saveButtonState === 'SAVING'"><div class="loader"></div>Reloading app...</span></button>
|
||||
<span *ngIf="saveButtonState === 'SAVING'">Saving...</span></button>
|
||||
</div>
|
||||
|
@ -34,11 +34,12 @@ export class WebideComponent implements OnInit {
|
||||
theme = 'monokai';
|
||||
files: string[];
|
||||
saveButtonState = 'SAVED';
|
||||
deployButtonState = 'DEPLOYED';
|
||||
autosave = null;
|
||||
command_handlers = { 'reload': this.reloadHandler.bind(this),
|
||||
'read': this.readHandler.bind(this),
|
||||
'select': this.selectHandler.bind(this),
|
||||
'write': () => {}};
|
||||
command_handlers = {'reload': this.reloadHandler.bind(this),
|
||||
'read': this.readHandler.bind(this),
|
||||
'select': this.selectHandler.bind(this),
|
||||
'write': this.writeHandler.bind(this)};
|
||||
|
||||
constructor(private webSocketService: WebSocketService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
@ -49,7 +50,7 @@ export class WebideComponent implements OnInit {
|
||||
this.subscribeWS();
|
||||
this.requestCode();
|
||||
this.processManagerService.init();
|
||||
this.processManagerService.subscribeCallback('login', (event) => { this.setButtonStateSaved(); });
|
||||
this.processManagerService.subscribeCallback('login', (event) => { this.setDeployButtonStateDeployed(); });
|
||||
this.resetAutoSaveCountdown();
|
||||
}
|
||||
|
||||
@ -80,6 +81,10 @@ export class WebideComponent implements OnInit {
|
||||
this.saveButtonState = 'SAVED';
|
||||
}
|
||||
|
||||
writeHandler() {
|
||||
this.saveButtonState = 'SAVED';
|
||||
}
|
||||
|
||||
resetAutoSaveCountdown() {
|
||||
if (this.autosave) {
|
||||
clearInterval(this.autosave);
|
||||
@ -95,18 +100,28 @@ export class WebideComponent implements OnInit {
|
||||
this.requestCode();
|
||||
}
|
||||
|
||||
setButtonStateSaved() {
|
||||
this.saveButtonState = 'SAVED';
|
||||
}
|
||||
|
||||
setButtonStateDirty() {
|
||||
setSaveButtonStateDirty() {
|
||||
this.saveButtonState = 'DIRTY';
|
||||
}
|
||||
|
||||
sendCode() {
|
||||
this.sendCodeContents();
|
||||
this.saveButtonState = 'SAVING';
|
||||
setDeployButtonStateDeployed() {
|
||||
this.deployButtonState = 'DEPLOYED';
|
||||
}
|
||||
|
||||
setDeployButtonStateTodeploy() {
|
||||
this.deployButtonState = 'TODEPLOY';
|
||||
}
|
||||
|
||||
deployCode() {
|
||||
this.processManagerService.restartProcess('login');
|
||||
this.deployButtonState = 'DEPLOYING';
|
||||
}
|
||||
|
||||
sendCode() {
|
||||
if (this.saveButtonState === 'DIRTY') {
|
||||
this.sendCodeContents();
|
||||
this.saveButtonState = 'SAVING';
|
||||
}
|
||||
}
|
||||
|
||||
sendCodeIfDirty() {
|
||||
|
Loading…
Reference in New Issue
Block a user