Browse Source

gateway Docker command mark 1

pull/7740/head
Maksym Dudnik 4 years ago
parent
commit
1917e15fac
  1. 15
      ui-ngx/src/app/modules/home/components/device/device-gateway-command.component.html
  2. 6
      ui-ngx/src/app/modules/home/components/device/device-gateway-command.component.ts
  3. 35
      ui-ngx/src/app/modules/home/components/gateway/gateway-list-table-config.ts
  4. 3
      ui-ngx/src/app/modules/home/components/gateway/gateway-list.component.ts
  5. 12
      ui-ngx/src/app/modules/home/pages/device/device.component.html

15
ui-ngx/src/app/modules/home/components/device/device-gateway-command.component.html

@ -15,13 +15,16 @@
limitations under the License.
-->
<div mat-dialog-content tb-toast toastTarget="dockerCommandDialogContent">
<mat-button-toggle-group [formControl]="selectedOSControll" aria-label="Favorite Color">
<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 mat-dialog-content tb-toast fxLayout="column" toastTarget="dockerCommandDialogContent">
<span style="padding-bottom: 15px;">In order to run ThingsBoard IoT gateway (<a [href]="helpLink" target="_blank">ThingsBoard IoT gateway</a>) in docker with credentials for this device you can use the following commands.</span>
<div fxFlex fxLayout="row" style="justify-content: space-between">
<mat-button-toggle-group [formControl]="selectedOSControll" aria-label="Favorite Color" style="width: max-content">
<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="tb-help" [tb-help]="helpLink"></div>
</div>
<div class="mat-content" fxLayout="column" *ngIf="selectedOSControll.value !== osTypes.windows">
<!-- <span translate>gateway.linux-macos</span>-->
<div fxLayout="row" fxLayoutAlign="start center">
<pre class="tb-highlight" fxFlex><code style="white-space: pre-wrap;">{{ linuxCode }}</code></pre>
<button mat-icon-button

6
ui-ngx/src/app/modules/home/components/device/device-gateway-command.component.ts

@ -24,6 +24,7 @@ import {AppState} from "@core/core.state";
import {TranslateService} from "@ngx-translate/core";
import {ActionNotificationShow} from "@core/notification/notification.actions";
import {DeviceService} from "@core/http/device.service";
import {helpBaseUrl} from "@shared/models/constants";
enum OsType {
linux = 'linux',
@ -49,6 +50,7 @@ export class DeviceGatewayCommandComponent implements OnInit {
windowsCode: string;
selectedOSControll: FormControl;
osTypes = OsType;
helpLink: string = helpBaseUrl + '/docs/iot-gateway/install/docker-installation/';
constructor(protected router: Router,
protected store: Store<AppState>,
@ -96,6 +98,10 @@ export class DeviceGatewayCommandComponent implements OnInit {
" --restart always thingsboard/tb-gateway";
}
goToDocumentationPage() {
window.open(this.helpLink, '_blank');
}
onDockerCodeCopied() {
this.store.dispatch(new ActionNotificationShow(
{

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

@ -34,14 +34,14 @@ import {
EntityTableColumn,
EntityTableConfig
} from '@home/models/entity/entities-table-config.models';
import {EntityTypeResource} from '@shared/models/entity-type.models';
import {EntityType, EntityTypeResource} from '@shared/models/entity-type.models';
import {TranslateService} from '@ngx-translate/core';
import {DatePipe} from '@angular/common';
import {Direction} from '@shared/models/page/sort-order';
import {MatDialog} from '@angular/material/dialog';
import {TimePageLink} from '@shared/models/page/page-link';
import {Observable} from 'rxjs';
import {PageData} from '@shared/models/page/page-data';
import {emptyPageData, PageData} from '@shared/models/page/page-data';
import {UtilsService} from '@core/services/utils.service';
import {DeviceService} from "@core/http/device.service";
import {AttributeService} from "@core/http/attribute.service";
@ -54,21 +54,19 @@ import {ActionNotificationShow} from "@core/notification/notification.actions";
import {Store} from "@ngrx/store";
import {AppState} from "@core/core.state";
import {map} from "rxjs/operators";
import {getCurrentAuthUser} from "@core/auth/auth.selectors";
import {Authority} from "@shared/models/authority.enum";
import {EntityService} from "@core/http/entity.service";
export class GatewayListTableConfig extends EntityTableConfig<Device, TimePageLink> {
private authUser = getCurrentAuthUser(this.store);
constructor(protected store: Store<AppState>,
private deviceService: DeviceService,
private attributeService: AttributeService,
private entityService: EntityService,
private datePipe: DatePipe,
private translate: TranslateService,
private utils: UtilsService,
private dialog: MatDialog,
updateOnInit = true,
pageMode = false) {
updateOnInit = true) {
super();
this.loadDataOnInit = updateOnInit;
this.tableTitle = 'Gateway list';
@ -77,7 +75,7 @@ export class GatewayListTableConfig extends EntityTableConfig<Device, TimePageLi
this.displayPagination = false;
this.detailsPanelEnabled = false;
this.selectionEnabled = false;
this.searchEnabled = true;
this.searchEnabled = false;
this.addEnabled = false;
this.entitiesDeleteEnabled = false;
this.actionsColumnTitle = '';
@ -87,7 +85,7 @@ export class GatewayListTableConfig extends EntityTableConfig<Device, TimePageLi
};
this.entityResources = {} as EntityTypeResource<Device>;
this.entitiesFetchFunction = pageLink => this.fetchGateways(pageLink);
this.entitiesFetchFunction = () => this.fetchGateways();
this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
@ -134,17 +132,14 @@ export class GatewayListTableConfig extends EntityTableConfig<Device, TimePageLi
})
}
fetchGateways(pageLink: TimePageLink): Observable<PageData<Device>> {
let request = this.deviceService.getTenantDevices(pageLink);
if (this.authUser.authority === Authority.CUSTOMER_USER) {
request = this.deviceService.getCustomerDeviceInfos(this.authUser.customerId, pageLink);
}
return request.pipe(
map(pageData => {
pageData.data = pageData.data.filter(device => device.additionalInfo?.gateway);
pageData.totalElements = pageData.data.length;
fetchGateways(): Observable<PageData<Device>> {
return this.entityService.getEntitiesByNameFilter(EntityType.DEVICE, "", -1).pipe(
map((array: Array<Device>) => {
const pageData = emptyPageData<Device>();
pageData.data = array.filter(device => device.additionalInfo?.gateway);
pageData.totalPages = 1;
pageData.totalElements = array.length;
return pageData;
})
);
}))
}
}

3
ui-ngx/src/app/modules/home/components/gateway/gateway-list.component.ts

@ -39,6 +39,7 @@ import {DatePipe} from "@angular/common";
import {MatDialog} from "@angular/material/dialog";
import {Store} from "@ngrx/store";
import {AppState} from "@core/core.state";
import {EntityService} from "@core/http/entity.service";
@Component({
selector: 'tb-gateway-list',
@ -56,6 +57,7 @@ export class GatewayListComponent implements OnInit {
private translate: TranslateService,
private datePipe: DatePipe,
private deviceService: DeviceService,
private entityService: EntityService,
private attributeService: AttributeService,
private dialog: MatDialog,
) {
@ -66,6 +68,7 @@ export class GatewayListComponent implements OnInit {
this.store,
this.deviceService,
this.attributeService,
this.entityService,
this.datePipe,
this.translate,
this.utils,

12
ui-ngx/src/app/modules/home/pages/device/device.component.html

@ -142,12 +142,14 @@
{{ 'device.overwrite-activity-time' | translate }}
</mat-checkbox>
</div>
<mat-form-field class="mat-block">
<mat-label translate>device.description</mat-label>
<textarea matInput formControlName="description" rows="2"></textarea>
</mat-form-field>
</div>
</fieldset>
<tb-gateway-command *ngIf="entity?.id?.id && entityForm.get('additionalInfo.gateway').value && !isEdit" [deviceId]="entity?.id?.id" ></tb-gateway-command>
<tb-gateway-command *ngIf="entity?.id?.id && entityForm.get('additionalInfo.gateway').value && !isEdit" [deviceId]="entity?.id?.id"></tb-gateway-command>
<div formGroupName="additionalInfo" fxLayout="column">
<mat-form-field class="mat-block" >
<mat-label translate>device.description</mat-label>
<textarea matInput formControlName="description" rows="2"></textarea>
</mat-form-field>
</div>
</form>
</div>

Loading…
Cancel
Save