File

src/app/resource/resource-node-viewer/resource-node-viewer.component.ts

Implements

OnInit

Metadata

Index

Properties
Methods

Constructor

constructor(route: ActivatedRoute, service: ResourceService, helper: HelperService)
Parameters :
Name Type Optional
route ActivatedRoute No
service ResourceService No
helper HelperService No

Methods

Protected loadResource
loadResource()
Returns : void
ngOnInit
ngOnInit()
Returns : void

Properties

clusterName
Type : string
isLoading
Default value : true
obj
Type : any
path
Type : string
resource
Type : Resource
resourceName
Type : string
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import * as _ from 'lodash';

import { Resource } from '../shared/resource.model';
import { HelperService } from '../../shared/helper.service';
import { ResourceService } from '../shared/resource.service';

@Component({
  selector: 'hi-resource-node-viewer',
  templateUrl: './resource-node-viewer.component.html',
  styleUrls: ['./resource-node-viewer.component.scss'],
})
export class ResourceNodeViewerComponent implements OnInit {
  isLoading = true;
  clusterName: string;
  resourceName: string;
  resource: Resource;
  path: string;
  obj: any;

  constructor(
    protected route: ActivatedRoute,
    protected service: ResourceService,
    protected helper: HelperService
  ) {}

  ngOnInit() {
    if (this.route.snapshot.data.path) {
      this.path = this.route.snapshot.data.path;
    }

    if (this.route.parent) {
      this.clusterName = this.route.parent.snapshot.params.cluster_name;
      this.resourceName = this.route.parent.snapshot.params.resource_name;

      this.loadResource();
    }
  }

  protected loadResource() {
    this.isLoading = true;
    this.service.get(this.clusterName, this.resourceName).subscribe(
      (resource) => {
        this.resource = resource;
        this.obj = _.get(this.resource, this.path);
      },
      (error) => this.helper.showError(error),
      () => (this.isLoading = false)
    );
  }
}
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements.  See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership.  The ASF licenses this file
  ~ to you 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.
  -->

<section>
  <hi-node-viewer [loadingIndicator]="isLoading" [obj]="obj"> </hi-node-viewer>
</section>

./resource-node-viewer.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""