admin: Use relative path to call API

This commit is contained in:
nemunaire 2021-07-21 23:17:47 +02:00
parent 8f1b44e3dd
commit 29607981e4
5 changed files with 87 additions and 87 deletions

View file

@ -178,161 +178,161 @@ angular.module("FICApp")
angular.module("FICApp")
.factory("Version", function($resource) {
return $resource("/api/version")
return $resource("api/version")
})
.factory("Timestamp", function($resource) {
return $resource("/api/timestamps.json")
return $resource("api/timestamps.json")
})
.factory("Health", function($resource) {
return $resource("/api/health.json")
return $resource("api/health.json")
})
.factory("Monitor", function($resource) {
return $resource("/api/monitor/:machineId", { machineId: '@id' })
return $resource("api/monitor/:machineId", { machineId: '@id' })
})
.factory("Event", function($resource) {
return $resource("/api/events/:eventId", { eventId: '@id' }, {
return $resource("api/events/:eventId", { eventId: '@id' }, {
'update': {method: 'PUT'},
})
})
.factory("Claim", function($resource) {
return $resource("/api/claims/:claimId", { claimId: '@id' }, {
return $resource("api/claims/:claimId", { claimId: '@id' }, {
'update': {method: 'PUT'},
})
})
.factory("ClaimAssignee", function($resource) {
return $resource("/api/claims-assignees/:assigneeId", { assigneeId: '@id' }, {
return $resource("api/claims-assignees/:assigneeId", { assigneeId: '@id' }, {
'update': {method: 'PUT'},
})
})
.factory("Certificate", function($resource) {
return $resource("/api/certs/:serial", { serial: '@id' }, {
return $resource("api/certs/:serial", { serial: '@id' }, {
'update': {method: 'PUT'},
})
})
.factory("CACertificate", function($resource) {
return $resource("/api/ca/:serial", { serial: '@id' })
return $resource("api/ca/:serial", { serial: '@id' })
})
.factory("File", function($resource) {
return $resource("/api/files/:fileId", { fileId: '@id' })
return $resource("api/files/:fileId", { fileId: '@id' })
})
.factory("ROSettings", function($resource) {
return $resource("/api/settings-ro.json")
return $resource("api/settings-ro.json")
})
.factory("Settings", function($resource) {
return $resource("/api/settings.json", null, {
return $resource("api/settings.json", null, {
'update': {method: 'PUT'},
})
})
.factory("Scene", function($resource) {
return $resource("/api/public/:screenId", { screenId: '@id' }, {
return $resource("api/public/:screenId", { screenId: '@id' }, {
'update': {method: 'PUT'},
})
})
.factory("Team", function($resource) {
return $resource("/api/teams/:teamId", { teamId: '@id' }, {
return $resource("api/teams/:teamId", { teamId: '@id' }, {
'update': {method: 'PUT'},
})
})
.factory("TeamCertificate", function($resource) {
return $resource("/api/teams/:teamId/certificates", { teamId: '@id' })
return $resource("api/teams/:teamId/certificates", { teamId: '@id' })
})
.factory("TeamAssociation", function($resource) {
return $resource("/api/teams/:teamId/associations/:assoc", { teamId: '@teamId', assoc: '@assoc' })
return $resource("api/teams/:teamId/associations/:assoc", { teamId: '@teamId', assoc: '@assoc' })
})
.factory("TeamMember", function($resource) {
return $resource("/api/teams/:teamId/members", { teamId: '@id' }, {
return $resource("api/teams/:teamId/members", { teamId: '@id' }, {
'save': {method: 'PUT'},
})
})
.factory("TeamMy", function($resource) {
return $resource("/api/teams/:teamId/my.json", { teamId: '@id' })
return $resource("api/teams/:teamId/my.json", { teamId: '@id' })
})
.factory("Teams", function($resource) {
return $resource("/api/teams.json")
return $resource("api/teams.json")
})
.factory("TeamHistory", function($resource) {
return $resource("/api/teams/:teamId/history.json", { teamId: '@id' })
return $resource("api/teams/:teamId/history.json", { teamId: '@id' })
})
.factory("TeamScore", function($resource) {
return $resource("/api/teams/:teamId/score-grid.json", { teamId: '@id' })
return $resource("api/teams/:teamId/score-grid.json", { teamId: '@id' })
})
.factory("TeamStats", function($resource) {
return $resource("/api/teams/:teamId/stats.json", { teamId: '@id' })
return $resource("api/teams/:teamId/stats.json", { teamId: '@id' })
})
.factory("TeamPresence", function($resource) {
return $resource("/api/teams/:teamId/tries", { teamId: '@id' })
return $resource("api/teams/:teamId/tries", { teamId: '@id' })
})
.factory("Theme", function($resource) {
return $resource("/api/themes/:themeId", { themeId: '@id' }, {
return $resource("api/themes/:themeId", { themeId: '@id' }, {
update: {method: 'PUT'}
});
})
.factory("Themes", function($resource) {
return $resource("/api/themes.json", null, {
return $resource("api/themes.json", null, {
'get': {method: 'GET'},
})
})
.factory("ThemedExercice", function($resource) {
return $resource("/api/themes/:themeId/exercices/:exerciceId", { themeId: '@id', exerciceId: '@idExercice' }, {
return $resource("api/themes/:themeId/exercices/:exerciceId", { themeId: '@id', exerciceId: '@idExercice' }, {
update: {method: 'PUT'}
})
})
.factory("Exercice", function($resource) {
return $resource("/api/exercices/:exerciceId", { exerciceId: '@id' }, {
return $resource("api/exercices/:exerciceId", { exerciceId: '@id' }, {
update: {method: 'PUT'},
patch: {method: 'PATCH'}
})
})
.factory("ExerciceClaims", function($resource) {
return $resource("/api/exercices/:exerciceId/claims", { exerciceId: '@idExercice'})
return $resource("api/exercices/:exerciceId/claims", { exerciceId: '@idExercice'})
})
.factory("ExerciceTags", function($resource) {
return $resource("/api/exercices/:exerciceId/tags", { exerciceId: '@idExercice'}, {
return $resource("api/exercices/:exerciceId/tags", { exerciceId: '@idExercice'}, {
update: {method: 'PUT'}
})
})
.factory("ExerciceHistory", function($resource) {
return $resource("/api/exercices/:exerciceId/history.json", { exerciceId: '@id' })
return $resource("api/exercices/:exerciceId/history.json", { exerciceId: '@id' })
})
.factory("ExercicesStats", function($resource) {
return $resource("/api/themes/:themeId/exercices_stats.json", { themeId: '@id' })
return $resource("api/themes/:themeId/exercices_stats.json", { themeId: '@id' })
})
.factory("ExerciceStats", function($resource) {
return $resource("/api/exercices/:exerciceId/stats.json", { exerciceId: '@id' })
return $resource("api/exercices/:exerciceId/stats.json", { exerciceId: '@id' })
})
.factory("ExerciceFile", function($resource) {
return $resource("/api/exercices/:exerciceId/files/:fileId", { exerciceId: '@idExercice', fileId: '@id' }, {
return $resource("api/exercices/:exerciceId/files/:fileId", { exerciceId: '@idExercice', fileId: '@id' }, {
update: {method: 'PUT'}
})
})
.factory("ExerciceHint", function($resource) {
return $resource("/api/exercices/:exerciceId/hints/:hintId", { exerciceId: '@idExercice', hintId: '@id' }, {
return $resource("api/exercices/:exerciceId/hints/:hintId", { exerciceId: '@idExercice', hintId: '@id' }, {
update: {method: 'PUT'}
})
})
.factory("ExerciceHintDeps", function($resource) {
return $resource("/api/exercices/:exerciceId/hints/:hintId/dependancies", { exerciceId: '@idExercice', hintId: '@id' })
return $resource("api/exercices/:exerciceId/hints/:hintId/dependancies", { exerciceId: '@idExercice', hintId: '@id' })
})
.factory("ExerciceFlag", function($resource) {
return $resource("/api/exercices/:exerciceId/flags/:flagId", { exerciceId: '@idExercice', flagId: '@id' }, {
return $resource("api/exercices/:exerciceId/flags/:flagId", { exerciceId: '@idExercice', flagId: '@id' }, {
update: {method: 'PUT'}
})
})
.factory("ExerciceFlagChoices", function($resource) {
return $resource("/api/exercices/:exerciceId/flags/:flagId/choices/:choiceId", { exerciceId: '@idExercice', flagId: '@idFlag', choiceId: '@id' }, {
return $resource("api/exercices/:exerciceId/flags/:flagId/choices/:choiceId", { exerciceId: '@idExercice', flagId: '@idFlag', choiceId: '@id' }, {
'update': {method: 'PUT'},
})
})
.factory("ExerciceFlagDeps", function($resource) {
return $resource("/api/exercices/:exerciceId/flags/:flagId/dependancies", { exerciceId: '@idExercice', flagId: '@id' })
return $resource("api/exercices/:exerciceId/flags/:flagId/dependancies", { exerciceId: '@idExercice', flagId: '@id' })
})
.factory("ExerciceMCQFlag", function($resource) {
return $resource("/api/exercices/:exerciceId/quiz/:mcqId", { exerciceId: '@idExercice', mcqId: '@id' }, {
return $resource("api/exercices/:exerciceId/quiz/:mcqId", { exerciceId: '@idExercice', mcqId: '@id' }, {
update: {method: 'PUT'}
})
})
.factory("ExerciceMCQDeps", function($resource) {
return $resource("/api/exercices/:exerciceId/quiz/:mcqId/dependancies", { exerciceId: '@idExercice', mcqId: '@id' })
return $resource("api/exercices/:exerciceId/quiz/:mcqId/dependancies", { exerciceId: '@idExercice', mcqId: '@id' })
});
angular.module("FICApp")
@ -431,7 +431,7 @@ angular.module("FICApp")
.run(function($rootScope, $http, $interval, Settings) {
function refresh() {
$http.get("/api/settings.json").then(function(response) {
$http.get("api/settings.json").then(function(response) {
response.data.start = new Date(response.data.start);
response.data.end = new Date(response.data.end);
response.data.generation = new Date(response.data.generation);
@ -517,7 +517,7 @@ angular.module("FICApp")
refreshSyncReport()
var progressInterval = $interval(function() {
$http.get("/api/sync/deep").then(function(response) {
$http.get("api/sync/deep").then(function(response) {
if (response.data.progress && response.data.progress != 255)
needRefreshSyncReportWhenReady = true;
else if (needRefreshSyncReportWhenReady)
@ -586,7 +586,7 @@ angular.module("FICApp")
$scope.addToast('warning', txts[type], 'Êtes-vous sûr de vouloir continuer ?',
function() {
if (confirm("Êtes-vous vraiment sûr ?\n" + txts[type])) {
$http.post("/api/reset", {"type": type}).then(function(time) {
$http.post("api/reset", {"type": type}).then(function(time) {
$scope.addToast('success', type + 'reseted');
$location.url("/");
}, function(response) {
@ -600,10 +600,10 @@ angular.module("FICApp")
$scope.deepSync = function(theme) {
if (theme) {
question = 'Faire une synchronisation intégrale du thème ' + theme.name + ' ?'
url = "/api/sync/deep/" + theme.id
url = "api/sync/deep/" + theme.id
} else {
question = 'Faire une synchronisation intégrale ?'
url = "/api/sync/deep"
url = "api/sync/deep"
}
$scope.addToast('warning', question, '',
function() {
@ -621,7 +621,7 @@ angular.module("FICApp")
$scope.addToast('warning', 'Faire une synchronisation profonde rapide, sans s\'occuper des fichiers ?', '',
function() {
$scope.deepSyncInProgress = true;
$http.post("/api/sync/speed").then(function() {
$http.post("api/sync/speed").then(function() {
$scope.deepSyncInProgress = false;
$scope.addToast('success', 'Synchronisation profonde rapide terminée.', '<a href="check_import.html">Voir le rapport</a>.', 15000);
}, function(response) {
@ -699,7 +699,7 @@ angular.module("FICApp")
};
$scope.generateCA = function() {
$http.post("/api/ca/new", $scope.newca).then(function() {
$http.post("api/ca/new", $scope.newca).then(function() {
$scope.ca = CACertificate.get();
}, function(response) {
$scope.addToast('danger', 'An error occurs when generating CA:', response.data.errmsg);
@ -710,21 +710,21 @@ angular.module("FICApp")
};
$scope.generateCert = function() {
$http.post("/api/certs").then(function() {
$http.post("api/certs").then(function() {
$scope.certificates = Certificate.query();
}, function(response) {
$scope.addToast('danger', 'An error occurs when generating certificate:', response.data.errmsg);
});
};
$scope.generateHtpasswd = function() {
$http.post("/api/htpasswd").then(function() {
$http.post("api/htpasswd").then(function() {
$scope.addToast('success', 'Fichier htpasswd généré avec succès');
}, function(response) {
$scope.addToast('danger', 'An error occurs when generating htpasswd file:', response.data.errmsg);
});
};
$scope.removeHtpasswd = function() {
$http.delete("/api/htpasswd").then(function() {
$http.delete("api/htpasswd").then(function() {
$scope.addToast('success', 'Fichier htpasswd supprimé avec succès');
}, function(response) {
$scope.addToast('danger', 'An error occurs when deleting htpasswd file:', response.data.errmsg);
@ -1078,7 +1078,7 @@ angular.module("FICApp")
};
$scope.checksum = function(f) {
$http({
url: "/api/files/" + f.id + "/check",
url: "api/files/" + f.id + "/check",
method: "POST"
}).then(function(response) {
f.err = true;
@ -1235,7 +1235,7 @@ angular.module("FICApp")
})
.controller("ClaimLastUpdateController", function($scope, $http) {
$scope.init = function(claim) {
$http.get("/api/claims/" + claim.id + "/last_update").then(function(response) {
$http.get("api/claims/" + claim.id + "/last_update").then(function(response) {
if (response.data)
$scope.last_update = response.data;
else
@ -1301,7 +1301,7 @@ angular.module("FICApp")
}
$scope.updateDescription = function(description) {
$http({
url: "/api/claims/" + $scope.claim.id + "/descriptions",
url: "api/claims/" + $scope.claim.id + "/descriptions",
method: "PUT",
data: description
}).then(function(response) {
@ -1314,7 +1314,7 @@ angular.module("FICApp")
}
$scope.saveDescription = function() {
$http({
url: "/api/claims/" + $scope.claim.id,
url: "api/claims/" + $scope.claim.id,
method: "POST",
data: {
"id_assignee": $scope.whoami,
@ -1387,7 +1387,7 @@ angular.module("FICApp")
$scope.sync = function() {
$scope.inSync = true;
$http({
url: "/api/sync/themes",
url: "api/sync/themes",
method: "POST"
}).then(function(response) {
$scope.inSync = false;
@ -1429,7 +1429,7 @@ angular.module("FICApp")
.controller("AllExercicesListController", function($scope, Exercice, Theme, $routeParams, $location, $rootScope, $http, $filter) {
$http({
url: "/api/themes.json",
url: "api/themes.json",
method: "GET"
}).then(function(response) {
$scope.themes = response.data
@ -1504,11 +1504,11 @@ angular.module("FICApp")
angular.forEach($scope.exercices, function(ex) {
if ($scope.syncFiles)
work.push("/api/sync/exercices/" + ex.id + "/files");
work.push("api/sync/exercices/" + ex.id + "/files");
if ($scope.syncHints)
work.push("/api/sync/exercices/" + ex.id + "/hints");
work.push("api/sync/exercices/" + ex.id + "/hints");
if ($scope.syncFlags)
work.push("/api/sync/exercices/" + ex.id + "/flags");
work.push("api/sync/exercices/" + ex.id + "/flags");
});
$scope.total = work.length;
go();
@ -1530,7 +1530,7 @@ angular.module("FICApp")
$scope.syncExo = function() {
$scope.inSync = true;
$http({
url: "/api/sync/themes/" + $scope.theme.id + "/exercices",
url: "api/sync/themes/" + $scope.theme.id + "/exercices",
method: "POST"
}).then(function(response) {
$scope.inSync = false;
@ -1553,7 +1553,7 @@ angular.module("FICApp")
$scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId });
}
$http({
url: "/api/themes.json",
url: "api/themes.json",
method: "GET"
}).then(function(response) {
$scope.themes = response.data
@ -1574,7 +1574,7 @@ angular.module("FICApp")
$scope.syncExo = function() {
$scope.inSync = true;
$http({
url: "/api/sync/themes/" + $scope.exercice.id_theme + "/exercices/" + $routeParams.exerciceId,
url: "api/sync/themes/" + $scope.exercice.id_theme + "/exercices/" + $routeParams.exerciceId,
method: "POST"
}).then(function(response) {
$scope.inSync = false;
@ -1666,7 +1666,7 @@ angular.module("FICApp")
};
if (target) {
$http({
url: "/api/exercices/" + $routeParams.exerciceId + "/history.json",
url: "api/exercices/" + $routeParams.exerciceId + "/history.json",
method: "PATCH",
data: target
}).then(function(response) {
@ -1680,7 +1680,7 @@ angular.module("FICApp")
}
$scope.delHistory = function(row) {
$http({
url: "/api/exercices/" + $routeParams.exerciceId + "/history.json",
url: "api/exercices/" + $routeParams.exerciceId + "/history.json",
method: "DELETE",
data: row
}).then(function(response) {
@ -1704,7 +1704,7 @@ angular.module("FICApp")
}
$scope.deleteFileDep = function() {
$http({
url: "/api//files/" + this.file.id + "/dependancies/" + this.dep.id,
url: "api//files/" + this.file.id + "/dependancies/" + this.dep.id,
method: "DELETE"
}).then(function(response) {
$scope.files = ExerciceFile.query({ exerciceId: $routeParams.exerciceId });
@ -1722,7 +1722,7 @@ angular.module("FICApp")
$scope.syncFiles = function() {
$scope.inSync = true;
$http({
url: "/api/sync/exercices/" + $routeParams.exerciceId + "/files",
url: "api/sync/exercices/" + $routeParams.exerciceId + "/files",
method: "POST"
}).then(function(response) {
$scope.inSync = false;
@ -1765,7 +1765,7 @@ angular.module("FICApp")
$scope.syncHints = function() {
$scope.inSync = true;
$http({
url: "/api/sync/exercices/" + $routeParams.exerciceId + "/hints",
url: "api/sync/exercices/" + $routeParams.exerciceId + "/hints",
method: "POST"
}).then(function(response) {
$scope.inSync = false;
@ -1830,7 +1830,7 @@ angular.module("FICApp")
if (flag.test_str) {
$http({
url: "/api/exercices/" + $routeParams.exerciceId + "/flags/" + flag.id + "/try",
url: "api/exercices/" + $routeParams.exerciceId + "/flags/" + flag.id + "/try",
data: {"flag": flag.test_str},
method: "POST"
}).then(function(response) {
@ -1846,7 +1846,7 @@ angular.module("FICApp")
$scope.syncFlags = function() {
$scope.inSync = true;
$http({
url: "/api/sync/exercices/" + $routeParams.exerciceId + "/flags",
url: "api/sync/exercices/" + $routeParams.exerciceId + "/flags",
method: "POST"
}).then(function(response) {
$scope.inSync = false;
@ -1962,7 +1962,7 @@ angular.module("FICApp")
};
$scope.desactiveTeams = function() {
$http.post("/api/disableinactiveteams").then(function() {
$http.post("api/disableinactiveteams").then(function() {
$scope.teams = Team.query();
}, function(response) {
$scope.addToast('danger', 'An error occurs when disabling inactive teams:', response.data.errmsg);
@ -2032,7 +2032,7 @@ angular.module("FICApp")
$scope.dissociateCertificate = function(certificate) {
$http({
url: "/api/certs/" + certificate.id,
url: "api/certs/" + certificate.id,
method: "PUT",
data: {
id_team: null
@ -2087,7 +2087,7 @@ angular.module("FICApp")
};
if (target) {
$http({
url: "/api/exercices/" + $("#updHistory").data("primary") + "/history.json",
url: "api/exercices/" + $("#updHistory").data("primary") + "/history.json",
method: "PATCH",
data: target
}).then(function(response) {
@ -2101,7 +2101,7 @@ angular.module("FICApp")
}
$scope.delHistory = function(row) {
$http({
url: "/api/teams/" + $routeParams.teamId + "/history.json",
url: "api/teams/" + $routeParams.teamId + "/history.json",
method: "DELETE",
data: row
}).then(function(response) {