import-dialog-csv.component.html
7.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!--
Copyright © 2016-2024 The Thingsboard Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<form>
<mat-toolbar fxLayout="row" color="primary">
<h2 translate>{{ importTitle }}</h2>
<span fxFlex></span>
<div [tb-help]="'entitiesImport'"></div>
<button mat-icon-button
(click)="cancel()"
[disabled]="isImportData"
type="button">
<mat-icon class="material-icons">close</mat-icon>
</button>
</mat-toolbar>
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
</mat-progress-bar>
<div mat-dialog-content>
<mat-vertical-stepper [linear]="true" [selectedIndex]="selectedIndex" #importStepper>
<mat-step [stepControl]="selectFileFormGroup">
<form [formGroup]="selectFileFormGroup">
<ng-template matStepLabel>{{ 'import.stepper-text.select-file' | translate }}</ng-template>
<fieldset [disabled]="isLoading$ | async">
<tb-file-input formControlName="importData"
required
label="{{importFileLabel | translate}}"
[allowedExtensions]="'csv,txt'"
[accept]="'.csv,application/csv,text/csv,.txt,text/plain'"
dropLabel="{{'import.drop-file-csv-or' | translate}}">
</tb-file-input>
</fieldset>
</form>
<div fxLayout="row" fxLayoutAlign="end center" fxLayoutGap="20px">
<button mat-button
[disabled]="(isLoading$ | async)"
(click)="cancel()">{{ 'action.cancel' | translate }}</button>
<button mat-raised-button
[disabled]="(isLoading$ | async) || selectFileFormGroup.invalid || !selectFileFormGroup.dirty"
color="primary"
(click)="nextStep(2)">{{ 'action.continue' | translate }}</button>
</div>
</mat-step>
<mat-step [stepControl]="importParametersFormGroup">
<form [formGroup]="importParametersFormGroup">
<ng-template matStepLabel>{{ 'import.stepper-text.configuration' | translate }}</ng-template>
<fieldset [disabled]="isLoading$ | async" fxLayout="column">
<mat-form-field class="mat-block">
<mat-label translate>import.csv-delimiter</mat-label>
<mat-select required formControlName="delim">
<mat-option *ngFor="let delimiter of delimiters" [value]="delimiter.key">
{{ delimiter.value }}
</mat-option>
</mat-select>
</mat-form-field>
<div fxLayout="column" fxLayoutGap="12px">
<mat-checkbox formControlName="isHeader">
{{ 'import.csv-first-line-header' | translate }}
</mat-checkbox>
<mat-checkbox formControlName="isUpdate">
{{ 'import.csv-update-data' | translate }}
</mat-checkbox>
</div>
</fieldset>
</form>
<div fxLayout="row wrap" fxLayoutAlign="space-between center">
<button mat-button
[disabled]="(isLoading$ | async)"
(click)="previousStep()">{{ 'action.back' | translate }}</button>
<div fxLayout="row wrap" fxLayoutGap="20px">
<button mat-button
[disabled]="(isLoading$ | async)"
(click)="cancel()">{{ 'action.cancel' | translate }}</button>
<button mat-raised-button
[disabled]="(isLoading$ | async)"
color="primary"
(click)="nextStep(3)">{{ 'action.continue' | translate }}</button>
</div>
</div>
</mat-step>
<mat-step [stepControl]="columnTypesFormGroup">
<form [formGroup]="columnTypesFormGroup">
<ng-template matStepLabel>{{ 'import.stepper-text.column-type' | translate }}</ng-template>
<tb-table-columns-assignment #columnsAssignmentComponent formControlName="columnsParam" [entityType]="entityType"></tb-table-columns-assignment>
</form>
<div fxLayout="row wrap" fxLayoutAlign="space-between center">
<button mat-button
[disabled]="(isLoading$ | async)"
(click)="previousStep()">{{ 'action.back' | translate }}</button>
<div fxLayout="row wrap" fxLayoutGap="20px">
<button mat-button
[disabled]="(isLoading$ | async)"
(click)="cancel()">{{ 'action.cancel' | translate }}</button>
<button mat-raised-button
[disabled]="(isLoading$ | async) || columnTypesFormGroup.invalid || !columnTypesFormGroup.dirty"
color="primary"
(click)="nextStep(4)">{{ 'action.continue' | translate }}</button>
</div>
</div>
</mat-step>
<mat-step>
<ng-template matStepLabel>{{ 'import.stepper-text.creat-entities' | translate }}</ng-template>
<mat-progress-bar color="warn" class="tb-import-progress" mode="indeterminate">
</mat-progress-bar>
</mat-step>
<mat-step>
<ng-template matStepLabel>{{ 'action.done' | translate }}</ng-template>
<div fxLayout="column">
<p class="mat-body-2" *ngIf="this.statistical?.created">
{{ translate.instant('import.message.create-entities', {count: this.statistical.created}) }}
</p>
<p class="mat-body-2" *ngIf="this.statistical?.updated">
{{ translate.instant('import.message.update-entities', {count: this.statistical.updated}) }}
</p>
<p class="mat-body-2" style="margin-bottom: 0.8em" *ngIf="this.statistical?.errors">
{{ translate.instant('import.message.error-entities', {count: this.statistical.errors}) }}
</p>
<mat-expansion-panel class="advanced-logs" [expanded]="false"
*ngIf="this.statistical?.errorsList?.length"
(opened)="initEditor()">
<mat-expansion-panel-header [collapsedHeight]="'38px'" [expandedHeight]="'38px'">
<mat-panel-title>
<div class="tb-small" translate>import.details</div>
</mat-panel-title>
</mat-expansion-panel-header>
<mat-divider></mat-divider>
<div #failureDetailsEditor class="tb-failure-details"></div>
</mat-expansion-panel>
</div>
<div fxLayout="row" fxLayoutAlign="end center" fxLayoutGap="20px">
<button mat-raised-button
[disabled]="(isLoading$ | async)"
color="primary"
(click)="nextStep(6)">{{ 'action.ok' | translate }}</button>
</div>
</mat-step>
</mat-vertical-stepper>
</div>
</form>