diff --git a/src/app/routes/operations/operation.html b/src/app/routes/operations/operation.html
index 1644933..686f499 100644
--- a/src/app/routes/operations/operation.html
+++ b/src/app/routes/operations/operation.html
@@ -9,6 +9,8 @@
+
+
diff --git a/src/index.js b/src/index.js
index d9a5176..3900e44 100644
--- a/src/index.js
+++ b/src/index.js
@@ -14,12 +14,17 @@ var app = angular.module('app', [
app.constant('ApiConfig', {
BASE_API: 'https://api.anrop.se',
+ BASE_AAR_API: 'https://api.aar.anrop.se',
BASE_ARMA3SYNC_API: 'https://arma3sync.anrop.se/manager/api',
BASE_PWS_API: 'https://playwithsix.anrop.se',
BASE_STEAM_WORKSHOP_API: 'https://steam-workshop.anrop.se',
BASE_STREAMS_API: 'https://streams.anrop.se'
})
+app.constant('WebConfig', {
+ BASE_AAR_WEB: 'https://aar.anrop.se'
+})
+
app.config(function ($locationProvider, $routeProvider) {
$locationProvider.html5Mode(true)
$routeProvider
diff --git a/src/operations/controllers/aar_controller.js b/src/operations/controllers/aar_controller.js
new file mode 100644
index 0000000..939d622
--- /dev/null
+++ b/src/operations/controllers/aar_controller.js
@@ -0,0 +1,23 @@
+angular.module('operations').controller('AARCtrl', function ($scope, WebConfig, AARSvc) {
+ $scope.aarUrl = function (aar) {
+ return WebConfig.BASE_AAR_WEB + '/missions/' + aar.aar_id
+ }
+
+ $scope.load = function () {
+ AARSvc.operation($scope.operationId).then(function (aars) {
+ aars.forEach(function (aar) {
+ AARSvc.mission(aar.aar_id).then(function (info) {
+ Object.assign(aar, {
+ length: info.length,
+ name: info.name,
+ world: info.world
+ })
+ })
+ })
+
+ $scope.aars = aars
+ })
+ }
+
+ $scope.load()
+})
diff --git a/src/operations/controllers/aar_search_controller.js b/src/operations/controllers/aar_search_controller.js
new file mode 100644
index 0000000..36a8e2c
--- /dev/null
+++ b/src/operations/controllers/aar_search_controller.js
@@ -0,0 +1,31 @@
+angular.module('operations').controller('AARSearchCtrl', function ($scope, $uibModalInstance, WebConfig, AARSvc) {
+ $scope.aars = []
+ $scope.loading = false
+
+ $scope.aarUrl = function (aar) {
+ return WebConfig.BASE_AAR_WEB + '/missions/' + aar.id
+ }
+
+ $scope.load = function (query) {
+ $scope.aars = []
+ $scope.loading = true
+ AARSvc.missions().then(function (aars) {
+ var operationDate = new Date($scope.operation.start)
+ $scope.aars = aars.filter(function (aar) {
+ var aarDate = new Date(aar.created_at)
+ return (
+ aarDate.getFullYear() === operationDate.getFullYear() &&
+ aarDate.getMonth() === operationDate.getMonth() &&
+ aarDate.getDate() === operationDate.getDate()
+ )
+ })
+ $scope.loading = false
+ })
+ }
+
+ $scope.close = function () {
+ $uibModalInstance.dismiss('cancel')
+ }
+
+ $scope.load()
+})
diff --git a/src/operations/controllers/edit_aar_controller.js b/src/operations/controllers/edit_aar_controller.js
new file mode 100644
index 0000000..cb4a48b
--- /dev/null
+++ b/src/operations/controllers/edit_aar_controller.js
@@ -0,0 +1,59 @@
+angular.module('operations').controller('EditAARCtrl', function ($scope, $uibModal, WebConfig, AARSvc, OperationSvc) {
+ $scope.add = function (data) {
+ var found = $scope.aars.filter(function (aar) {
+ return aar.aar_id === data.id
+ })
+
+ if (found.length === 0) {
+ return AARSvc.add($scope.operationId, { aar_id: data.id }).then(function () {
+ loadAARs()
+ return this
+ })
+ }
+ }
+
+ $scope.aarUrl = function (aar) {
+ return WebConfig.BASE_AAR_WEB + '/missions/' + aar.aar_id
+ }
+
+ $scope.delete = function (aar) {
+ AARSvc.delete($scope.operationId, aar.id).then(function () {
+ loadAARs()
+ return this
+ })
+ }
+
+ $scope.search = function () {
+ $uibModal.open({
+ template: require('../templates/aar_search.html'),
+ controller: 'AARSearchCtrl',
+ scope: $scope
+ }).result.then(function () {
+
+ }, function () {
+
+ })
+ }
+
+ var loadAARs = function () {
+ OperationSvc.operation($scope.operationId).then(function (operation) {
+ $scope.operation = operation
+ })
+
+ AARSvc.operation($scope.operationId).then(function (aars) {
+ aars.forEach(function (aar) {
+ AARSvc.mission(aar.aar_id).then(function (info) {
+ Object.assign(aar, {
+ length: info.length,
+ name: info.name,
+ world: info.world
+ })
+ })
+ })
+
+ $scope.aars = aars
+ })
+ }
+
+ loadAARs()
+})
diff --git a/src/operations/directives/aar_controller.js b/src/operations/directives/aar_controller.js
new file mode 100644
index 0000000..70c8682
--- /dev/null
+++ b/src/operations/directives/aar_controller.js
@@ -0,0 +1,9 @@
+angular.module('operations').directive('aarController', function () {
+ return {
+ controller: 'AARCtrl',
+ scope: {
+ operationId: '='
+ },
+ template: require('../templates/aar_controller.html')
+ }
+})
diff --git a/src/operations/directives/edit_aar_controller.js b/src/operations/directives/edit_aar_controller.js
new file mode 100644
index 0000000..5663458
--- /dev/null
+++ b/src/operations/directives/edit_aar_controller.js
@@ -0,0 +1,9 @@
+angular.module('operations').directive('editAarController', function () {
+ return {
+ controller: 'EditAARCtrl',
+ scope: {
+ operationId: '='
+ },
+ template: require('../templates/edit_aar_controller.html')
+ }
+})
diff --git a/src/operations/services/aar.js b/src/operations/services/aar.js
new file mode 100644
index 0000000..7f753ae
--- /dev/null
+++ b/src/operations/services/aar.js
@@ -0,0 +1,31 @@
+angular.module('operations').factory('AARSvc', function ($http, ApiConfig) {
+ return {
+ missions: function () {
+ return $http.get(ApiConfig.BASE_AAR_API + '/missions').then(function (response) {
+ return response.data
+ })
+ },
+ mission: function (id) {
+ return $http.get(ApiConfig.BASE_AAR_API + '/missions/' + id).then(function (response) {
+ return response.data
+ })
+ },
+ operation: function (operationId) {
+ return $http.get(ApiConfig.BASE_API + '/operations/' + operationId + '/aar').then(function (response) {
+ return response.data
+ })
+ },
+ add: function (operationId, data) {
+ return $http.post(ApiConfig.BASE_API + '/operations/' + operationId + '/aar', {
+ aar: data
+ }).then(function (response) {
+ return response.data
+ })
+ },
+ delete: function (operationId, id) {
+ return $http.delete(ApiConfig.BASE_API + '/operations/' + operationId + '/aar/' + id).then(function (response) {
+ return response.data
+ })
+ }
+ }
+})
diff --git a/src/operations/templates/aar_controller.html b/src/operations/templates/aar_controller.html
new file mode 100644
index 0000000..6c864ce
--- /dev/null
+++ b/src/operations/templates/aar_controller.html
@@ -0,0 +1,19 @@
+
diff --git a/src/operations/templates/aar_search.html b/src/operations/templates/aar_search.html
new file mode 100644
index 0000000..96d75bd
--- /dev/null
+++ b/src/operations/templates/aar_search.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+ Inga matchingar
+
+
+
+
Matchningar: {{ aars.length }}
+
+
+
+
diff --git a/src/operations/templates/edit_aar_controller.html b/src/operations/templates/edit_aar_controller.html
new file mode 100644
index 0000000..e1fa40e
--- /dev/null
+++ b/src/operations/templates/edit_aar_controller.html
@@ -0,0 +1,24 @@
+
AAR
+
+
+
+
+
+
+ {{ aar.name }}
+ {{ aar.length * 1000 | date: 'H:mm:ss': 'UTC' }}
+ |
+
+
+
+
+
+
+