Browse Source

Merge branch 'fix/send-email-uplink-43' into fix/send-email-uplink-44

pull/16143/head
Nikita Mazurenko 2 months ago
parent
commit
64eded8044
  1. 9
      ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts
  2. 12
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts
  3. 40
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss
  4. 3
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html
  5. 15
      ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts

9
ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts

@ -95,6 +95,12 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
wizardSteps: WizardStep[] = []; wizardSteps: WizardStep[] = [];
wizardStarted = false; wizardStarted = false;
reviewMode = false; reviewMode = false;
/**
* Set once the server has an installed item for this device. From that moment every way out of
* the wizard — including the header X and the Cancel button on a still-pending later step —
* has to report 'installed', or the caller keeps showing pre-install counts and badges.
*/
private installRegistered = false;
// Variable resolution state // Variable resolution state
formValues: Record<string, any> = {}; formValues: Record<string, any> = {};
@ -357,7 +363,7 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
} }
cancel(): void { cancel(): void {
this.dialogRef.close(false); this.dialogRef.close(this.installRegistered ? 'installed' : false);
} }
retryEntitySteps(step: WizardStep): void { retryEntitySteps(step: WizardStep): void {
@ -809,6 +815,7 @@ export class TbDeviceInstallDialogComponent extends DialogComponent<TbDeviceInst
{ ignoreLoading: true } { ignoreLoading: true }
) )
); );
this.installRegistered = true;
} catch (_e) { } catch (_e) {
// Non-critical — entities are created, tracking registration failed // Non-critical — entities are created, tracking registration failed
console.error('Failed to register device install', _e); console.error('Failed to register device install', _e);

12
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts

@ -51,6 +51,11 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
@Input() mode: 'default' | 'add' = 'default'; @Input() mode: 'default' | 'add' = 'default';
@Input() fixedSubType: string; @Input() fixedSubType: string;
@Output() addItem = new EventEmitter<MpItemVersionView>(); @Output() addItem = new EventEmitter<MpItemVersionView>();
/**
* Fired whenever an install, update or delete changed what this tenant has installed, so a host
* page showing its own installed-items counter can refresh it instead of waiting for a reload.
*/
@Output() installedItemsChanged = new EventEmitter<void>();
@Input() set activeType(value: ItemType) { @Input() set activeType(value: ItemType) {
if (value && value !== this._activeType) { if (value && value !== this._activeType) {
const wasInit = !!this._activeType; const wasInit = !!this._activeType;
@ -627,7 +632,11 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
}); });
} }
private reloadInstalledItems(): void { /**
* Re-reads what is installed for the active type and announces the change. Public so a host page
* that opens the item detail dialog itself can refresh this grid through the same path.
*/
reloadInstalledItems(): void {
const config = {ignoreLoading: true}; const config = {ignoreLoading: true};
const pageLink = new PageLink(10000, 0); const pageLink = new PageLink(10000, 0);
if (this.activeType === ItemType.WIDGET) { if (this.activeType === ItemType.WIDGET) {
@ -643,6 +652,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
this.installedItemCounts = counts; this.installedItemCounts = counts;
}); });
} }
this.installedItemsChanged.emit();
} }
private loadFilterInfo(): void { private loadFilterInfo(): void {

40
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss

@ -3,6 +3,10 @@
$text-color: rgba(0,0,0,0.76); $text-color: rgba(0,0,0,0.76);
$link-color: #2a7dec; $link-color: #2a7dec;
$copy-button-color: #2a7dec; $copy-button-color: #2a7dec;
// Geometry of the copy icon chip, shared by the chip itself and by the space table
// cells reserve for it, so the two cannot drift apart.
$copy-icon-width: 38px;
$copy-icon-offset: 3px;
$code-block-border-color: rgba(42, 125, 236, .2); $code-block-border-color: rgba(42, 125, 236, .2);
$code-default-color: #212529; $code-default-color: #212529;
@ -169,10 +173,10 @@ $gallery-border-hover-color: #2a7dec;
div { div {
background-color: #fff; background-color: #fff;
position: absolute; position: absolute;
width: 38px; width: $copy-icon-width;
height: 28px; height: 28px;
top: 3px; top: $copy-icon-offset;
right: 3px; right: $copy-icon-offset;
padding: 8px 10px 0; padding: 8px 10px 0;
img { img {
@ -204,9 +208,30 @@ $gallery-border-hover-color: #2a7dec;
} }
th, td { th, td {
// Long unbreakable tokens (logins, e-mails, passwords) must never overflow their
// own column. `anywhere` also drops the cell min-content width down to a single
// character, so auto layout can always squeeze the table into the available
// width instead of overflowing (and getting clipped by `overflow: hidden`).
overflow-wrap: break-word; // fallback for engines without `anywhere`
overflow-wrap: anywhere;
// Text is not the only thing that can outgrow a column: a preformatted block keeps
// its whole line as min-content width, which auto layout cannot shrink, so the table
// would push past its container and get cut off by a host that hides horizontal
// overflow (iot-hub-item-detail-dialog's .dlg-body). Wrap it inside the cell instead.
// Prism sets `white-space: pre` on both the block and the code inside it, so both
// have to be relaxed for the cell to shrink.
pre, pre > code {
white-space: pre-wrap;
}
div.code-wrapper { div.code-wrapper {
display: inline-block; display: inline-block;
width: 100%; width: 100%;
// Reserve room for the absolutely positioned copy icon, plus the same gap on its
// far side, so the cell text does not run underneath it and the reservation
// follows the chip if its geometry ever changes.
padding-right: $copy-icon-width + 2 * $copy-icon-offset;
button.clipboard-btn { button.clipboard-btn {
top: -6px; top: -6px;
@ -275,11 +300,10 @@ $gallery-border-hover-color: #2a7dec;
margin-top: 20px; margin-top: 20px;
margin-bottom: 20px; margin-bottom: 20px;
overflow: hidden; overflow: hidden;
table-layout: fixed; // Columns are sized to their content: with fixed layout every column got the
// same width, so cells with long values (e-mails, logins, tokens) had to wrap
&.auto { // mid-word while short columns kept a lot of unused space.
table-layout: auto; table-layout: auto;
}
> thead { > thead {
background-color: $table-header-background-color; background-color: $table-header-background-color;

3
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html

@ -35,7 +35,8 @@
<!-- Browse component (without tabs) --> <!-- Browse component (without tabs) -->
<tb-iot-hub-browse <tb-iot-hub-browse
[activeType]="config.type" [activeType]="config.type"
[hideTabs]="true"> [hideTabs]="true"
(installedItemsChanged)="loadInstalledCount()">
</tb-iot-hub-browse> </tb-iot-hub-browse>
<!-- Become a Creator footer --> <!-- Become a Creator footer -->

15
ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts

@ -1,12 +1,13 @@
// SPDX-FileCopyrightText: Copyright The Thingsboard Authors // SPDX-FileCopyrightText: Copyright The Thingsboard Authors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import { Component, OnInit } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { ItemType } from '@shared/models/iot-hub/iot-hub-item.models'; import { ItemType } from '@shared/models/iot-hub/iot-hub-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service'; import { IotHubApiService } from '@core/http/iot-hub-api.service';
import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service'; import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service';
import { TbIotHubBrowseComponent } from '@home/components/iot-hub/iot-hub-browse.component';
import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models'; import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models'; import { MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
@ -83,6 +84,8 @@ export class TbIotHubItemsPageComponent implements OnInit {
config: ItemTypePageConfig; config: ItemTypePageConfig;
installedItemsCount = 0; installedItemsCount = 0;
@ViewChild(TbIotHubBrowseComponent) private browse: TbIotHubBrowseComponent;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private router: Router, private router: Router,
@ -109,7 +112,7 @@ export class TbIotHubItemsPageComponent implements OnInit {
window.open(this.iotHubApiService.baseUrl + '/signup', '_blank'); window.open(this.iotHubApiService.baseUrl + '/signup', '_blank');
} }
private loadInstalledCount(): void { loadInstalledCount(): void {
this.iotHubApiService.getInstalledItemsCount(this.config.type, { ignoreLoading: true }).subscribe(count => { this.iotHubApiService.getInstalledItemsCount(this.config.type, { ignoreLoading: true }).subscribe(count => {
this.installedItemsCount = count; this.installedItemsCount = count;
}); });
@ -147,7 +150,13 @@ export class TbIotHubItemsPageComponent implements OnInit {
'default', 'default',
true, true,
openItem.preview openItem.preview
).subscribe(); ).subscribe(result => {
// The deep-linked dialog is opened by this page rather than by the grid, so its outcome
// has to be fed back in by hand — the grid then refreshes and announces the new count.
if (result === 'installed' || result === 'updated' || result === 'deleted') {
this.browse?.reloadInstalledItems();
}
});
}); });
} }

Loading…
Cancel
Save