Projekt

Obecné

Profil

« Předchozí | Další » 

Revize e4f78eb8

Přidáno uživatelem Jan Kohlíček před téměř 7 roky(ů)

refs #6863: Když REST API odpoví 400, 404, 500 nebo vyprší timeout zobrazí se modální okno s hláškou, při vypnutém JavaScriptu se zobrazí text vybízející k zapnutí JavaScriptu

Zobrazit rozdíly:

frontend/app.js
1
var app = angular.module('pvpk', ['ngRoute', 'ngResource']);
1
var app = angular.module('pvpk', ['ngRoute', 'ngResource', 'ngSanitize']);
2 2

  
3 3
app.constant('config', {
4 4
    APP_NAME: 'PVPK',
......
42 42
        switch (response.status) {
43 43
            case 400:
44 44
                console.log('API ERROR 400');
45
                $scope.modalError = {
46
                    title: 'Neplatný požadavek',
47
                    body: 'Požadavek nemůže být vyřízen, poněvadž byl syntakticky nesprávně zapsán.',
48
                    button: 'OK'
49
                };
50
                jQuery('#modalError').modal('show');
45 51
                break;
46 52
            case 401:
47
                jQuery('#modalExpiredToken').modal('show');
53
                $scope.modalError = {
54
                    title: 'Platnost webové aplikace vypršela',
55
                    body: 'Pro obnovení platnosti stačí stisknout tlačítko <strong>Obnovit</strong>.',
56
                    button: 'Obnovit',
57
                    clickButton: $scope.reloadApp
58
                };
59
                jQuery('#modalError').modal({backdrop: 'static', keyboard: false});
48 60
                break;
49 61
            case 404:
50 62
                console.log('API ERROR 404');
63
                $scope.modalError = {title: 'Nenalezen', body: 'Záznam nebyl nalezen.', button: 'OK'};
64
                jQuery('#modalError').modal('show');
51 65
                break;
52 66
            case 500:
53 67
                console.log('API ERROR 500');
68
                $scope.modalError = {title: 'Chyba', body: 'Chyba serveru. Zopakujte akci později.', button: 'OK'};
69
                jQuery('#modalError').modal('show');
70
                break;
71
            case -1:
72
                console.log('API NOT CONNECTED');
73
                $scope.modalError = {
74
                    title: 'Připojení k internetu',
75
                    body: 'Nejste připojeni k internetu. Zkontrolujte připojení.',
76
                    button: 'OK'
77
                };
78
                jQuery('#modalError').modal('show');
54 79
                break;
55 80
            default:
81
                console.log('API UNKNOWN ERROR');
82
                $scope.modalError = {title: 'Neočekávaná chyba', body: 'Nastala neočekávaná chyba.', button: 'OK'};
83
                jQuery('#modalError').modal('show');
84
                break;
56 85
        }
57 86
    };
58 87

  
......
234 263
                        lat: latlng.lat(),
235 264
                        lng: latlng.lng(),
236 265
                        title: lctn.name,
237
                        label: 'U',
238 266
                        click: function (e) {
239 267
                            $rootScope.$emit('infoLocation', {id: lctn.id});
240 268
                            //alert("asdfas");
frontend/assets/css/main.css
42 42
    padding: 0;
43 43
    margin: 0;
44 44
    overflow: hidden;
45
    min-height: 100%;
45 46
}
46 47

  
47 48

  
......
63 64

  
64 65

  
65 66
#loadingScreen{
66
    position: fixed;
67 67
    width: 100%;
68 68
    height: 100%;
69 69
    z-index: 1000;
70
    position: fixed;
70 71
    top: 0;
71 72
    left: 0;
72 73
    right: 0;
......
75 76
}
76 77

  
77 78
#loadingScreen .loading{
78
    border: 12px solid white; /* Light grey */
79
    border-top: 12px solid #007bff; /* Blue */
79
    border: 12px solid white;
80
    border-top: 12px solid #007bff;
80 81
    border-radius: 50%;
81 82
    width: 100px;
82 83
    height: 100px;
......
89 90
    right: 0;
90 91
}
91 92

  
93
#loadingScreen #logo {
94
    width: 100%;
95
    height: 50px;
96
    position: fixed;
97
    top: -160px;
98
    bottom: 0;
99
    left: 0;
100
    right: 0;
101
    margin: auto 0;
102
    text-align: center;
103
    font-size: 1.4rem;
104
}
92 105

  
93

  
94

  
106
#loadingScreen #pvpk_noscript{
107
    width: 100%;
108
    height: 110px;
109
    position: fixed;
110
    top: 0;
111
    bottom: 0;
112
    left: 0;
113
    right: 0;
114
    margin: auto 0;
115
    text-align: center;
116
    font-size: 1rem;
117
    background-color: #CFD8DC;
118
}
95 119

  
96 120

  
97 121

  
frontend/index.php
1 1
<!doctype html>
2
<html ng-app="pvpk" class="no-js" lang="cs">
2
<html ng-app="pvpk" lang="cs">
3 3
<head>
4 4
    <meta charset="utf-8">
5 5
    <title>Průjezd vozidel - Plzeňský kraj</title>
......
11 11
    <link rel="apple-touch-icon" href="./assets/img/favicon.png">
12 12
    <link rel="icon" href="./assets/img/favicon.png">
13 13

  
14
    <script>
15
        document.documentElement.className = document.documentElement.className.replace("no-js", "js");
16
    </script>
17

  
18
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css"
19
          integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
14
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"
15
          integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
20 16
    <link rel="stylesheet" media="screen" href="./assets/css/main.css">
21 17

  
22

  
23 18
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
24 19
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.min.js"></script>
25 20
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-resource.min.js"></script>
21
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-sanitize.min.js"></script>
22

  
23
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script>
26 24

  
27 25
    <script>
28 26
        <?php
......
37 35
    </script>
38 36

  
39 37
    <script src="./app.js"></script>
40

  
41

  
42
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.min.js"></script>
43 38
</head>
44 39
<body ng-controller="mainController" class="container-fluid">
45 40

  
46 41

  
42

  
43

  
47 44
<div id="loadingScreen" ng-show="showLoadingScreen">
45
    <h1 id="logo">
46
        <img src="./assets/img/favicon.png" alt="logo"> Průjezd vozidel
47
        <small class="text-muted">Plzeňský kraj</small>
48
    </h1>
48 49
    <div class="loading"></div>
50
    <noscript id="pvpk_noscript">Aplikace vyžaduje Javascript. Aktivujte Javascript a znovu načtěte tuto stránku.</noscript>
49 51
</div>
52

  
50 53
<div class="row h-100">
51 54

  
52 55
    <!--SEARCH section-->
......
71 74
                </div>
72 75

  
73 76
                <div class="custom-control custom-checkbox mb-3">
74
                    <!-- ng-true-value="ofCourse" ng-false-value="iWish"  -->
75 77
                    <input type="checkbox" id="searchDirection" name="searchDirection" class="custom-control-input"
76 78
                           checked ng-model="search.direction" required ng-change="searchLocations()">
77 79
                    <label for="searchDirection" class="custom-control-label">Rozlišovat směr</label>
......
124 126
                </div>
125 127
            </form>
126 128

  
127

  
128 129
            <div class="result-locations mb-5 mt-5">
129 130
                <h5>Lokality</h5>
130 131

  
131 132
                <div class="list-group" ng-show="locations.length>0 && !showSearchLoading">
132
                    <!-- class = active -->
133 133
                    <a href="" id="location-{{location.id}}"
134 134
                       class="list-group-item list-group-item-action flex-column align-items-start"
135 135
                       ng-repeat="location in locations"
......
152 152
                </div>
153 153

  
154 154
                <div class="loading" ng-show="showSearchLoading"></div>
155

  
156 155
            </div>
157

  
158 156
        </div>
159 157
        <footer class="text-center mb-2 mt-2 w-100">
160 158
            <small class="text-muted">2018 © FAV, ZČU</small>
......
167 165
             ng-controller="infoController">
168 166

  
169 167
        <header class="mt-2">
170

  
171 168
            <h5>{{$root.selectDevice.name}}
172 169
                <button type="button" class="close" aria-label="Close" ng-click="infoClose()">
173 170
                    <span aria-hidden="true">&times;</span>
......
180 177

  
181 178
        <div class="loading" ng-show="showInfoLoading"></div>
182 179

  
183

  
184 180
        <h3 class="mt-5">Graf #1</h3>
185 181

  
186 182
        <h3 class="mt-5">Graf #2</h3>
......
194 190

  
195 191
        <h3 class="mt-5">Graf #3</h3>
196 192

  
197

  
198 193
    </section>
199 194

  
195

  
200 196
    <!--MAP section-->
201 197
    <section class="map col-12 col-sm-12" id="map"
202 198
             ng-class="{ 'col-lg-9': $root.selectDevice==null, 'col-lg-6': $root.selectDevice!=null }"
203 199
             ng-controller="mapController">
204

  
205

  
206 200
    </section>
207

  
208

  
209 201
</div>
210 202

  
211
<div class="modal fade" id="modalExpiredToken" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
212
     aria-hidden="true">
203
<div class="modal fade" id="modalError" tabindex="-1" role="dialog">
213 204
    <div class="modal-dialog" role="document">
214 205
        <div class="modal-content">
215 206
            <div class="modal-header">
216
                <h5 class="modal-title" id="exampleModalLabel">Platnost webové aplikace vypršela</h5>
207
                <h5 class="modal-title" id="exampleModalLabel">{{modalError.title}}</h5>
217 208
            </div>
218 209
            <div class="modal-body">
219
                <p>Pro obnovení platnosti stačí stisknout tlačítko <strong>Obnovit</strong>.</p>
210
                <p ng-bind-html="modalError.body"></p>
220 211
            </div>
221 212
            <div class="modal-footer">
222
                <button type="button" class="btn btn-primary" ng-click="reloadApp()">Obnovit</button>
213
                <button type="button" class="btn btn-primary" data-dismiss="{{modalError.clickButton ? '' : 'modal'}}"
214
                        ng-click="modalError.clickButton && modalError.clickButton()">{{modalError.button}}
215
                </button>
223 216
            </div>
224 217
        </div>
225 218
    </div>
226 219
</div>
227 220

  
228

  
229 221
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
230 222
        integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
231 223
        crossorigin="anonymous"></script>
232
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"
233
        integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm"
224

  
225
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"
226
        integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T"
234 227
        crossorigin="anonymous"></script>
235 228

  
236
<!--async defer-->
237 229
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCSx7hyAzQiG5uocJTeZgf1Z3lpDy4kpEk"
238 230
        type="text/javascript"></script>
239 231

  
240 232
<script type="text/javascript" src="./assets/libs/gmaps.min.js"></script>
241 233

  
242

  
243 234
</body>
244 235
</html>

Také k dispozici: Unified diff