Browse Source

Refactor API key dialog components and styles.

pull/14074/head
deaflynx 11 months ago
parent
commit
fba08a3212
  1. 0
      ui-ngx/src/app/modules/home/components/api-key/add-api-key-dialog.component.html
  2. 0
      ui-ngx/src/app/modules/home/components/api-key/add-api-key-dialog.component.scss
  3. 2
      ui-ngx/src/app/modules/home/components/api-key/add-api-key-dialog.component.ts
  4. 0
      ui-ngx/src/app/modules/home/components/api-key/api-key-generated-dialog.component.html
  5. 10
      ui-ngx/src/app/modules/home/components/api-key/api-key-generated-dialog.component.scss
  6. 0
      ui-ngx/src/app/modules/home/components/api-key/api-key-generated-dialog.component.ts
  7. 46
      ui-ngx/src/app/modules/home/components/api-key/api-keys-table-config.ts
  8. 0
      ui-ngx/src/app/modules/home/components/api-key/api-keys-table-dialog.component.html
  9. 0
      ui-ngx/src/app/modules/home/components/api-key/api-keys-table-dialog.component.scss
  10. 0
      ui-ngx/src/app/modules/home/components/api-key/api-keys-table-dialog.component.ts
  11. 0
      ui-ngx/src/app/modules/home/components/api-key/edit-api-key-description-panel.component.html
  12. 0
      ui-ngx/src/app/modules/home/components/api-key/edit-api-key-description-panel.component.scss
  13. 0
      ui-ngx/src/app/modules/home/components/api-key/edit-api-key-description-panel.component.ts
  14. 14
      ui-ngx/src/app/modules/home/components/home-components.module.ts
  15. 5
      ui-ngx/src/app/modules/home/pages/security/security.component.ts

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/add-api-key-dialog.component.html → ui-ngx/src/app/modules/home/components/api-key/add-api-key-dialog.component.html

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/add-api-key-dialog.component.scss → ui-ngx/src/app/modules/home/components/api-key/add-api-key-dialog.component.scss

2
ui-ngx/src/app/modules/home/components/api-key/components/dialog/add-api-key-dialog.component.ts → ui-ngx/src/app/modules/home/components/api-key/add-api-key-dialog.component.ts

