Browse Source

gateway list modal window update

pull/7740/head
Maksym Dudnik 4 years ago
parent
commit
d4ae9329dc
  1. 4
      ui-ngx/proxy.conf.js
  2. 12
      ui-ngx/src/app/modules/home/components/gateway/gateway-command-dialog.component.html
  3. 30
      ui-ngx/src/app/modules/home/components/gateway/gateway-command-dialog.component.ts
  4. 5
      ui-ngx/src/app/modules/home/components/gateway/gateway-list-table-config.ts

4
ui-ngx/proxy.conf.js

@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
const forwardUrl = "https://thingsboard.cloud/"; const forwardUrl = "http://localhost:8080";
const wsForwardUrl = "wss://thingsboard.cloud/"; const wsForwardUrl = "ws://localhost:8080";
const ruleNodeUiforwardUrl = forwardUrl; const ruleNodeUiforwardUrl = forwardUrl;
const PROXY_CONFIG = { const PROXY_CONFIG = {

12
ui-ngx/src/app/modules/home/components/gateway/gateway-command-dialog.component.html

@ -44,8 +44,12 @@
</mat-progress-bar> </mat-progress-bar>
<div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div> <div style="height: 4px;" *ngIf="!(isLoading$ | async)"></div>
<div mat-dialog-content tb-toast toastTarget="dockerCommandDialogContent"> <div mat-dialog-content tb-toast toastTarget="dockerCommandDialogContent">
<div class="mat-content" fxLayout="column"> <mat-button-toggle-group [formControl]="selectedOSControll" aria-label="Favorite Color">
<span translate>gateway.linux-macos</span> <mat-button-toggle [value]="osTypes.windows"><span translate>gateway.windows </span></mat-button-toggle>
<mat-button-toggle [value]="osTypes.linux"><span translate>gateway.linux-macos </span></mat-button-toggle>
</mat-button-toggle-group>
<div class="mat-content" fxLayout="column" *ngIf="selectedOSControll.value !== osTypes.windows">
<!-- <span translate>gateway.linux-macos</span>-->
<div fxLayout="row" fxLayoutAlign="start center"> <div fxLayout="row" fxLayoutAlign="start center">
<pre class="tb-highlight" fxFlex><code style="white-space: pre-wrap;">{{ linuxCode }}</code></pre> <pre class="tb-highlight" fxFlex><code style="white-space: pre-wrap;">{{ linuxCode }}</code></pre>
<button mat-icon-button <button mat-icon-button
@ -58,7 +62,9 @@
<mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon> <mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon>
</button> </button>
</div> </div>
<span translate>gateway.windows</span> </div>
<div class="mat-content" fxLayout="column" *ngIf="selectedOSControll.value === osTypes.windows">
<!-- <span translate>gateway.windows</span>-->
<div fxLayout="row" fxLayoutAlign="start center"> <div fxLayout="row" fxLayoutAlign="start center">
<pre class="tb-highlight" fxFlex><code style="white-space: pre-wrap;">{{ windowsCode }}</code></pre> <pre class="tb-highlight" fxFlex><code style="white-space: pre-wrap;">{{ windowsCode }}</code></pre>
<button mat-icon-button <button mat-icon-button

30
ui-ngx/src/app/modules/home/components/gateway/gateway-command-dialog.component.ts

@ -38,12 +38,19 @@ import { DialogComponent } from '@app/shared/components/dialog.component';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import {Device, DeviceCredentials} from "@shared/models/device.models"; import {Device, DeviceCredentials} from "@shared/models/device.models";
import {ActionNotificationShow} from "@core/notification/notification.actions"; import {ActionNotificationShow} from "@core/notification/notification.actions";
import {FormControl} from "@angular/forms";
export interface GatewayCommandDialogData { export interface GatewayCommandDialogData {
device: Device, device: Device,
credentials: DeviceCredentials credentials: DeviceCredentials
} }
enum OsType {
linux = 'linux',
macos = 'macos',
windows = 'win'
}
@Component({ @Component({
selector: 'tb-gateway-command-dialog', selector: 'tb-gateway-command-dialog',
templateUrl: './gateway-command-dialog.component.html', templateUrl: './gateway-command-dialog.component.html',
@ -52,6 +59,8 @@ export interface GatewayCommandDialogData {
export class GatewayCommandDialogComponent extends DialogComponent<GatewayCommandDialogComponent> implements OnInit { export class GatewayCommandDialogComponent extends DialogComponent<GatewayCommandDialogComponent> implements OnInit {
linuxCode: string; linuxCode: string;
windowsCode: string; windowsCode: string;
selectedOSControll: FormControl;
osTypes = OsType;
constructor(protected router: Router, constructor(protected router: Router,
protected store: Store<AppState>, protected store: Store<AppState>,
@ -60,13 +69,30 @@ export class GatewayCommandDialogComponent extends DialogComponent<GatewayComman
public dialogRef: MatDialogRef<GatewayCommandDialogComponent, boolean>,) { public dialogRef: MatDialogRef<GatewayCommandDialogComponent, boolean>,) {
super(store, router, dialogRef); super(store, router, dialogRef);
const ACCESS_TOKEN = data.credentials.credentialsId; const ACCESS_TOKEN = data.credentials.credentialsId;
const HOST = window.location.hostname;
this.selectedOSControll = new FormControl('');
// @ts-ignore
const platform = window.navigator?.userAgentData?.platform || window.navigator.platform,
macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
if (macosPlatforms.indexOf(platform) !== -1) {
this.selectedOSControll.setValue(OsType.macos);
} else if (windowsPlatforms.indexOf(platform) !== -1) {
this.selectedOSControll.setValue(OsType.windows);
} else if (/Linux/.test(platform)) {
this.selectedOSControll.setValue(OsType.linux);
}
this.linuxCode = "docker run -it -v ~/.tb-gateway/logs:/thingsboard_gateway/logs -v " + this.linuxCode = "docker run -it -v ~/.tb-gateway/logs:/thingsboard_gateway/logs -v " +
"~/.tb-gateway/extensions:/thingsboard_gateway/extensions -v ~/.tb-gateway/config:/thingsboard_gateway/config --name tb-gateway -e accessToken=" + "~/.tb-gateway/extensions:/thingsboard_gateway/extensions -v ~/.tb-gateway/config:/thingsboard_gateway/config --name tb-gateway -e host=" +
HOST +
" accessToken=" +
ACCESS_TOKEN + ACCESS_TOKEN +
" --restart always thingsboard/tb-gateway"; " --restart always thingsboard/tb-gateway";
this.windowsCode = "docker run -it -v %HOMEPATH%/tb-gateway/config:/thingsboard_gateway/config -v " + this.windowsCode = "docker run -it -v %HOMEPATH%/tb-gateway/config:/thingsboard_gateway/config -v " +
"%HOMEPATH%/tb-gateway/extensions:/thingsboard_gateway/extensions -v %HOMEPATH%/tb-gateway/logs:/thingsboard_gateway/logs " + "%HOMEPATH%/tb-gateway/extensions:/thingsboard_gateway/extensions -v %HOMEPATH%/tb-gateway/logs:/thingsboard_gateway/logs " +
"--name tb-gateway -e host=thingsboard.cloud -p 1883 -e accessToken=" + "--name tb-gateway -e host=" +
HOST +
" -p 1883 -e accessToken=" +
ACCESS_TOKEN + ACCESS_TOKEN +
" --restart always thingsboard/tb-gateway"; " --restart always thingsboard/tb-gateway";

5
ui-ngx/src/app/modules/home/components/gateway/gateway-list-table-config.ts

@ -73,7 +73,8 @@ export class GatewayListTableConfig extends EntityTableConfig<Device, TimePageLi
this.loadDataOnInit = updateOnInit; this.loadDataOnInit = updateOnInit;
this.tableTitle = ''; this.tableTitle = '';
this.useTimePageLink = false; this.useTimePageLink = false;
this.pageMode = pageMode; this.pageMode = false;
this.displayPagination = false;
this.detailsPanelEnabled = false; this.detailsPanelEnabled = false;
this.selectionEnabled = false; this.selectionEnabled = false;
this.searchEnabled = true; this.searchEnabled = true;
@ -140,7 +141,7 @@ export class GatewayListTableConfig extends EntityTableConfig<Device, TimePageLi
} }
return request.pipe( return request.pipe(
map(pageData => { map(pageData => {
pageData.data = pageData.data.filter(device => device.additionalInfo.gateway); pageData.data = pageData.data.filter(device => device.additionalInfo?.gateway);
pageData.totalElements = pageData.data.length; pageData.totalElements = pageData.data.length;
return pageData; return pageData;
}) })

Loading…
Cancel
Save