2222 {
2323 <p >It 's time to create an application. "Application", in codeRR language, means an error reporting entity. </p>
2424 <p >
25- If you have a client / server based product named " l33tApp" you would typically create two applications in codeRR :
26-
25+ If you have a client / server based product named " l33tApp" you would typically create two applications in codeRR :
26+
2727 </p >
2828 <ul >
2929 <li >l33tApp Client </li >
3535 Specify the name of your first application , you 'll be able to add more applications later.
3636 </p >
3737 }
38- <form method =" post" >
38+ <form method =" post" id = " createMyAppForm " >
3939 <div class =" form-group" >
4040 <input type =" text" name =" Name" placeholder =" Application name" class =" form-control" />
4141 </div >
4242 <div class =" form-group" >
4343 <button type =" submit" class =" btn btn-primary" >Create</button >
44- <a href =" http://discuss.coderrapp.com" target =" _self" >Help</a > |
44+ <a href =" http://discuss.coderrapp.com" target =" _self" >Help</a > |
4545 <a href =" @Url.Content(" ~ /" )#/" >Exit wizard</a >
4646 </div >
4747 </form >
4848 </div >
4949 </div >
50- </div >
50+ </div >
51+
52+ @section scripts
53+ {
54+ <script >
55+ function createMyApplication (name , callback ) {
56+ var hostType = ' DesktopApplication' ;
57+
58+ var client = new Griffin.Net.HttpClient ();
59+ client .get (window .API_URL + ' /guid' )
60+ .done (function (response ) {
61+ var appKey = response .body ;
62+ var cmd = new codeRR.Core.Applications.Commands.CreateApplication (name, hostType);
63+ cmd .ApplicationKey = appKey;
64+ Griffin .Cqs .CqsClient .command (cmd)
65+ .done (function () {
66+ callback (appKey);
67+ })
68+ .fail (function (rejection ) {
69+ console .log (rejection .message );
70+ });
71+ });
72+ }
73+
74+ function checkForApplication (appKey , foundCallback , notFoundCallback ) {
75+ var query = new codeRR.Core.Applications.Queries.GetApplicationIdByKey (appKey);
76+ Griffin .Cqs .CqsClient .query (query)
77+ .done (function (result ) {
78+ console .log (result);
79+ if (result != null ) {
80+ foundCallback (result);
81+ } else {
82+ notFoundCallback ();
83+ }
84+
85+ // $('#appName').val('');
86+ // var appUrl = '#/application/' + result.Id + '/';
87+ // window.location = window.WEB_SITE + '/account/UpdateSession?returnUrl=' + encodeURIComponent(window.WEB_ROOT + appUrl);
88+ });
89+ }
90+
91+ var timer = null ;
92+ var attemptsLeft = 5 ;
93+ $ (' #createMyAppForm' ).submit (function (e ) {
94+ e .preventDefault ();
95+ var name = $ (' input[name="Name"]' , this ).val ();
96+ createMyApplication (name,
97+ function (appKey ) {
98+ timer = setInterval (function () {
99+
100+ checkForApplication (appKey,
101+ function (app ) {
102+ clearInterval (timer);
103+ var nextPage = ' @Url.Content("~/#/application/")' + app .Id + ' /' ;
104+ if (@ViewBag .FirstApplication .ToString ().ToLower () == false ) {
105+ nextPage = ' @Url.Action("Packages")?applicationId=' + app .Id ;
106+ }
107+ window .location = ' @Url.Content("~/account/UpdateSession")?returnUrl=' +
108+ encodeURIComponent (nextPage);
109+ },
110+ function () {
111+ attemptsLeft-- ;
112+ if (attemptsLeft <= 0 ) {
113+ clearInterval (timer);
114+ humane .log (' Failed to create application :(' );
115+ }
116+ });
117+ },
118+ 500 );
119+
120+ });
121+ });
122+
123+ </script >
124+ }
0 commit comments