3 * Copyright (C) 2017 "IoT.bzh"
4 * Author Sebastien Douheret <sebastien@iot.bzh>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import { Component, Input, Pipe, PipeTransform } from '@angular/core';
20 import { SdkService, ISdk, StatusType } from '../../../@core-xds/services/sdk.service';
21 import { AlertService } from '../../../@core-xds/services/alert.service';
23 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
24 import { ConfirmModalComponent, EType } from '../../confirm/confirm-modal/confirm-modal.component';
27 selector: 'xds-sdk-card',
28 styleUrls: ['./sdk-card.component.scss'],
29 templateUrl: './sdk-card.component.html',
31 export class SdkCardComponent {
33 // FIXME workaround of https://github.com/angular/angular-cli/issues/2034
34 // should be removed with angular 5
35 // @Input() sdk: ISdk;
36 @Input() sdk = <ISdk>null;
39 private alert: AlertService,
40 private sdkSvr: SdkService,
41 private modalService: NgbModal,
45 canRemove(sdk: ISdk) {
46 return sdk.status === StatusType.INSTALLED;
50 const modal = this.modalService.open(ConfirmModalComponent, {
53 container: 'nb-layout',
55 modal.componentInstance.title = 'Confirm SDK deletion';
56 modal.componentInstance.type = EType.YesNo;
57 modal.componentInstance.question = `
58 Do you <b>permanently remove '` + sdk.name + `'</b> SDK ?
60 <i><small>(SDK ID: ` + sdk.id + ` )</small></i>`;
65 this.sdkSvr.remove(sdk).subscribe(
67 err => this.alert.error(err),