Migration to AGL gerrit (update go import)
[src/xds/xds-agent.git] / webapp / src / app / pages / about / about-modal / about-modal.component.ts
1 /**
2 * @license
3 * Copyright (C) 2017-2018 "IoT.bzh"
4 * Author Sebastien Douheret <sebastien@iot.bzh>
5 *
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
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
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.
17 */
18
19 import { Component, OnInit } from '@angular/core';
20 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
21
22 import { XDSAgentService, IXDSVersions, IXDSVer } from '../../../@core-xds/services/xdsagent.service';
23
24
25 @Component({
26   selector: 'xds-about-modal',
27   template: `
28     <div class="modal-header">
29       <span>About <b>X</b>(cross) Development System</span>
30       <button class="close" aria-label="Close" (click)="closeModal()">
31         <span aria-hidden="true">&times;</span>
32       </button>
33     </div>
34
35     <div class="modal-body row">
36       <div class="col-12">
37         <label class="col-sm-4">Developed by IoT.bzh</label>
38         <span class="col-sm-8"><a href="http://iot.bzh/en/author" target="_blank">http://iot.bzh</a></span>
39       </div>
40       <div class="col-12">
41         <label class="col-sm-4">Powered by</label>
42         <span class="col-sm-8"><a href="https://github.com/akveo/ngx-admin" target="_blank">akveo/ngx-admin</a></span>
43       </div>
44
45       <br><br>
46
47       <div class="col-12">
48           <label class="col-sm-4">XDS Agent ID</label>
49           <span class="col-sm-8">{{agent?.id}}</span>
50       </div>
51       <div class="col-12">
52         <label class="col-sm-4">XDS Agent Version</label>
53         <span class="col-sm-8">{{agent?.version}}</span>
54       </div>
55       <div class="col-12">
56         <label class="col-sm-4">XDS Agent Sub-Version</label>
57         <span class="col-sm-8">{{agent?.gitTag}}</span>
58       </div>
59
60       <div class="col-12">
61         <label class="col-sm-4">XDS Server ID</label>
62         <span class="col-sm-8">{{server?.id}}</span>
63       </div>
64       <div class="col-12">
65         <label class="col-sm-4">XDS Server Version</label>
66         <span class="col-sm-8">{{server?.version}}</span>
67       </div>
68       <div class="col-12">
69         <label class="col-sm-4">XDS Server Sub-Version</label>
70         <span class="col-sm-8">{{server?.gitTag}}</span>
71       </div>
72
73     </div>
74   `,
75 })
76
77 export class AboutModalComponent implements OnInit {
78
79   agent: IXDSVer;
80   server: IXDSVer;
81
82   constructor(
83     private activeModal: NgbActiveModal,
84     private xdsSvr: XDSAgentService,
85   ) { }
86
87   ngOnInit() {
88     this.xdsSvr.getVersion().subscribe(v => {
89       this.agent = v.client;
90       if (v && v.servers.length > 0 && !v.servers[0].version.startsWith('Cannot retrieve')) {
91         this.server = v.servers[0];
92       }
93     });
94   }
95
96   closeModal() {
97     this.activeModal.close();
98   }
99 }