From f80404c777c661c40215b7be9355a9ef3bc473c4 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Tue, 11 Mar 2014 22:04:10 +0800 Subject: [PATCH] create user on Portal, experimental --- htdocs/portal/assets/js/fsportal.js | 64 +++++++++++++++++++++++++++++ htdocs/portal/index.html | 17 +++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/htdocs/portal/assets/js/fsportal.js b/htdocs/portal/assets/js/fsportal.js index 32f36ae519..b2086652d1 100644 --- a/htdocs/portal/assets/js/fsportal.js +++ b/htdocs/portal/assets/js/fsportal.js @@ -41,6 +41,17 @@ var App = Ember.Application.create({ } }); +App.ApplicationRoute = Ember.Route.extend({ + setupController: function(controller) { + // alert("setupController"); + }, + actions: { + newUser: function() { + return Bootstrap.ModalManager.show('newUserForm'); + } + } +}); + App.CallsRoute = Ember.Route.extend({ setupController: function(controller) { // Set the IndexController's `title` @@ -196,6 +207,17 @@ App.UsersRoute = Ember.Route.extend({ } }); +App.newUserRoute = Ember.Route.extend({ + setupController: function(Controller) { + alert("auto_update_calls"); + }, + actions: { + show: function(controller) { + App.newUserController.show(); + } + } +}); + App.Router.map(function(){ this.route("calls"); this.route("channels"); @@ -218,6 +240,7 @@ App.Router.map(function(){ this.route("showLimits"); this.route("show"); this.route("users"); + this.route("newUser"); this.route("about", { path: "/about" }); }); @@ -243,6 +266,14 @@ App.Channel = Em.Object.extend({ }); +App.ApplicationController = Ember.ObjectController.extend({ + actions: { + newUser: function() { + alert("ApplicationController"); + } + } +}); + App.callsController = Ember.ArrayController.create({ content: [], init: function(){ @@ -714,6 +745,39 @@ App.usersController = Ember.ArrayController.create({ } }); + +App.UsersController = Ember.ObjectController.extend({ + xnewUserButtons: [ + {title: 'Submit', clicked: "submit"}, + {title: 'Cancel', clicked: "cancel", dismiss: 'modal'} + ], + + actions: { + //Submit the modal + submit: function() { + $.post("/txtapi/lua?create_user.lua%20" + $("#user_id").val(), { + data: "user_id=xxxx", + success: function() { }, + error: function(e) { } + }); + + // Bootstrap.NM.push('Successfully submitted modal', 'success'); + return Bootstrap.ModalManager.hide('newUserForm'); + }, + + //Cancel the modal, we don't need to hide the model manually because we set {..., dismiss: 'modal'} on the button meta data + cancel: function() { + Bootstrap.ModalManager.hide('newUserForm'); + return Bootstrap.NM.push('Modal was cancelled', 'info'); + }, + + //Show the modal + newUser: function() { + return Bootstrap.ModalManager.show('newUserForm'); + } + } +}); + // App.initialize(); var global_debug_event = false; var global_background_job = false; diff --git a/htdocs/portal/index.html b/htdocs/portal/index.html index 770f03d673..2c231b0b52 100644 --- a/htdocs/portal/index.html +++ b/htdocs/portal/index.html @@ -595,8 +595,23 @@
-