Commit 170cda55 authored by ibuler's avatar ibuler

[Update] 支持修改终端字体大小

parent d200a5f3
...@@ -56,5 +56,7 @@ ...@@ -56,5 +56,7 @@
"connect": "连接", "connect": "连接",
"rdp resolution": "RDP分辨率", "rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率", "set rdp solution": "设置分辨率",
"select a solution": "选择分辨率" "select a solution": "选择分辨率",
"set font size": "设置字体大小",
"font size": "字体大小"
} }
...@@ -56,5 +56,7 @@ ...@@ -56,5 +56,7 @@
"connect": "连接", "connect": "连接",
"rdp resolution": "RDP分辨率", "rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率", "set rdp solution": "设置分辨率",
"select a solution": "选择分辨率" "select a solution": "选择分辨率",
"set font size": "设置字体大小",
"font size": "字体大小"
} }
...@@ -56,5 +56,7 @@ ...@@ -56,5 +56,7 @@
"connect": "连接", "connect": "连接",
"rdp resolution": "RDP分辨率", "rdp resolution": "RDP分辨率",
"set rdp solution": "设置分辨率", "set rdp solution": "设置分辨率",
"select a solution": "选择分辨率" "select a solution": "选择分辨率",
"set font size": "设置字体大小",
"font size": "字体大小"
} }
...@@ -26,7 +26,7 @@ import {MAT_LABEL_GLOBAL_OPTIONS} from '@angular/material'; ...@@ -26,7 +26,7 @@ import {MAT_LABEL_GLOBAL_OPTIONS} from '@angular/material';
import {Pipes} from './pipes/pipes'; import {Pipes} from './pipes/pipes';
import {PagesComponents} from './pages/pages.component'; import {PagesComponents} from './pages/pages.component';
import {ElementComponents} from './elements/elements.component'; import {ElementComponents} from './elements/elements.component';
import {ChangLanWarningDialogComponent, RDPSolutionDialogComponent} from './elements/nav/nav.component'; import {ChangLanWarningDialogComponent, RDPSolutionDialogComponent, FontSizeDialogComponent} from './elements/nav/nav.component';
import {DialogService, ElementDialogAlertComponent} from './elements/dialog/dialog.service'; import {DialogService, ElementDialogAlertComponent} from './elements/dialog/dialog.service';
import {PluginModules} from './plugins/plugins'; import {PluginModules} from './plugins/plugins';
import {TestPageComponent} from './test-page/test-page.component'; import {TestPageComponent} from './test-page/test-page.component';
...@@ -56,6 +56,7 @@ import {SftpComponent} from './elements/sftp/sftp.component'; ...@@ -56,6 +56,7 @@ import {SftpComponent} from './elements/sftp/sftp.component';
ElementDialogAlertComponent, ElementDialogAlertComponent,
ChangLanWarningDialogComponent, ChangLanWarningDialogComponent,
RDPSolutionDialogComponent, RDPSolutionDialogComponent,
FontSizeDialogComponent
], ],
bootstrap: [AppComponent], bootstrap: [AppComponent],
providers: [ providers: [
......
...@@ -14,7 +14,7 @@ import {ElementDialogAlertComponent} from './dialog/dialog.service'; ...@@ -14,7 +14,7 @@ import {ElementDialogAlertComponent} from './dialog/dialog.service';
import {ElementGuacamoleComponent} from './guacamole/guacamole.component'; import {ElementGuacamoleComponent} from './guacamole/guacamole.component';
import {ElementSshTermComponent} from './ssh-term/ssh-term.component'; import {ElementSshTermComponent} from './ssh-term/ssh-term.component';
import {AssetTreeDialogComponent, ElementAssetTreeComponent} from './asset-tree/asset-tree.component'; import {AssetTreeDialogComponent, ElementAssetTreeComponent} from './asset-tree/asset-tree.component';
import {RDPSolutionDialogComponent} from './nav/nav.component'; import {RDPSolutionDialogComponent, FontSizeDialogComponent} from './nav/nav.component';
export const ElementComponents = [ export const ElementComponents = [
ElementLeftbarComponent, ElementLeftbarComponent,
...@@ -33,5 +33,6 @@ export const ElementComponents = [ ...@@ -33,5 +33,6 @@ export const ElementComponents = [
ElementAssetTreeComponent, ElementAssetTreeComponent,
ElementSshTermComponent, ElementSshTermComponent,
AssetTreeDialogComponent, AssetTreeDialogComponent,
RDPSolutionDialogComponent RDPSolutionDialogComponent,
FontSizeDialogComponent
]; ];
<h1 mat-dialog-title>{{"Set font size"|trans}}</h1>
<mat-form-field>
<input matInput placeholder='{{"Font size"|trans}}' name="fontSize" type="number" min="5" max="60" [(ngModel)]="fontSize">
</mat-form-field>
<div style="float: right">
<button mat-raised-button (click)="onNoClick()">{{"Cancel"|trans}}</button>
<button mat-raised-button color="primary" [disabled]="!isValid()" (click)="onSubmit()">{{"Confirm"|trans}}</button>
</div>
...@@ -12,7 +12,6 @@ import {ControlComponent, NavList, View} from '../../pages/control/control/contr ...@@ -12,7 +12,6 @@ import {ControlComponent, NavList, View} from '../../pages/control/control/contr
import {DataStore, i18n} from '../../globals'; import {DataStore, i18n} from '../../globals';
import * as jQuery from 'jquery/dist/jquery.min.js'; import * as jQuery from 'jquery/dist/jquery.min.js';
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material'; import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material';
import {FormControl, Validators} from '@angular/forms';
declare let layer: any; declare let layer: any;
@Component({ @Component({
...@@ -34,7 +33,7 @@ export class ElementNavComponent implements OnInit { ...@@ -34,7 +33,7 @@ export class ElementNavComponent implements OnInit {
public _dialog: MatDialog, public _dialog: MatDialog,
private _localStorage: LocalStorageService) { private _localStorage: LocalStorageService) {
this._logger.log('nav.ts:NavComponent'); this._logger.log('nav.ts:NavComponent');
this.getnav(); this.getNav();
} }
ngOnInit() { ngOnInit() {
...@@ -126,6 +125,26 @@ export class ElementNavComponent implements OnInit { ...@@ -126,6 +125,26 @@ export class ElementNavComponent implements OnInit {
}); });
break; break;
} }
case 'SetFontSize': {
const dialog = this._dialog.open(
FontSizeDialogComponent,
{
height: '200px',
width: '300px',
data: {
title: 'Warning',
note: 'The page will be reload, can you acceptable?',
cancel: 'Cancel',
confirm: 'Confirm',
},
});
dialog.afterClosed().subscribe(result => {
if (result) {
console.log(result);
}
});
break;
}
case 'EnterLicense': { case 'EnterLicense': {
this.EnterLicense(); this.EnterLicense();
break; break;
...@@ -194,7 +213,7 @@ export class ElementNavComponent implements OnInit { ...@@ -194,7 +213,7 @@ export class ElementNavComponent implements OnInit {
}); });
} }
getnav() { getNav() {
DataStore.Nav = [{ DataStore.Nav = [{
'id': 'File', 'id': 'File',
'name': 'Server', 'name': 'Server',
...@@ -235,6 +254,11 @@ export class ElementNavComponent implements OnInit { ...@@ -235,6 +254,11 @@ export class ElementNavComponent implements OnInit {
'click': 'SetResolution', 'click': 'SetResolution',
'name': 'RDP Resolution' 'name': 'RDP Resolution'
}, },
{
'id': 'FontSize',
'click': 'SetFontSize',
'name': 'Font Size'
},
{ {
'id': 'SplitVertical', 'id': 'SplitVertical',
'href': '', 'href': '',
...@@ -390,3 +414,39 @@ export class RDPSolutionDialogComponent implements OnInit { ...@@ -390,3 +414,39 @@ export class RDPSolutionDialogComponent implements OnInit {
this.dialogRef.close(); this.dialogRef.close();
} }
} }
@Component({
selector: 'elements-font-size-dialog',
templateUrl: 'fontSizeDialog.html',
})
export class FontSizeDialogComponent implements OnInit {
fontSize: string;
solution: string;
cacheKey = 'fontSize';
constructor(public dialogRef: MatDialogRef<FontSizeDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
ngOnInit() {
this.fontSize = localStorage.getItem(this.cacheKey) || '14';
}
setFontSize(value: string) {
localStorage.setItem(this.cacheKey, value);
}
isValid() {
const size = parseInt(this.fontSize, 10);
return size > 5 && size < 60;
}
onSubmit() {
this.setFontSize(this.fontSize);
this.dialogRef.close();
}
onNoClick(): void {
this.dialogRef.close();
}
}
...@@ -26,9 +26,10 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit { ...@@ -26,9 +26,10 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit {
ngOnInit() { ngOnInit() {
this.secret = this._uuid.gen(); this.secret = this._uuid.gen();
const fontSize = localStorage.getItem('fontSize') || '14';
this.term = new Terminal({ this.term = new Terminal({
fontFamily: '"Consolas", "monospace"', fontFamily: 'monaco, Consolas, "Lucida Console", monospace',
fontSize: 16, fontSize: parseInt(fontSize, 10),
rightClickSelectsWord: true, rightClickSelectsWord: true,
theme: { theme: {
background: '#1f1b1b' background: '#1f1b1b'
......
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