@ -25,7 +25,7 @@ import { FormBuilder, Validators } from '@angular/forms';
import { deepTrim } from '@core/utils'; import { deepTrim } from '@core/utils';
import { ApiKeyService } from '@core/http/api-key.service'; import { ApiKeyService } from '@core/http/api-key.service';
import { ApiKeyInfo } from '@shared/models/api-key.models'; import { ApiKeyInfo } from '@shared/models/api-key.models';
import { ApiKeysTableDialogData } from '@home/components/api-key/components/dialog/api-keys-table-dialog.component'; import { ApiKeysTableDialogData } from '@home/components/api-key/api-keys-table-dialog.component';
import { DAY } from '@shared/models/time/time.models'; import { DAY } from '@shared/models/time/time.models';
@Component({ @Component({

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/api-key-generated-dialog.component.html → ui-ngx/src/app/modules/home/components/api-key/api-key-generated-dialog.component.html

10
ui-ngx/src/app/modules/home/components/api-key/components/dialog/api-key-generated-dialog.component.scss → ui-ngx/src/app/modules/home/components/api-key/api-key-generated-dialog.component.scss

@ -13,6 +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.
*/ */
@import '../../src/scss/constants';
:host{ :host{
display: grid; display: grid;
width: 500px; width: 500px;
@ -34,8 +36,10 @@
pre[class*=language-] { pre[class*=language-] {
margin: 0; margin: 0;
background: #F3F6FA; background: #F3F6FA;
border-color: #305680; border-color: $tb-primary-color;
padding-right: 38px; padding-right: 38px;
overflow: hidden;
overflow-x: auto;
padding-bottom: 4px; padding-bottom: 4px;
min-height: 42px; min-height: 42px;
scrollbar-width: thin; scrollbar-width: thin;
@ -49,7 +53,7 @@
button.clipboard-btn { button.clipboard-btn {
right: -2px; right: -2px;
p { p {
color: #305680; color: $tb-primary-color;
} }
p, div { p, div {
background-color: #F3F6FA; background-color: #F3F6FA;
@ -64,7 +68,7 @@
display: block; display: block;
width: 18px; width: 18px;
height: 18px; height: 18px;
background: #305680; background: $tb-primary-color;
mask-image: url(/assets/copy-code-icon.svg); mask-image: url(/assets/copy-code-icon.svg);
-webkit-mask-image: url(/assets/copy-code-icon.svg); -webkit-mask-image: url(/assets/copy-code-icon.svg);
mask-repeat: no-repeat; mask-repeat: no-repeat;

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/api-key-generated-dialog.component.ts → ui-ngx/src/app/modules/home/components/api-key/api-key-generated-dialog.component.ts

46
ui-ngx/src/app/modules/home/components/api-key/api-keys-table-config.ts

@ -17,7 +17,8 @@
import { import {
DateEntityTableColumn, DateEntityTableColumn,
EntityTableColumn, EntityTableColumn,
EntityTableConfig EntityTableConfig,
CellActionDescriptor
} from '@home/models/entity/entities-table-config.models'; } from '@home/models/entity/entities-table-config.models';
import { EntityType, EntityTypeResource, entityTypeTranslations } from '@shared/models/entity-type.models'; import { EntityType, EntityTypeResource, entityTypeTranslations } from '@shared/models/entity-type.models';
import { Direction } from '@shared/models/page/sort-order'; import { Direction } from '@shared/models/page/sort-order';
@ -32,14 +33,13 @@ import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe';
import { TbPopoverService } from '@shared/components/popover.service'; import { TbPopoverService } from '@shared/components/popover.service';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { UserId } from '@shared/models/id/user-id'; import { UserId } from '@shared/models/id/user-id';
import { AddApiKeyDialogComponent } from '@home/components/api-key/components/dialog/add-api-key-dialog.component'; import { AddApiKeyDialogComponent } from '@home/components/api-key/add-api-key-dialog.component';
import { EditApiKeyDescriptionPanelComponent } from '@home/components/api-key/edit-api-key-description-panel.component';
import { ApiKeysTableDialogData } from '@home/components/api-key/api-keys-table-dialog.component';
import { import {
EditApiKeyDescriptionPanelComponent ApiKeyGeneratedDialogComponent,
} from '@home/components/api-key/components/dialog/edit-api-key-description-panel.component'; ApiKeyGeneratedDialogData
import { ApiKeysTableDialogData } from '@home/components/api-key/components/dialog/api-keys-table-dialog.component'; } from '@home/components/api-key/api-key-generated-dialog.component';
import {
ApiKeyGeneratedDialogComponent, ApiKeyGeneratedDialogData
} from '@home/components/api-key/components/dialog/api-key-generated-dialog.component';
@Injectable() @Injectable()
export class ApiKeysTableConfig extends EntityTableConfig<ApiKeyInfo> { export class ApiKeysTableConfig extends EntityTableConfig<ApiKeyInfo> {
@ -65,6 +65,7 @@ export class ApiKeysTableConfig extends EntityTableConfig<ApiKeyInfo> {
this.entityTranslations = entityTypeTranslations.get(EntityType.API_KEY); this.entityTranslations = entityTypeTranslations.get(EntityType.API_KEY);
this.entityResources = {} as EntityTypeResource<ApiKeyInfo>; this.entityResources = {} as EntityTypeResource<ApiKeyInfo>;
this.tableTitle = this.translate.instant('api-key.api-keys'); this.tableTitle = this.translate.instant('api-key.api-keys');
this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
this.entitiesFetchFunction = pageLink => this.apiKeyService.getUserApiKeys(this.userId.id, pageLink); this.entitiesFetchFunction = pageLink => this.apiKeyService.getUserApiKeys(this.userId.id, pageLink);
this.addEntity = () => this.addApiKey(); this.addEntity = () => this.addApiKey();
@ -75,18 +76,7 @@ export class ApiKeysTableConfig extends EntityTableConfig<ApiKeyInfo> {
this.deleteEntitiesContent = () => this.translate.instant('api-key.delete-api-keys-text'); this.deleteEntitiesContent = () => this.translate.instant('api-key.delete-api-keys-text');
this.deleteEntity = id => this.apiKeyService.deleteApiKey(id.id); this.deleteEntity = id => this.apiKeyService.deleteApiKey(id.id);
this.cellActionDescriptors = [{ this.cellActionDescriptors = this.configureCellActions();
name: '',
nameFunction: (entity) =>
this.translate.instant(entity.enabled ? 'api-key.disable' : 'api-key.enable'),
icon: 'mdi:toggle-switch',
isEnabled: (entity) => !entity.expired,
iconFunction: (entity) => entity.enabled ? 'mdi:toggle-switch' : 'mdi:toggle-switch-off-outline',
onAction: ($event, entity) => this.toggleEnableMode($event, entity)
}];
this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
this.columns.push( this.columns.push(
new DateEntityTableColumn<ApiKeyInfo>('createdTime', 'common.created-time', this.datePipe, '170px'), new DateEntityTableColumn<ApiKeyInfo>('createdTime', 'common.created-time', this.datePipe, '170px'),
new EntityTableColumn<ApiKeyInfo>('description', 'api-key.description', '100%', new EntityTableColumn<ApiKeyInfo>('description', 'api-key.description', '100%',
@ -108,6 +98,21 @@ export class ApiKeysTableConfig extends EntityTableConfig<ApiKeyInfo> {
); );
} }
private configureCellActions(): Array<CellActionDescriptor<ApiKeyInfo>> {
const actions: Array<CellActionDescriptor<ApiKeyInfo>> = [];
actions.push(
{
name: '',
nameFunction: (entity) => this.translate.instant(entity.enabled ? 'api-key.disable' : 'api-key.enable'),
icon: 'mdi:toggle-switch',
isEnabled: (entity) => !entity.expired,
iconFunction: (entity) => entity.enabled ? 'mdi:toggle-switch' : 'mdi:toggle-switch-off-outline',
onAction: ($event, entity) => this.toggleEnableMode($event, entity)
}
)
return actions;
}
private addApiKey(): Observable<ApiKey> { private addApiKey(): Observable<ApiKey> {
return this.dialog.open<AddApiKeyDialogComponent, ApiKeysTableDialogData, ApiKey>(AddApiKeyDialogComponent, { return this.dialog.open<AddApiKeyDialogComponent, ApiKeysTableDialogData, ApiKey>(AddApiKeyDialogComponent, {
disableClose: true, disableClose: true,
@ -137,7 +142,6 @@ export class ApiKeysTableConfig extends EntityTableConfig<ApiKeyInfo> {
}); });
} }
private toggleEnableMode($event: Event, entity: ApiKeyInfo): void { private toggleEnableMode($event: Event, entity: ApiKeyInfo): void {
if ($event) { if ($event) {
$event.stopPropagation(); $event.stopPropagation();

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/api-keys-table-dialog.component.html → ui-ngx/src/app/modules/home/components/api-key/api-keys-table-dialog.component.html

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/api-keys-table-dialog.component.scss → ui-ngx/src/app/modules/home/components/api-key/api-keys-table-dialog.component.scss

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/api-keys-table-dialog.component.ts → ui-ngx/src/app/modules/home/components/api-key/api-keys-table-dialog.component.ts

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/edit-api-key-description-panel.component.html → ui-ngx/src/app/modules/home/components/api-key/edit-api-key-description-panel.component.html

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/edit-api-key-description-panel.component.scss → ui-ngx/src/app/modules/home/components/api-key/edit-api-key-description-panel.component.scss

0
ui-ngx/src/app/modules/home/components/api-key/components/dialog/edit-api-key-description-panel.component.ts → ui-ngx/src/app/modules/home/components/api-key/edit-api-key-description-panel.component.ts

14
ui-ngx/src/app/modules/home/components/home-components.module.ts

@ -198,16 +198,10 @@ import { CalculatedFieldsModule } from '@home/components/calculated-fields/calcu
import { AlarmRuleModule } from "@home/components/alarm-rules/alarm-rule.module"; import { AlarmRuleModule } from "@home/components/alarm-rules/alarm-rule.module";
import { AlarmRulesTableComponent } from "@home/components/alarm-rules/alarm-rules-table.component"; import { AlarmRulesTableComponent } from "@home/components/alarm-rules/alarm-rules-table.component";
import { ApiKeysTableComponent } from '@home/components/api-key/api-keys-table.component'; import { ApiKeysTableComponent } from '@home/components/api-key/api-keys-table.component';
import { AddApiKeyDialogComponent } from '@home/components/api-key/components/dialog/add-api-key-dialog.component'; import { AddApiKeyDialogComponent } from '@home/components/api-key/add-api-key-dialog.component';
import { import { EditApiKeyDescriptionPanelComponent } from '@home/components/api-key/edit-api-key-description-panel.component';
EditApiKeyDescriptionPanelComponent import { ApiKeyGeneratedDialogComponent } from '@home/components/api-key/api-key-generated-dialog.component';
} from '@home/components/api-key/components/dialog/edit-api-key-description-panel.component'; import { ApiKeysTableDialogComponent } from '@home/components/api-key/api-keys-table-dialog.component';
import {
ApiKeyGeneratedDialogComponent
} from '@home/components/api-key/components/dialog/api-key-generated-dialog.component';
import {
ApiKeysTableDialogComponent
} from '@home/components/api-key/components/dialog/api-keys-table-dialog.component';
@NgModule({ @NgModule({
declarations: declarations:

5
ui-ngx/src/app/modules/home/pages/security/security.component.ts

@ -53,8 +53,9 @@ import { AuthService } from '@core/auth/auth.service';
import { UserPasswordPolicy } from '@shared/models/settings.models'; import { UserPasswordPolicy } from '@shared/models/settings.models';
import { MatCheckboxChange } from '@angular/material/checkbox'; import { MatCheckboxChange } from '@angular/material/checkbox';
import { import {
ApiKeysTableDialogComponent, ApiKeysTableDialogData ApiKeysTableDialogComponent,
} from '@home/components/api-key/components/dialog/api-keys-table-dialog.component'; ApiKeysTableDialogData
} from '@home/components/api-key/api-keys-table-dialog.component';
@Component({ @Component({
selector: 'tb-security', selector: 'tb-security',

Loading…
Cancel
Save