@@ -1304,14 +1304,66 @@ window.ManageAppsView = countlyView.extend({
1304
1304
app . appSettings [ j ] . toInject ( ) ;
1305
1305
}
1306
1306
}
1307
+
1308
+ /**
1309
+ * initial screen prepare method
1310
+ * add first app elements and hide other things
1311
+ */
1312
+ function firstApp ( ) {
1313
+ store . set ( 'first_app' , true ) ;
1314
+ // hide sidebar & app navigation and app management bar
1315
+ // make unclickable countly logo
1316
+ // re-align elements
1317
+ $ ( '#top-bar > div.logo-container > a' ) . attr ( 'href' , 'javascript:void(0)' ) ;
1318
+ $ ( '#top-bar > div.right-menu > div:nth-child(1)' ) . css ( { 'opacity' : '0' , 'pointer-events' : 'none' } ) ;
1319
+ $ ( "#sidebar" ) . addClass ( "hidden" ) ;
1320
+ $ ( "#app-navigation" ) . css ( { 'opacity' : '0' , 'pointer-events' : 'none' } ) ;
1321
+ $ ( "#hide-sidebar-button" ) . hide ( ) ;
1322
+ $ ( '#app-management-bar' ) . hide ( ) ;
1323
+ $ ( '#content-container' ) . css ( { 'margin-left' : '0px' } ) ;
1324
+ var width = $ ( 'body' ) . width ( ) ;
1325
+ // create first app screen elements
1326
+ $ ( '#content' ) . prepend ( '<div id="first-app-welcome"></div>' ) ;
1327
+ $ ( '#first-app-welcome' ) . append ( '<h1 id="first-app-welcome-header" data-localize="management-applications.create-first-app-title"></h1>' ) ;
1328
+ $ ( '#first-app-welcome' ) . append ( '<p id="first-app-description" data-localize="management-applications.create-first-app-description"></p>' ) ;
1329
+ $ ( '#content > div.widget' ) . addClass ( 'widget-first-app-state' ) ;
1330
+ $ ( '#content > div.widget' ) . css ( { 'width' : width / ( 3 ) + 'px' } ) ;
1331
+ $ ( '#first-app-welcome' ) . css ( { 'width' : width / ( 3.5 ) + 'px' , 'margin-left' : '10%' } ) ;
1332
+
1333
+ $ ( '#add-new-app' ) . hide ( ) ;
1334
+ // make visible first app form
1335
+ $ ( '#add-first-app' ) . css ( { 'display' : 'block' } ) ;
1336
+ }
1337
+
1338
+ /**
1339
+ * make things normal after first app create process
1340
+ */
1341
+ function afterFirstApp ( ) {
1342
+ $ ( "#sidebar" ) . removeClass ( "hidden" ) ;
1343
+ $ ( "#app-navigation" ) . css ( { 'opacity' : '1' , 'pointer-events' : 'auto' } ) ;
1344
+ $ ( "#hide-sidebar-button" ) . show ( ) ;
1345
+ $ ( '#app-management-bar' ) . show ( ) ;
1346
+ var widthOfSidebar = $ ( '#sidebar' ) . width ( ) ;
1347
+ $ ( '#content-container' ) . css ( { 'margin-left' : widthOfSidebar + 'px' } ) ;
1348
+
1349
+ $ ( '#first-app-welcome' ) . remove ( ) ;
1350
+ $ ( '#add-first-app' ) . hide ( ) ;
1351
+ $ ( '#content > div.widget' ) . removeClass ( 'widget-first-app-state' ) ;
1352
+
1353
+ $ ( '#add-first-app' ) . css ( { 'display' : 'none' } ) ;
1354
+ $ ( '#top-bar > div.logo-container > a' ) . attr ( 'href' , '/dashboard#/' ) ;
1355
+ $ ( '#top-bar > div.right-menu > div:nth-child(1)' ) . css ( { 'opacity' : '1' , 'pointer-events' : 'auto' } ) ;
1356
+ store . set ( 'first_app' , false ) ;
1357
+ }
1358
+
1307
1359
/** App management initialization function
1308
1360
* @param {string } app_id - application id
1309
1361
* @returns {boolean } false - if no apps
1310
1362
*/
1311
1363
function initAppManagement ( app_id ) {
1312
1364
if ( jQuery . isEmptyObject ( countlyGlobal . apps ) ) {
1313
1365
showAdd ( ) ;
1314
- $ ( "#no-app-warning" ) . show ( ) ;
1366
+ firstApp ( ) ;
1315
1367
return false ;
1316
1368
}
1317
1369
else if ( jQuery . isEmptyObject ( countlyGlobal . admin_apps ) ) {
@@ -1394,12 +1446,12 @@ window.ManageAppsView = countlyView.extend({
1394
1446
for ( var i = 0 ; i < appTimezone . z . length ; i ++ ) {
1395
1447
for ( var tzone in appTimezone . z [ i ] ) {
1396
1448
if ( appTimezone . z [ i ] [ tzone ] === countlyGlobal . apps [ app_id ] . timezone ) {
1397
- var appEditTimezone = $ ( "#app-edit-timezone" ) . find ( ".read" ) ,
1449
+ var appEditTimezone = store . get ( 'first_app' ) ? $ ( "#first-app-edit-timezone" ) . find ( ".read" ) : $ ( "#app-edit-timezone" ) . find ( ".read" ) ,
1398
1450
appCountryCode = countlyGlobal . apps [ app_id ] . country ;
1399
1451
appEditTimezone . find ( ".flag" ) . css ( { "background-image" : "url(" + countlyGlobal . cdn + "images/flags/" + appCountryCode . toLowerCase ( ) + ".png)" } ) ;
1400
1452
appEditTimezone . find ( ".country" ) . text ( appTimezone . n ) ;
1401
1453
appEditTimezone . find ( ".timezone" ) . text ( tzone ) ;
1402
- initCountrySelect ( "#app-edit-timezone" , appCountryCode , tzone , appTimezone . z [ i ] [ tzone ] ) ;
1454
+ store . get ( 'first_app' ) ? initCountrySelect ( "#first-app-edit-timezone" , appCountryCode , tzone , appTimezone . z [ i ] [ tzone ] ) : initCountrySelect ( "#app-edit-timezone" , appCountryCode , tzone , appTimezone . z [ i ] [ tzone ] ) ;
1403
1455
break ;
1404
1456
}
1405
1457
}
@@ -1542,8 +1594,8 @@ window.ManageAppsView = countlyView.extend({
1542
1594
for ( prop in country . z [ 0 ] ) {
1543
1595
$ ( parent + " #selected" ) . show ( ) ;
1544
1596
$ ( parent + " #selected" ) . text ( prop ) ;
1545
- $ ( parent + " #app-timezone" ) . val ( country . z [ 0 ] [ prop ] ) ;
1546
- $ ( parent + " #app-country" ) . val ( countryCode ) ;
1597
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-timezone" ) . val ( country . z [ 0 ] [ prop ] ) : $ ( parent + " #app-timezone" ) . val ( country . z [ 0 ] [ prop ] ) ;
1598
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-country" ) . val ( countryCode ) : $ ( parent + " #app-country" ) . val ( countryCode ) ;
1547
1599
$ ( parent + " #country-select .text" ) . html ( "<div class='flag' style='background-image:url(" + countlyGlobal . cdn + "images/flags/" + countryCode . toLowerCase ( ) + ".png)'></div>" + country . n ) ;
1548
1600
}
1549
1601
}
@@ -1556,8 +1608,8 @@ window.ManageAppsView = countlyView.extend({
1556
1608
}
1557
1609
}
1558
1610
1559
- $ ( parent + " #app-timezone" ) . val ( timezone ) ;
1560
- $ ( parent + " #app-country" ) . val ( countryCode ) ;
1611
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-timezone" ) . val ( timezone ) : $ ( parent + " #app-timezone" ) . val ( timezone ) ;
1612
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-country" ) . val ( countryCode ) : $ ( parent + " #app-country" ) . val ( countryCode ) ;
1561
1613
$ ( parent + " #country-select .text" ) . html ( "<div class='flag' style='background-image:url(" + countlyGlobal . cdn + "images/flags/" + countryCode . toLowerCase ( ) + ".png)'></div>" + country . n ) ;
1562
1614
$ ( parent + " #timezone-select .text" ) . text ( timezoneText ) ;
1563
1615
$ ( parent + " #timezone-select" ) . show ( ) ;
@@ -1569,7 +1621,7 @@ window.ManageAppsView = countlyView.extend({
1569
1621
selectedItem . data ( "value" , $ ( this ) . data ( "value" ) ) ;
1570
1622
} ) ;
1571
1623
$ ( parent + " #timezone-items .item" ) . click ( function ( ) {
1572
- $ ( parent + " #app-timezone" ) . val ( $ ( this ) . data ( "value" ) ) ;
1624
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-timezone" ) . val ( $ ( this ) . data ( "value" ) ) : $ ( parent + " #app-timezone" ) . val ( $ ( this ) . data ( "value" ) ) ;
1573
1625
} ) ;
1574
1626
}
1575
1627
@@ -1584,8 +1636,8 @@ window.ManageAppsView = countlyView.extend({
1584
1636
for ( prop2 in timezones [ attr ] . z [ 0 ] ) {
1585
1637
$ ( parent + " #selected" ) . show ( ) ;
1586
1638
$ ( parent + " #selected" ) . text ( prop2 ) ;
1587
- $ ( parent + " #app-timezone" ) . val ( timezones [ attr ] . z [ 0 ] [ prop2 ] ) ;
1588
- $ ( parent + " #app-country" ) . val ( attr ) ;
1639
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-timezone" ) . val ( timezones [ attr ] . z [ 0 ] [ prop2 ] ) : $ ( parent + " #app-timezone" ) . val ( timezones [ attr ] . z [ 0 ] [ prop2 ] ) ;
1640
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-country" ) . val ( attr ) : $ ( parent + " #app-country" ) . val ( attr ) ;
1589
1641
}
1590
1642
}
1591
1643
else {
@@ -1597,22 +1649,22 @@ window.ManageAppsView = countlyView.extend({
1597
1649
if ( i === 0 ) {
1598
1650
$ ( parent + " #timezone-select" ) . find ( ".text" ) . text ( prop2 ) ;
1599
1651
firstTz = timezones [ attr ] . z [ 0 ] [ prop2 ] ;
1600
- $ ( parent + " #app-country" ) . val ( attr ) ;
1652
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-country" ) . val ( attr ) : $ ( parent + " #app-country" ) . val ( attr ) ;
1601
1653
}
1602
1654
1603
1655
timezoneSelect . append ( "<div data-value='" + timezones [ attr ] . z [ i ] [ prop2 ] + "' class='item'>" + prop2 + "</div>" ) ;
1604
1656
}
1605
1657
}
1606
1658
1607
1659
$ ( parent + " #timezone-select" ) . show ( ) ;
1608
- $ ( parent + " #app-timezone" ) . val ( firstTz ) ;
1660
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-timezone" ) . val ( firstTz ) : $ ( parent + " #app-timezone" ) . val ( firstTz ) ;
1609
1661
$ ( parent + " .select-items .item" ) . click ( function ( ) {
1610
1662
var selectedItem = $ ( this ) . parents ( ".cly-select" ) . find ( ".text" ) ;
1611
1663
selectedItem . html ( $ ( this ) . html ( ) ) ;
1612
1664
selectedItem . data ( "value" , $ ( this ) . data ( "value" ) ) ;
1613
1665
} ) ;
1614
1666
$ ( parent + " #timezone-items .item" ) . click ( function ( ) {
1615
- $ ( parent + " #app-timezone" ) . val ( $ ( this ) . data ( "value" ) ) ;
1667
+ store . get ( 'first_app' ) ? $ ( parent + " #first-app-timezone" ) . val ( $ ( this ) . data ( "value" ) ) : $ ( parent + " #app-timezone" ) . val ( $ ( this ) . data ( "value" ) ) ;
1616
1668
} ) ;
1617
1669
}
1618
1670
} ) ;
@@ -1728,7 +1780,7 @@ window.ManageAppsView = countlyView.extend({
1728
1780
}
1729
1781
1730
1782
initAppManagement ( appId ) ;
1731
- initCountrySelect ( "#app-add-timezone" ) ;
1783
+ store . get ( 'first_app' ) ? initCountrySelect ( "#first-app-add-timezone" ) : initCountrySelect ( "#app-add-timezone" ) ;
1732
1784
1733
1785
$ ( "#clear-app-data" ) . click ( function ( ) {
1734
1786
if ( $ ( this ) . hasClass ( "active" ) ) {
@@ -2049,43 +2101,44 @@ window.ManageAppsView = countlyView.extend({
2049
2101
$ ( ".new-app-name" ) . text ( newAppName ) ;
2050
2102
} ) ;
2051
2103
2052
- $ ( " #save-app-add" ) . click ( function ( ) {
2104
+ var saveAppBtn = store . get ( 'first_app' ) ? ' #save-first- app-add' : '#save-app-add' ;
2053
2105
2106
+ $ ( saveAppBtn ) . click ( function ( ) {
2054
2107
if ( $ ( this ) . hasClass ( "disabled" ) ) {
2055
2108
return false ;
2056
2109
}
2057
2110
2058
- var appName = $ ( "#app-add-name" ) . val ( ) ,
2059
- type = $ ( "#app-add-type" ) . data ( "value" ) + "" ,
2060
- category = $ ( "#app-add-category" ) . data ( "value" ) + "" ,
2061
- timezone = $ ( "#app-add-timezone #app-timezone" ) . val ( ) ,
2062
- country = $ ( "#app-add-timezone #app-country" ) . val ( ) ;
2111
+ var appName = store . get ( 'first_app' ) ? $ ( "#first-app-add-name" ) . val ( ) : $ ( "#app-add-name" ) . val ( ) ,
2112
+ type = store . get ( 'first_app' ) ? $ ( '#first-app-add-type' ) . data ( 'value' ) + "" : $ ( "#app-add-type" ) . data ( "value" ) + "" ,
2113
+ category = store . get ( 'first_app' ) ? $ ( "#first-app-add-category" ) . data ( "value" ) + "" : $ ( "#app-add-category" ) . data ( "value" ) + "" ,
2114
+ timezone = store . get ( 'first_app' ) ? $ ( "#first-app-add-timezone #first-app-timezone" ) . val ( ) : $ ( "#app-add-timezone #app-timezone" ) . val ( ) ,
2115
+ country = store . get ( 'first_app' ) ? $ ( "#first-app-add-timezone #first-app-country" ) . val ( ) : $ ( "#app-add-timezone #app-country" ) . val ( ) ;
2063
2116
2064
2117
$ ( ".required" ) . fadeOut ( ) . remove ( ) ;
2065
2118
var reqSpan = $ ( "<span>" ) . addClass ( "required" ) . text ( "*" ) ;
2066
2119
2067
2120
if ( ! appName ) {
2068
- $ ( "#app-add-name" ) . after ( reqSpan . clone ( ) ) ;
2121
+ store . get ( 'first_app' ) ? $ ( "#first-app-add-name" ) . after ( reqSpan . clone ( ) ) : $ ( "#app-add-name" ) . after ( reqSpan . clone ( ) ) ;
2069
2122
}
2070
2123
2071
2124
if ( ! type ) {
2072
- $ ( "#app-add-type" ) . parents ( ".cly-select" ) . after ( reqSpan . clone ( ) ) ;
2125
+ store . get ( 'first_app' ) ? $ ( "#first-app-add-type" ) . parents ( ".cly-select" ) . after ( reqSpan . clone ( ) ) : $ ( "#app-add-type" ) . parents ( ".cly-select" ) . after ( reqSpan . clone ( ) ) ;
2073
2126
}
2074
2127
2075
2128
/*if (!category) {
2076
2129
$("#app-add-category").parents(".cly-select").after(reqSpan.clone());
2077
2130
}*/
2078
2131
2079
2132
if ( ! timezone ) {
2080
- $ ( "#app-add-timezone #app-timezone" ) . after ( reqSpan . clone ( ) ) ;
2133
+ store . get ( 'first_app' ) ? $ ( "#first-app-add-timezone #first-app-timezone" ) . after ( reqSpan . clone ( ) ) : $ ( "#app-add-timezone #app-timezone" ) . after ( reqSpan . clone ( ) ) ;
2081
2134
}
2082
2135
2083
2136
if ( $ ( ".required" ) . length ) {
2084
2137
$ ( ".required" ) . fadeIn ( ) ;
2085
2138
return false ;
2086
2139
}
2087
2140
2088
- var ext = $ ( '#add-app-image-form' ) . find ( "#app_add_image" ) . val ( ) . split ( '.' ) . pop ( ) . toLowerCase ( ) ;
2141
+ var ext = store . get ( 'first_app' ) ? $ ( '#add-first-app-image-form' ) . find ( "#first-app_add_image" ) . val ( ) . split ( '.' ) . pop ( ) . toLowerCase ( ) : $ ( '#add-app-image-form' ) . find ( "#app_add_image" ) . val ( ) . split ( '.' ) . pop ( ) . toLowerCase ( ) ;
2089
2142
if ( ext && $ . inArray ( ext , [ 'gif' , 'png' , 'jpg' , 'jpeg' ] ) === - 1 ) {
2090
2143
CountlyHelpers . alert ( jQuery . i18n . map [ "management-applications.icon-error" ] , "red" ) ;
2091
2144
return false ;
@@ -2101,7 +2154,9 @@ window.ManageAppsView = countlyView.extend({
2101
2154
country : country
2102
2155
} ;
2103
2156
2104
- $ ( "#add-new-app .app-write-settings" ) . each ( function ( ) {
2157
+ var appWriteSettings = store . get ( 'first_app' ) ? $ ( "#add-first-app .app-write-settings" ) : $ ( "#add-new-app .app-write-settings" ) ;
2158
+
2159
+ appWriteSettings . each ( function ( ) {
2105
2160
var id = $ ( this ) . data ( 'id' ) ;
2106
2161
if ( app . appSettings [ id ] && app . appSettings [ id ] . toSave ) {
2107
2162
app . appSettings [ id ] . toSave ( null , args , this ) ;
@@ -2125,6 +2180,7 @@ window.ManageAppsView = countlyView.extend({
2125
2180
dataType : "jsonp" ,
2126
2181
success : function ( data ) {
2127
2182
2183
+ afterFirstApp ( ) ;
2128
2184
var sidebarApp = $ ( "#sidebar-new-app>div" ) . clone ( ) ;
2129
2185
2130
2186
countlyGlobal . apps [ data . _id ] = data ;
@@ -2139,7 +2195,7 @@ window.ManageAppsView = countlyView.extend({
2139
2195
newApp . removeAttr ( "id" ) ;
2140
2196
2141
2197
if ( ! ext ) {
2142
- $ ( "#save-app-add" ) . removeClass ( "disabled" ) ;
2198
+ $ ( "#save-first- app-add" ) . removeClass ( "disabled" ) ;
2143
2199
sidebarApp . find ( ".name" ) . text ( data . name ) ;
2144
2200
sidebarApp . data ( "id" , data . _id ) ;
2145
2201
sidebarApp . data ( "key" , data . key ) ;
0 commit comments