Skip to content

Commit dfc3237

Browse files
committed
Déplacement du bouton Swagger directement dans la top bar
1 parent 9b54f7a commit dfc3237

File tree

16 files changed

+356
-224
lines changed

16 files changed

+356
-224
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"karma-firefox-launcher": "latest",
5858
"karma-jasmine": "latest",
5959
"karma-verbose-reporter": "latest",
60+
"moment": "^2.24.0",
6061
"protractor": "latest",
6162
"protractor-jasmine2-html-reporter": "latest",
6263
"restling": "latest",

src/app/diff/diff.js

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
function buildDiffDiffPageUrl(fromPlatform, toPlatform, fromPropertiesPath, toPropertiesPath, lookPast, date) {
19+
function buildDiffPageUrl(fromPlatform, toPlatform, fromPropertiesPath, toPropertiesPath, lookPast, timestamp) {
2020
const urlParams = {
2121
application: fromPlatform.application_name,
2222
platform: fromPlatform.platform,
@@ -26,11 +26,19 @@ function buildDiffDiffPageUrl(fromPlatform, toPlatform, fromPropertiesPath, toPr
2626
compare_path: toPropertiesPath,
2727
};
2828
if (lookPast) {
29-
urlParams.timestamp = date;
29+
urlParams.timestamp = timestamp;
3030
}
3131
return `/#/diff?${ Object.keys(urlParams).map((key) => `${ encodeURIComponent(key) }=${ encodeURIComponent(urlParams[key]) }`).join('&') }`;
3232
}
3333

34+
function dateToTimestamp(lookPast, date) {
35+
var timestamp = null;
36+
if (lookPast) {
37+
timestamp = date ? Number(moment(date, 'YYYY-MM-DD HH:mm:ss Z')) : new Date().getTime();
38+
}
39+
return timestamp;
40+
}
41+
3442
angular.module('hesperides.diff', [])
3543

3644
.controller('DiffController', function ($filter, $scope, $routeParams, $timeout, $route, ApplicationService, ModuleService, $translate, HesperidesModalFactory, Platform, notify) {
@@ -247,49 +255,49 @@ angular.module('hesperides.diff', [])
247255
if status == 3 : same behavior as status == 2
248256
*/
249257
$scope.diff_containers.filter((diff_container) => diff_container.selected)
250-
.forEach((diff_container) => {
251-
switch (diff_container.status) {
252-
case 0:
253-
break;
254-
case 1:
258+
.forEach((diff_container) => {
259+
switch (diff_container.status) {
260+
case 0:
261+
break;
262+
case 1:
255263
// Revert modifs
256-
diff_container.property_to_modify.value = diff_container.property_to_modify.old_value;
257-
delete diff_container.property_to_modify.old_value;
258-
259-
// Change status and reset markers. Keep selected for user experience
260-
// Status depends on old_value, if it was empty status is 3 otherwise it is 2
261-
diff_container.status = diff_container.property_to_modify.value === '' ? 3 : 2;
262-
diff_container.modified = false;
263-
break;
264-
case 2:
264+
diff_container.property_to_modify.value = diff_container.property_to_modify.old_value;
265+
delete diff_container.property_to_modify.old_value;
266+
267+
// Change status and reset markers. Keep selected for user experience
268+
// Status depends on old_value, if it was empty status is 3 otherwise it is 2
269+
diff_container.status = diff_container.property_to_modify.value === '' ? 3 : 2;
270+
diff_container.modified = false;
271+
break;
272+
case 2:
265273
// Store old value and apply modifs
266-
diff_container.property_to_modify.old_value = diff_container.property_to_modify.value;
267-
diff_container.property_to_modify.value = diff_container.property_to_compare_to.value;
268-
269-
// Change status and reset markers. Keep selected for user experience
270-
diff_container.modified = true;
271-
diff_container.status = 1;
272-
break;
273-
case 3:
274+
diff_container.property_to_modify.old_value = diff_container.property_to_modify.value;
275+
diff_container.property_to_modify.value = diff_container.property_to_compare_to.value;
276+
277+
// Change status and reset markers. Keep selected for user experience
278+
diff_container.modified = true;
279+
diff_container.status = 1;
280+
break;
281+
case 3:
274282
// Same as 2, copy paste (bad :p )
275283
// Store old value and apply modifs
276-
diff_container.property_to_modify.old_value = diff_container.property_to_modify.value;
277-
diff_container.property_to_modify.value = diff_container.property_to_compare_to.value;
278-
279-
// Change status and reset markers. Keep selected for user experience
280-
diff_container.modified = true;
281-
diff_container.status = 1;
282-
break;
283-
default:
284-
throw new Error(`Diff container with invalid status -> ${ diff_container.status }. It will be ignored`);
285-
}
286-
});
284+
diff_container.property_to_modify.old_value = diff_container.property_to_modify.value;
285+
diff_container.property_to_modify.value = diff_container.property_to_compare_to.value;
286+
287+
// Change status and reset markers. Keep selected for user experience
288+
diff_container.modified = true;
289+
diff_container.status = 1;
290+
break;
291+
default:
292+
throw new Error(`Diff container with invalid status -> ${ diff_container.status }. It will be ignored`);
293+
}
294+
});
287295
};
288296

289297
$scope.save_diff = function () {
290298
// Get all the properties modified
291299
var key_value_properties = $scope.diff_containers.filter((diff_container) => diff_container.property_to_modify)
292-
.map((diff_container) => diff_container.property_to_modify);
300+
.map((diff_container) => diff_container.property_to_modify);
293301

294302
// Is some diff item selected ?
295303
var hasSomeDiffSelected = _.some($scope.diff_containers, { selected: true });
@@ -347,7 +355,7 @@ angular.module('hesperides.diff', [])
347355
$scope.checkToPlatformExist = function () {
348356
if ($scope.diffForm) {
349357
$scope.diffForm.$setValidity('matchingModule', true); // reset to default value
350-
let appHasPlatform = _.some($scope.targetPlatforms, { name: $scope.toPlatform.platform });
358+
const appHasPlatform = _.some($scope.targetPlatforms, { name: $scope.toPlatform.platform });
351359
$scope.diffForm.$setValidity('toPlatformExist', appHasPlatform);
352360
}
353361
};
@@ -362,12 +370,8 @@ angular.module('hesperides.diff', [])
362370

363371
$scope.getModuleToCompare = function () {
364372
$scope.loadingComparePlatform = true;
365-
if ($scope.lookPast) {
366-
$scope.date = $scope.date ? Number(moment($scope.date, 'YYYY-MM-DD HH:mm:ss Z')) : new Date().getTime();
367-
} else {
368-
$scope.date = null;
369-
}
370-
ApplicationService.get_platform($scope.toPlatform.application_name, $scope.toPlatform.platform, $scope.date).then((platformFetched) => {
373+
const timestamp = dateToTimestamp($scope.lookPast, $scope.date);
374+
ApplicationService.get_platform($scope.toPlatform.application_name, $scope.toPlatform.platform, timestamp).then((platformFetched) => {
371375
$scope.loadingComparePlatform = false;
372376
$scope.toPlatform.modules = platformFetched.modules;
373377
$scope.toModule = _.find($scope.toPlatform.modules, { name: $scope.fromModule.name });
@@ -396,7 +400,8 @@ angular.module('hesperides.diff', [])
396400

397401
$scope.openDiffPage = function () {
398402
$mdDialog.hide();
399-
$window.open(buildDiffDiffPageUrl($scope.fromPlatform, $scope.toPlatform, $scope.fromModule.properties_path, $scope.toModule.properties_path, $scope.lookPast, $scope.date), '_blank');
403+
const timestamp = dateToTimestamp($scope.lookPast, $scope.date);
404+
$window.open(buildDiffPageUrl($scope.fromPlatform, $scope.toPlatform, $scope.fromModule.properties_path, $scope.toModule.properties_path, $scope.lookPast, timestamp), '_blank');
400405
};
401406

402407
// Construtor initialization:
@@ -432,7 +437,7 @@ angular.module('hesperides.diff', [])
432437

433438
$scope.checkToPlatformExist = function () {
434439
if ($scope.diffForm) {
435-
let appHasPlatform = _.some($scope.targetPlatforms, { name: $scope.toPlatform.platform });
440+
const appHasPlatform = _.some($scope.targetPlatforms, { name: $scope.toPlatform.platform });
436441
$scope.diffForm.$setValidity('toPlatformExist', appHasPlatform);
437442
}
438443
};
@@ -451,7 +456,8 @@ angular.module('hesperides.diff', [])
451456

452457
$scope.openDiffPage = function () {
453458
$mdDialog.hide();
454-
$window.open(buildDiffDiffPageUrl($scope.fromPlatform, $scope.toPlatform, '#', '#', $scope.lookPast, $scope.date), '_blank');
459+
const timestamp = dateToTimestamp($scope.lookPast, $scope.date);
460+
$window.open(buildDiffPageUrl($scope.fromPlatform, $scope.toPlatform, '#', '#', $scope.lookPast, timestamp), '_blank');
455461
};
456462

457463
// Construtor initialization:
@@ -471,7 +477,7 @@ angular.module('hesperides.diff', [])
471477
if ($scope.ngModel) {
472478
angular.element($document[0].querySelector($scope.target)).focus();
473479
}
474-
});
480+
}, 100); // Nécessaire pour faire fonctionner le focus au premier essai
475481
});
476482
},
477483
};

src/app/diff/global_properties_diff_wizard.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ <h2>{{ 'properties.platform.globalProperties.compare.modal.title' | translate }}
5656
{{ 'properties.compare.modal.error.toPlatformDoesNotExists' | translate }}
5757
</div>
5858

59-
<md-switch move-focus-when-enabled target="#look-past-date-time"
59+
<md-switch id="e2e-global-properties-diff-select-date-switch" move-focus-when-enabled target="#look-past-date-time"
6060
class="md-primary md-block" aria-label="Comparer à une date" ng-model="formScope.lookPast" ng-show="toPlatform.application_name && toPlatform.platform">
6161
<strong>{{ 'properties.compare.modal.compareDate.switch' | translate : {application: toPlatform.application_name, platform: toPlatform.platform} }}</strong>
6262
</md-switch>
@@ -67,7 +67,7 @@ <h2>{{ 'properties.platform.globalProperties.compare.modal.title' | translate }}
6767
</md-content>
6868
</div>
6969
<md-dialog-actions>
70-
<md-button type="submit" class="md-raised md-primary" ng-disabled="!isDateValid() || diffForm.$invalid">{{ 'button.modal.runComparison' | translate }}</md-button>
70+
<md-button id="e2e-global-properties-diff-runcomparison-button" type="submit" class="md-raised md-primary" ng-disabled="!isDateValid() || diffForm.$invalid">{{ 'button.modal.runComparison' | translate }}</md-button>
7171
<md-button ng-click="closeGlobalPropertiesDiffWizard()" class="md-raised md-warn">{{ 'button.modal.cancel' | translate }}</md-button>
7272
</md-dialog-actions>
7373
</form>

src/app/diff/properties_diff_wizard.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h2>{{ 'properties.compare.modal.title' | translate }}
7070
</md-content>
7171
</div>
7272
<md-dialog-actions>
73-
<md-button wz-next ng-click="getModuleToCompare()" class="md-raised md-primary" ng-disabled="!isDateValid() || diffForm.$invalid">
73+
<md-button id="e2e-properties-diff-next-button" wz-next ng-click="getModuleToCompare()" class="md-raised md-primary" ng-disabled="!isDateValid() || diffForm.$invalid">
7474
{{ 'button.modal.next' | translate }}
7575
</md-button>
7676
<md-button ng-click="closePropertiesDiffWizard()" class="md-raised md-warn">{{ 'button.modal.cancel' | translate }}</md-button>
@@ -105,7 +105,7 @@ <h2>{{ 'properties.compare.modal.moduleChoice' | translate : {comparePlatformApp
105105
</ul>
106106
</div>
107107
<div flex class="text-align-end">
108-
<md-button type="submit" class="md-raised md-primary" aria-label="{{ 'button.modal.runComparison' | translate }}"
108+
<md-button id="e2e-properties-diff-runcomparison-button" type="submit" class="md-raised md-primary" aria-label="{{ 'button.modal.runComparison' | translate }}"
109109
ng-disabled="!toModule">{{ 'button.modal.runComparison' | translate }}</md-button>
110110
</div>
111111
</div>
@@ -136,7 +136,7 @@ <h2>{{ 'properties.compare.modal.moduleChoice' | translate : {comparePlatformApp
136136
</md-content>
137137
</div>
138138
<md-dialog-actions>
139-
<md-button class="md-raised md-primary" wz-previous>{{ 'button.modal.prev' | translate }}</md-button>
139+
<md-button id="e2e-properties-diff-previous-button" class="md-raised md-primary" wz-previous>{{ 'button.modal.prev' | translate }}</md-button>
140140
<md-button ng-click="closePropertiesDiffWizard()" class="md-raised md-warn">{{ 'button.modal.cancel' | translate }}</md-button>
141141
</md-dialog-actions>
142142
</wz-step>

src/app/hesperides/hesperides.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ angular.module('hesperides', [
4646
weekdays: [ 'D', 'L', 'M', 'M', 'J', 'V', 'S' ],
4747
calendar: 'Calendrier',
4848
})
49-
5049
.config([
5150
'$routeProvider', '$mdThemingProvider', '$ariaProvider', '$mdIconProvider', '$translateProvider', '$locationProvider',
5251
function ($routeProvider, $mdThemingProvider, $ariaProvider, $mdIconProvider, $translateProvider, $locationProvider) {
@@ -116,7 +115,7 @@ angular.module('hesperides', [
116115
},
117116
])
118117

119-
.run(function (editableOptions, editableThemes, $rootScope, $http, $location, $route, $document, UserService) {
118+
.run(function (editableOptions, editableThemes, $rootScope, $http, $location, $route, $document, UserService, notify) {
120119
editableOptions.theme = 'default';
121120

122121
// overwrite submit button template
@@ -166,6 +165,9 @@ angular.module('hesperides', [
166165

167166
// On tente de se connecter systématiquement :
168167
UserService.authenticate();
168+
169+
// eslint-disable-next-line angular/module-getter
170+
notify.config({ position: 'right' });
169171
})
170172

171173

src/app/index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
const BUILD_TIME = '';
4545

4646
// Substitué par docker_entrypoint.sh :
47-
let substOrDefault = (e, v) => (e[0] !== '$' ? e : v);
48-
const DOCUMENTATION_LINK = substOrDefault("$DOCUMENTATION_LINK", 'https://voyages-sncf-technologies.github.io/hesperides-gui/');
49-
const EVENT_PAGINATION_SIZE = +substOrDefault("$EVENT_PAGINATION_SIZE", '25');
50-
const LOCALCHANGES_TTL = +substOrDefault("$LOCALCHANGES_TTL", '50');
51-
const SUPPORT_URL = substOrDefault("$SUPPORT_URL", '');
52-
const SWAGGER_LINK = substOrDefault("$SWAGGER_LINK", '/rest/swagger-ui.html');
47+
let substOrDefault = (e, v) => (e && e[0] !== '$') ? e : v;
48+
const DOCUMENTATION_LINK = substOrDefault('$DOCUMENTATION_LINK', 'https://voyages-sncf-technologies.github.io/hesperides-gui/');
49+
const EVENT_PAGINATION_SIZE = substOrDefault('$EVENT_PAGINATION_SIZE', '25');
50+
const LOCALCHANGES_TTL = substOrDefault('$LOCALCHANGES_TTL', '50');
51+
const SUPPORT_URL = substOrDefault('$SUPPORT_URL', '');
52+
const SWAGGER_LINK = substOrDefault('$SWAGGER_LINK', '/rest/swagger-ui.html');
5353
delete substOrDefault;
5454
</script>
5555

src/app/menu/menu.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@
136136
{{ 'menu.help.title' | translate}} <i class="fa fa-question"></i>
137137
</button>
138138
<md-menu-content class="menu-item">
139-
<md-menu-item ng-if="swaggerLink">
140-
<md-button ng-click="display_swagger()">Swagger</md-button>
139+
<md-menu-item>
140+
<md-button ng-href="{{swaggerLink}}" target="_blank">Swagger</md-button>
141141
</md-menu-item>
142142
<md-menu-item>
143-
<md-button ng-click="display_hesperides_documentation()">
143+
<md-button ng-href="{{documentationLink}}" target="_blank">
144144
{{ 'menu.help.documentation' | translate}}
145145
</md-button>
146146
</md-menu-item>
@@ -149,8 +149,8 @@
149149
{{ 'menu.help.about' | translate}}
150150
</md-button>
151151
</md-menu-item>
152-
<md-menu-item ng-if="supportUrl">
153-
<md-button href="{{ supportUrl }}" target="_blank">
152+
<md-menu-item>
153+
<md-button href="{{supportUrl}}" target="_blank">
154154
{{ 'menu.help.support' | translate}}
155155
</md-button>
156156
</md-menu-item>

0 commit comments

Comments
 (0)