From 44da47950bdd75be57714158fd8a6d59c94460b5 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 2 May 2015 12:07:37 +1200 Subject: Add create device dialog --- web/DeviceView.js | 38 +++++++++++++++++++++++++------------- web/Strings.js | 7 ++++++- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/web/DeviceView.js b/web/DeviceView.js index c64a6031f..80e75cb2c 100644 --- a/web/DeviceView.js +++ b/web/DeviceView.js @@ -16,6 +16,7 @@ Ext.define('DeviceView', { extend: 'Ext.grid.Panel', + requires: [ 'DeviceDialog' ], xtype: 'device-view', title: Strings.device_title, @@ -23,24 +24,35 @@ Ext.define('DeviceView', { tbar: [{ text:'Add', handler: function() { - - var device = { - name: "AjaxTest", - uniqueId: "UniqueId" - }; - - Ext.Ajax.request({ - url: '/api/device/add', - jsonData: Ext.encode(device), - success: function() { - alert("success"); + var panel = this.up('panel'); + Ext.create('DeviceDialog', { + onUpdate: function() { + panel.store.reload(); } - }); + }).show(); } }, { text:'Edit' }, { - text:'Remove' + text:'Remove', + handler: function() { + Ext.Msg.show({ + title: Strings.device_dialog, + message: 'Remove device?', + buttons: Ext.Msg.YESNO, + buttonText: { + yes: Strings.dialog_delete, + no: Strings.dialog_cancel + }, + fn: function(btn) { + if (btn === 'yes') { + console.log('Yes pressed'); + } else if (btn === 'no') { + console.log('No pressed'); + } + } + }); + } }, { xtype: 'tbfill' }, { diff --git a/web/Strings.js b/web/Strings.js index b46c162a9..9c89f7fa0 100644 --- a/web/Strings.js +++ b/web/Strings.js @@ -24,12 +24,17 @@ Ext.define('Strings', { login_login: 'Login', login_failed: 'Incorrect email address or password.', + device_dialog: 'Device', device_title: 'Devices', device_name: 'Name', device_identifier: 'Identifier', report_title: 'Reports', - + + dialog_create: 'Create', + dialog_update: 'Update', + dialog_delete: 'Delete', + dialog_cancel: 'Cancel', map_title: 'Map' }); -- cgit v1.2.3