Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
668ccb3b
Commit
668ccb3b
authored
Jul 21, 2016
by
Vladimir Baranov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CHANGE, closes zetaops/ulakbus-uiGH-105, closes #5394. Allow to work offline in devel mode
parent
283d8d6f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
43 deletions
+93
-43
app.js
app/app.js
+41
-1
app_routes.js
app/app_routes.js
+1
-41
main.js
app/main.js
+51
-1
No files found.
app/app.js
View file @
668ccb3b
...
@@ -75,6 +75,46 @@ angular.module(
...
@@ -75,6 +75,46 @@ angular.module(
return
{
url
:
backendurl
};
return
{
url
:
backendurl
};
})())
})())
.
factory
(
'IsOnline'
,
function
(
$window
,
$document
,
$rootScope
)
{
var
isOnlineService
=
{};
isOnlineService
.
status
=
true
;
var
offlineMask
=
angular
.
element
(
'<div class="body-mask" style="z-index: 2010; opacity: 0.6">'
+
'<div class="alert alert-danger text-center" role="alert" style="z-index: 2011; position: relative">'
+
'İnternet bağlantınız kesilmiştir. Bağlantı sağlandığında kaldığınız yerden devam edebilirsiniz.'
+
'</div>'
+
'</div>'
);
var
body
=
$document
.
find
(
'body'
).
eq
(
0
);
isOnlineService
.
set_status
=
function
(
state
)
{
// status changed
if
(
state
!=
isOnlineService
.
status
){
// online
if
(
state
){
offlineMask
.
remove
();
// is user is set, reload page to init
if
(
$rootScope
.
current_user
===
true
){
window
.
location
.
reload
();
}
}
// offline
else
{
body
.
append
(
offlineMask
);
}
}
isOnlineService
.
status
=
state
;
};
isOnlineService
.
get_status
=
function
()
{
return
isOnlineService
.
status
;
};
return
isOnlineService
;
})
// .service('DESIGN', function ($routeParams, $cookies, $log) {
// .service('DESIGN', function ($routeParams, $cookies, $log) {
// // use route param to change cookie for design
// // use route param to change cookie for design
// // this is a config as a service added for designer can work without backend
// // this is a config as a service added for designer can work without backend
...
...
app/app_routes.js
View file @
668ccb3b
...
@@ -63,47 +63,7 @@ angular.module('ulakbus')
...
@@ -63,47 +63,7 @@ angular.module('ulakbus')
})
})
.
otherwise
({
redirectTo
:
'/dashboard'
});
.
otherwise
({
redirectTo
:
'/dashboard'
});
}])
}])
.
factory
(
'IsOnline'
,
function
()
{
var
isOnlineService
=
{};
isOnlineService
.
status
=
navigator
.
onLine
;
isOnlineService
.
set_status
=
function
(
state
)
{
isOnlineService
.
status
=
state
;
};
isOnlineService
.
get_status
=
function
()
{
return
isOnlineService
.
status
;
};
return
isOnlineService
;
})
.
run
(
function
(
$window
,
$rootScope
,
$document
,
$route
,
IsOnline
)
{
// in this run configuration we detect internet connection and append a mask to body
// when reconnect the mask will be removed
var
offlineMask
=
angular
.
element
(
'<div class="body-mask">'
+
'</div>'
);
offlineMask
.
css
({
zIndex
:
'2010'
,
opacity
:
'0.6'
});
var
offlineAlert
=
angular
.
element
(
'<div class="alert alert-danger text-center" role="alert">'
+
'İnternet bağlantınız kesilmiştir. Bağlantı sağlandığında kaldığınız yerden devam edebilirsiniz.'
+
'</div>'
).
css
({
zIndex
:
'2011'
,
position
:
'relative'
});
var
body
=
$document
.
find
(
'body'
).
eq
(
0
);
// detect internet connection
var
is_online
=
navigator
.
onLine
;
if
(
!
is_online
){
body
.
append
(
offlineMask
).
append
(
offlineAlert
);}
$window
.
addEventListener
(
"offline"
,
function
()
{
is_online
=
false
;
IsOnline
.
set_status
(
false
);
body
.
append
(
offlineMask
).
append
(
offlineAlert
);
},
false
);
$window
.
addEventListener
(
"online"
,
function
()
{
is_online
=
true
;
IsOnline
.
set_status
(
true
);
offlineMask
.
remove
();
offlineAlert
.
remove
();
if
(
$rootScope
.
current_user
===
true
){
window
.
location
.
reload
();}
// $route.reload();
},
false
);
})
.
run
(
function
(
$rootScope
,
AuthService
)
{
.
run
(
function
(
$rootScope
,
AuthService
)
{
AuthService
.
check_auth
();
AuthService
.
check_auth
();
...
...
app/main.js
View file @
668ccb3b
...
@@ -80,6 +80,56 @@ angular.module(
...
@@ -80,6 +80,56 @@ angular.module(
return
{
url
:
backendurl
};
return
{
url
:
backendurl
};
})())
})())
.
factory
(
'IsOnline'
,
function
(
$window
,
$document
,
$rootScope
)
{
var
isOnlineService
=
{};
isOnlineService
.
status
=
true
;
var
offlineMask
=
angular
.
element
(
'<div class="body-mask" style="z-index: 2010; opacity: 0.6">'
+
'<div class="alert alert-danger text-center" role="alert" style="z-index: 2011; position: relative">'
+
'İnternet bağlantınız kesilmiştir. Bağlantı sağlandığında kaldığınız yerden devam edebilirsiniz.'
+
'</div>'
+
'</div>'
);
var
body
=
$document
.
find
(
'body'
).
eq
(
0
);
isOnlineService
.
set_status
=
function
(
state
)
{
// status changed
if
(
state
!=
isOnlineService
.
status
){
// online
if
(
state
){
offlineMask
.
remove
();
// is user is set, reload page to init
if
(
$rootScope
.
current_user
===
true
){
window
.
location
.
reload
();
}
}
// offline
else
{
body
.
append
(
offlineMask
);
}
}
isOnlineService
.
status
=
state
;
};
isOnlineService
.
get_status
=
function
()
{
return
isOnlineService
.
status
;
};
// @if NODE_ENV='PRODUCTION'
isOnlineService
.
status
=
navigator
.
onLine
;
$window
.
addEventListener
(
"offline"
,
function
(){
isOnlineService
.
set_status
(
false
);
});
$window
.
addEventListener
(
"online"
,
function
(){
isOnlineService
.
set_status
(
true
);
});
// @endif
return
isOnlineService
;
})
// .service('DESIGN', function ($routeParams, $cookies, $log) {
// .service('DESIGN', function ($routeParams, $cookies, $log) {
// // use route param to change cookie for design
// // use route param to change cookie for design
// // this is a config as a service added for designer can work without backend
// // this is a config as a service added for designer can work without backend
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment