Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 1 | /* |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the 'License'); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an 'AS IS' BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame] | 16 | import { Component, OnInit, OnDestroy, Inject } from '@angular/core'; |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 17 | import { HttpClient } from '@angular/common/http'; |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 18 | |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 19 | import { |
| 20 | FnService, |
| 21 | IconService, |
| 22 | LionService, |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 23 | LogService, |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 24 | TableBaseImpl, TableResponse, SortDir, |
Sean Condon | 5ca0026 | 2018-09-06 17:55:25 +0100 | [diff] [blame] | 25 | UrlFnService, |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 26 | WebSocketService |
Sean Condon | 3dd062f | 2020-04-14 09:25:00 +0100 | [diff] [blame] | 27 | } from 'org_onosproject_onos/web/gui2-fw-lib/public_api'; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 28 | |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 29 | const INSTALLED = 'INSTALLED'; |
| 30 | const ACTIVE = 'ACTIVE'; |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 31 | const APPMGMTREQ = 'appManagementRequest'; |
| 32 | const DETAILSREQ = 'appDetailsRequest'; |
| 33 | const FILEUPLOADURL = 'upload'; |
| 34 | const FILEDOWNLOADURL = 'download'; |
| 35 | const ACTIVATEOPTION = '?activate=true'; |
| 36 | const DRAGDROPMSG1 = 'Drag and drop one file at a time'; |
| 37 | const DRAGDROPMSGEXT = 'Only files ending in .oar can be dropped'; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 38 | |
| 39 | /** Prefix to access the REST service for applications */ |
Sean Condon | 3c8e558 | 2018-08-28 23:22:43 +0100 | [diff] [blame] | 40 | export const APPURLPREFIX = 'rs/applications/'; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 41 | /** Suffix to access the icon of the application - gives back an image */ |
| 42 | export const ICONURLSUFFIX = '/icon'; |
| 43 | |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 44 | const downloadSuffix = '/download'; |
| 45 | const dialogId = 'app-dialog'; |
| 46 | const dialogOpts = { |
| 47 | edge: 'right', |
| 48 | width: 400, |
| 49 | }; |
| 50 | const strongWarning = { |
| 51 | 'org.onosproject.drivers': true, |
| 52 | }; |
| 53 | const propOrder = ['id', 'state', 'category', 'version', 'origin', 'role']; |
| 54 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 55 | /** |
| 56 | * Model of the data returned through the Web Socket about apps. |
| 57 | */ |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 58 | interface AppTableResponse extends TableResponse { |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 59 | apps: App[]; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 60 | } |
| 61 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 62 | /** |
| 63 | * Model of the data returned through Web Socket for a single App |
| 64 | */ |
| 65 | export interface App { |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 66 | category: string; |
| 67 | desc: string; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 68 | features: string[]; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 69 | icon: string; |
| 70 | id: string; |
| 71 | origin: string; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 72 | permissions: string[]; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 73 | readme: string; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 74 | required_apps: string[]; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 75 | role: string; |
| 76 | state: string; |
| 77 | title: string; |
| 78 | url: string; |
| 79 | version: string; |
| 80 | _iconid_state: string; |
| 81 | } |
| 82 | |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 83 | export enum AppAction { |
| 84 | NONE = 0, |
| 85 | ACTIVATE = 1, |
| 86 | DEACTIVATE = 2, |
| 87 | UNINSTALL = 3, |
| 88 | } |
| 89 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 90 | /** |
| 91 | * Model of the Control Button |
| 92 | */ |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 93 | interface CtrlBtnState { |
| 94 | installed: boolean; |
| 95 | selection: string; |
| 96 | active: boolean; |
| 97 | } |
| 98 | |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 99 | /** |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 100 | * ONOS GUI -- Apps View Component extends TableBaseImpl |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 101 | */ |
| 102 | @Component({ |
| 103 | selector: 'onos-apps', |
| 104 | templateUrl: './apps.component.html', |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 105 | styleUrls: [ |
| 106 | './apps.component.css', './apps.theme.css', |
Sean Condon | 98b6ddb | 2019-12-24 08:07:40 +0000 | [diff] [blame] | 107 | '../../../../../../../../gui2-fw-lib/lib/widget/table.css', '../../../../../../../../gui2-fw-lib/lib/widget/table.theme.css' |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 108 | ] |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 109 | }) |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 110 | export class AppsComponent extends TableBaseImpl implements OnInit, OnDestroy { |
| 111 | |
| 112 | // deferred localization strings |
| 113 | lionFn; // Function |
| 114 | warnDeactivate: string; |
| 115 | warnOwnRisk: string; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 116 | ctrlBtnState: CtrlBtnState; |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame] | 117 | appFile: any; |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame] | 118 | |
| 119 | uploadTip: string; |
| 120 | activateTip: string; |
| 121 | deactivateTip: string; |
| 122 | uninstallTip: string; |
| 123 | downloadTip: string; |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 124 | alertMsg: string; |
| 125 | AppActionEnum: any = AppAction; |
| 126 | appAction: AppAction = AppAction.NONE; |
| 127 | confirmMsg: string = ''; |
| 128 | strongWarning: string = ''; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 129 | |
| 130 | constructor( |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 131 | protected fs: FnService, |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 132 | private is: IconService, |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 133 | private lion: LionService, |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 134 | protected log: LogService, |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 135 | private ufs: UrlFnService, |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 136 | protected wss: WebSocketService, |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame] | 137 | @Inject('Window') private window: Window, |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 138 | private httpClient: HttpClient |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 139 | ) { |
Sean Condon | 95fb574 | 2019-04-02 12:16:55 +0100 | [diff] [blame] | 140 | super(fs, log, wss, 'app'); |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 141 | this.responseCallback = this.appResponseCb; |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 142 | this.parentSelCb = this.rowSelection; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 143 | // pre-populate sort so active apps are at the top of the list |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 144 | this.sortParams = { |
| 145 | firstCol: 'state', |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 146 | firstDir: SortDir.desc, |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 147 | secondCol: 'title', |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 148 | secondDir: SortDir.asc, |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 149 | }; |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 150 | // We want doLion() to be called only after the Lion |
| 151 | // service is populated (from the WebSocket) |
| 152 | // If lion is not ready we make do with a dummy function |
| 153 | // As soon a lion gets loaded this function will be replaced with |
| 154 | // the real thing |
| 155 | if (this.lion.ubercache.length === 0) { |
| 156 | this.lionFn = this.dummyLion; |
| 157 | this.lion.loadCbs.set('apps', () => this.doLion()); |
| 158 | } else { |
| 159 | this.doLion(); |
| 160 | } |
| 161 | |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 162 | this.ctrlBtnState = <CtrlBtnState>{ |
| 163 | installed: false, |
| 164 | active: false |
| 165 | }; |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 166 | } |
| 167 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 168 | /** |
| 169 | * Initialize querying the WebSocket for App table details |
| 170 | */ |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 171 | ngOnInit() { |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 172 | this.init(); |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 173 | } |
| 174 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 175 | /** |
| 176 | * Stop sending queries to WebSocket |
| 177 | */ |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 178 | ngOnDestroy() { |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 179 | this.lion.loadCbs.delete('apps'); |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 180 | this.destroy(); |
| 181 | this.log.debug('AppComponent destroyed'); |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * The callback called when App data returns from WSS |
| 186 | */ |
| 187 | appResponseCb(data: AppTableResponse) { |
| 188 | this.log.debug('App response received for ', data.apps.length, 'apps'); |
| 189 | } |
| 190 | |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 191 | /** |
| 192 | * called when a row is selected - sets the state of control icons |
| 193 | */ |
| 194 | rowSelection(event: any, selRow: any) { |
| 195 | this.ctrlBtnState.installed = this.selId && selRow && selRow.state === INSTALLED; |
| 196 | this.ctrlBtnState.active = this.selId && selRow && selRow.state === ACTIVE; |
| 197 | this.ctrlBtnState.selection = this.selId; |
| 198 | this.log.debug('Row ', this.selId, 'selected', this.ctrlBtnState); |
| 199 | } |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 200 | |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 201 | |
| 202 | /** |
| 203 | * Perform one of the app actions - activate, deactivate or uninstall |
| 204 | * Raises a dialog which calls back the dOk() below |
| 205 | */ |
| 206 | confirmAction(action: AppAction): void { |
| 207 | this.appAction = action; |
| 208 | const appActionLc = (<string>AppAction[this.appAction]).toLowerCase(); |
| 209 | |
| 210 | this.confirmMsg = this.lionFn(appActionLc) + ' ' + this.selId; |
| 211 | if (strongWarning[this.selId]) { |
| 212 | this.strongWarning = this.warnDeactivate + '\n' + this.warnOwnRisk; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 213 | } |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 214 | |
| 215 | this.log.debug('Initiating', this.appAction, 'of', this.selId); |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 216 | } |
| 217 | |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 218 | /** |
| 219 | * Callback when the Confirm dialog is shown and a choice is made |
| 220 | */ |
| 221 | dOk(choice: boolean) { |
| 222 | const appActionLc = (<string>AppAction[this.appAction]).toLowerCase(); |
| 223 | if (choice) { |
| 224 | this.log.debug('Confirmed', appActionLc, 'on', this.selId); |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 225 | |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 226 | this.wss.sendEvent(APPMGMTREQ, { |
| 227 | action: appActionLc, |
| 228 | name: this.selId, |
| 229 | sortCol: this.sortParams.firstCol, |
| 230 | sortDir: SortDir[this.sortParams.firstDir], |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 231 | }); |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 232 | if (this.appAction === AppAction.UNINSTALL) { |
| 233 | this.selId = ''; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 234 | } else { |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 235 | this.wss.sendEvent(DETAILSREQ, { id: this.selId }); |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 236 | } |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 237 | |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 238 | } else { |
| 239 | this.log.debug('Cancelled', appActionLc, 'on', this.selId); |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 240 | } |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 241 | this.confirmMsg = ''; |
| 242 | this.strongWarning = ''; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | downloadApp() { |
| 246 | if (this.ctrlBtnState.selection) { |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 247 | (<any>this.window).location = APPURLPREFIX + this.selId + '/' + FILEDOWNLOADURL; |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | |
| 251 | /** |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 252 | * When the file is selected this fires |
| 253 | * It passes the file on to the server through a POST request |
| 254 | * If there is an error its logged and raised to the user through Flash Component |
| 255 | */ |
| 256 | fileEvent(event: any, activateImmediately?: boolean) { |
| 257 | this.log.debug('File event for', event.target.files[0]); |
| 258 | const formData = new FormData(); |
| 259 | formData.append('file', event.target.files[0]); |
| 260 | let url = APPURLPREFIX + FILEUPLOADURL; |
| 261 | if (activateImmediately) { |
| 262 | url += ACTIVATEOPTION; |
| 263 | } |
| 264 | this.httpClient |
| 265 | .post<any>(APPURLPREFIX + FILEUPLOADURL, formData) |
| 266 | .subscribe( |
| 267 | data => this.log.debug(data), |
| 268 | err => { |
| 269 | this.log.warn(err.message); |
| 270 | this.alertMsg = err.message; // This will activate flash msg |
| 271 | } |
| 272 | ); |
| 273 | |
| 274 | } |
| 275 | |
| 276 | /** |
| 277 | * When the upload button is clicked pass this on to the file input (hidden) |
| 278 | */ |
| 279 | triggerForm() { |
| 280 | document.getElementById('uploadFile') |
| 281 | .dispatchEvent(new MouseEvent('click')); |
| 282 | } |
| 283 | |
| 284 | /** |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 285 | * Read the LION bundle for App and set up the lionFn |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 286 | */ |
| 287 | doLion() { |
| 288 | this.lionFn = this.lion.bundle('core.view.App'); |
| 289 | |
| 290 | this.warnDeactivate = this.lionFn('dlg_warn_deactivate'); |
| 291 | this.warnOwnRisk = this.lionFn('dlg_warn_own_risk'); |
| 292 | |
Sean Condon | 28ecc5f | 2018-06-25 12:50:16 +0100 | [diff] [blame] | 293 | this.uploadTip = this.lionFn('tt_ctl_upload'); |
| 294 | this.activateTip = this.lionFn('tt_ctl_activate'); |
| 295 | this.deactivateTip = this.lionFn('tt_ctl_deactivate'); |
| 296 | this.uninstallTip = this.lionFn('tt_ctl_uninstall'); |
| 297 | this.downloadTip = this.lionFn('tt_ctl_download'); |
Sean Condon | 2bd11b7 | 2018-06-15 08:00:48 +0100 | [diff] [blame] | 298 | } |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame] | 299 | |
Sean Condon | 2aa8609 | 2018-07-16 09:04:05 +0100 | [diff] [blame] | 300 | onDrop(event: DragEvent) { |
| 301 | event.preventDefault(); |
| 302 | event.stopPropagation(); |
| 303 | |
| 304 | const dt = event.dataTransfer; |
| 305 | const droppedFiles = dt.files; |
| 306 | |
| 307 | this.log.debug(droppedFiles.length, 'File(s) dropped'); |
| 308 | if (droppedFiles.length !== 1) { |
| 309 | this.log.error(DRAGDROPMSG1, droppedFiles.length, 'were dropped'); |
| 310 | this.alertMsg = DRAGDROPMSG1; |
| 311 | return; |
| 312 | } else if (droppedFiles[0].name.slice(droppedFiles[0].name.length - 4) !== '.oar') { |
| 313 | this.log.error(DRAGDROPMSGEXT, droppedFiles[0].name, 'rejected'); |
| 314 | this.alertMsg = DRAGDROPMSGEXT; |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | const fileEvent = { |
| 319 | target: { |
| 320 | files: droppedFiles |
| 321 | } |
| 322 | }; |
| 323 | this.fileEvent(fileEvent, true); |
| 324 | } |
| 325 | |
| 326 | onDragOver(evt) { |
| 327 | evt.preventDefault(); |
| 328 | evt.stopPropagation(); |
| 329 | } |
| 330 | |
| 331 | onDragLeave(evt) { |
| 332 | evt.preventDefault(); |
| 333 | evt.stopPropagation(); |
Sean Condon | a00bf38 | 2018-06-23 07:54:01 +0100 | [diff] [blame] | 334 | } |
Bhavesh | 72ead49 | 2018-07-19 16:29:18 +0530 | [diff] [blame] | 335 | |
| 336 | deselectRow(event) { |
| 337 | this.log.debug('Details panel close event'); |
| 338 | this.selId = event; |
| 339 | this.ctrlBtnState = <CtrlBtnState>{ |
| 340 | installed: undefined, |
| 341 | active: undefined |
| 342 | }; |
| 343 | } |
Sean Condon | c687ccb | 2019-10-25 12:27:54 +0100 | [diff] [blame] | 344 | |
| 345 | getStateAsClass(value: string) { |
| 346 | if (value === 'ACTIVE') { |
| 347 | return 'active'; |
| 348 | } else if (value === 'INSTALLED') { |
| 349 | return 'inactive'; |
| 350 | } |
| 351 | return ''; |
| 352 | } |
Sean Condon | 83fc39f | 2018-04-19 18:56:13 +0100 | [diff] [blame] | 353 | } |