File

default-subscriptions/default-subscriptions.component.ts

Description

The component shows the main view for managing default subscriptions configuration.

Metadata

selector c8y-default-subscriptions
templateUrl ./default-subscriptions.component.html

Index

Properties
Methods

Constructor

constructor(fb: FormBuilder, defaultSubscriptionsService: DefaultSubscriptionsService, alertService: AlertService)
Parameters :
Name Type Optional
fb FormBuilder No
defaultSubscriptionsService DefaultSubscriptionsService No
alertService AlertService No

Methods

Async initForm
initForm()

Loads the list of apps, builds the form and hooks value change events for override switches.

Returns : any
isEmptyView
isEmptyView()

Checks if there are no application rows to be displayed.

Returns : boolean
isSubscribed
isSubscribed(app: IApplication, subscribedApps: PartialAppsList)

Checks if given application is subscribed (present in the given list of applications).

Parameters :
Name Type Optional Description
app IApplication No

Application object to check.

subscribedApps PartialAppsList No

The list of application objects to check against.

Returns : boolean

True, if the application is present in the list.

Async ngOnInit
ngOnInit()

Initializes the loading of the form and the current settings.

Returns : any
Async save
save()

Saves the current value of form object to backend.

Returns : any
shouldShowAppRow
shouldShowAppRow(appRowRawValue)

Checks if given application row should be displayed. The row is displayed when any of its checkboxes is selected or any of the lists is being overridden.

Parameters :
Name Optional
appRowRawValue No
Returns : boolean

Properties

currentDefaultSubscriptions
currentDefaultSubscriptions: DefaultSubscriptions
Type : DefaultSubscriptions

Default subscriptions defined in the current tenant.

form
form: FormGroup
Type : FormGroup

Form object.

loading
loading: boolean
Type : boolean

Whether the configuration is being loaded.

parentDefaultSubscriptions
parentDefaultSubscriptions: DefaultSubscriptions
Type : DefaultSubscriptions

Default subscriptions inherited from parent tenant.

<c8y-title>{{ 'Default subscriptions' | translate }}</c8y-title>

<form [formGroup]="form" (ngSubmit)="save()">
  <div class="card card--fullpage">
    <div class="card-header separator">
      <h4 class="card-title" translate>Default subscriptions</h4>
    </div>
    <div class="inner-scroll">
      <div class="card--grid grid__col--2-8-2--md grid__col--3-6-3">
        <div class="card-block large-padding bg-gray-white sticky-top separator-bottom p-b-0">
          <p><strong translate>Applications subscribed to a tenant on creation</strong></p>
          <div class="text-center">
            <label class="c8y-switch">
              <input type="checkbox" formControlName="overrideOnCreationSubscriptions" />
              <span></span> {{ 'Override inherited' | translate }}
            </label>
          </div>
        </div>
        <div class="card-block bg-white sticky-top separator-bottom">
          <p><b translate>Applications</b></p>
          <p translate>
            Configure default subscriptions in the platform, both for tenant creation and for platform upgrade. To display a full list of available applications, override inherited settings.
          </p>
        </div>
        <div class="card-block large-padding bg-gray-white sticky-top separator-bottom p-b-0">
          <p><strong translate>Applications subscribed to a tenant on platform upgrade</strong></p>
          <div class="text-center">
            <label class="c8y-switch">
              <input type="checkbox" formControlName="overrideOnUpgradeSubscriptions" />
              <span></span> {{ 'Override inherited' | translate }}
            </label>
          </div>
        </div>
        <div class="card-block bg-gray-white" *ngIf="loading"></div>
        <div class="card-block bg-white" *ngIf="loading">
          <div class="p-r-48 p-b-24 d-inline-block p-relative">
            <div class="spinner">
              <div class="rect1"></div>
              <div class="rect2"></div>
              <div class="rect3"></div>
              <div class="rect4"></div>
              <div class="rect5"></div>
            </div>
          </div>
          <span translate>Loading application subscriptions…</span>
        </div>
        <div class="card-block bg-gray-white" *ngIf="loading"></div>
        <ng-container formArrayName="appRows" class="d-contents">
          <div class="bg-gray-white" *ngIf="!loading && isEmptyView()"></div>
          <div class="card-block bg-white" *ngIf="!loading && isEmptyView()">
            <div class="c8y-empty-state">
              <h1 class="c8y-icon c8y-icon-c8y-data c8y-icon-duocolor"></h1>
              <h3 translate>No application subscriptions yet.</h3>
              <p translate>
                Select "Override inherited" to define the list of subscribed applications.
              </p>
            </div>
          </div>
          <div class="bg-gray-white" *ngIf="!loading && isEmptyView()"></div>

          <div
            *ngFor="let appRowControl of form.get('appRows')['controls']; let i = index"
            class="d-contents"
          >
            <ng-container
              *ngIf="shouldShowAppRow(appRowControl.getRawValue())"
              formArrayName="{{ i }}"
              class="d-contents"
            >
              <div class="c8y-list__item d-flex d-col bg-gray-white text-center">
                <div class="flex-item-middle">
                  <label
                    class="c8y-checkbox d-inline-block"
                    [ngClass]="{ disabled: appRowControl.controls.subscribedOnCreation.disabled }"
                  >
                    <input type="checkbox" formControlName="subscribedOnCreation" />
                    <span></span>
                  </label>
                </div>
              </div>

              <div class="c8y-list__item bg-white">
                <div class="c8y-list__item__block">
                  <div class="c8y-list__item__appicon">
                    <c8y-app-icon
                      [app]="appRowControl.value.app"
                      [name]="appRowControl.value.app.name"
                      [contextPath]="appRowControl.value.app.contextPath"
                    ></c8y-app-icon>
                  </div>
                  <div class="c8y-list__item__body">
                    <div class="content-flex-50">
                      <div class="col-6">
                        <p
                          class="text-truncate"
                          title="{{ appRowControl.value.app | humanizeAppName | async }}"
                        >
                          {{ appRowControl.value.app | humanizeAppName | async }}
                        </p>
                        <small class="text-muted">{{ appRowControl.value.app.contextPath }}</small>
                      </div>
                      <div class="col-6">
                        <p>
                          <span class="text-label-small m-r-4" translate>
                            Tenant ID
                          </span>
                          {{ appRowControl.value.app.owner.tenant.id }}
                        </p>
                        <!-- TODO: uncomment when company name is available
                          <p>
                          <span class="text-label-small m-r-4" translate>Company</span>
                          <small class="text-muted">company name</small>
                        </p> -->
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <div class="c8y-list__item d-flex d-col bg-gray-white text-center">
                <div class="flex-item-middle">
                  <label
                    class="c8y-checkbox d-inline-block"
                    [ngClass]="{ disabled: appRowControl.controls.subscribedOnUpgrade.disabled }"
                  >
                    <input type="checkbox" formControlName="subscribedOnUpgrade" />
                    <span></span>
                  </label>
                </div>
              </div>
            </ng-container>
          </div>
        </ng-container>
      </div>
    </div>
    <div class="card-footer separator">
      <button
        type="submit"
        class="btn btn-primary"
        [disabled]="form.invalid || form.pristine"
        title="{{ 'Save default subscriptions' | translate }}"
      >
        {{ 'Save' | translate }}
      </button>
    </div>
  </div>
</form>

result-matching ""

    No results matching ""