-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
angular.module('operations').directive('aarController', function () { | ||
return { | ||
controller: 'AARCtrl', | ||
scope: { | ||
operationId: '=' | ||
}, | ||
template: require('../templates/aar_controller.html') | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
angular.module('operations').directive('editAarController', function () { | ||
return { | ||
controller: 'EditAARCtrl', | ||
scope: { | ||
operationId: '=' | ||
}, | ||
template: require('../templates/edit_aar_controller.html') | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div ng-if="aars.length > 0"> | ||
<div class="block-title">AAR</div> | ||
<div class="bordered-block"> | ||
<table width="100%" cellspacing="0"> | ||
<tr ng-repeat="aar in aars | orderBy: 'name' track by aar.id"> | ||
<td style="vertical-align: middle" ng-class-odd="'tbl1'" ng-class-even="'tbl2'"> | ||
<div ng-if="aar.name"> | ||
<a target="_blank" ng-href="{{aarUrl(aar)}}">{{ aar.name }}</a> | ||
<small>{{ aar.length * 1000 | date: 'H:mm:ss': 'UTC' }}</small> | ||
</div> | ||
|
||
<div ng-if="!aar.name"> | ||
<a target="_blank" ng-href="{{aarUrl(aar)}}">{{ aar.aar_id }}</a> | ||
</div> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<div class="modal-header"> | ||
<h3 class="modal-title">Lägg till AAR</h3> | ||
</div> | ||
<div class="modal-body"> | ||
<div class="progress" ng-if="loading" style="margin-top: 20px; margin-bottom: 10px;"> | ||
<div class="progress-bar progress-bar-striped active" role="progressbar" style="width: 100%"> | ||
</div> | ||
</div> | ||
|
||
<h4 ng-if="!loading && aars.length === 0"> | ||
Inga matchingar | ||
</h4> | ||
|
||
<div ng-if="aars.length > 0"> | ||
<h4>Matchningar: {{ aars.length }}</h4> | ||
<table class="table"> | ||
<tbody> | ||
<tr ng-repeat="aar in aars"> | ||
<td ng-class-odd="'tbl1'" ng-class-even="'tbl2'"> | ||
<p> | ||
<a ng-href="{{aarUrl(aar)}}" target="_blank"> | ||
<strong>{{ aar.name }}</strong> | ||
</a> | ||
<small>{{ aar.length * 1000 | date: 'H:mm:ss': 'UTC' }}</small> | ||
</p> | ||
</td> | ||
<td ng-class-odd="'tbl1'" ng-class-even="'tbl2'"> | ||
<p> | ||
<a class="btn btn-primary pull-right" ng-click="add(aar)"> | ||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> | ||
Lägg till | ||
</a> | ||
<div class="clearfix"></div> | ||
</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button class="btn btn-primary" ng-click="close()">Stäng</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div class="block-title">AAR</div> | ||
<div class="bordered-block ng-hide" ng-show="aars"> | ||
<table width="100%" cellspacing="0"> | ||
<tr ng-repeat="aar in aars | orderBy: 'name' track by aar.id"> | ||
<td style="vertical-align: middle" ng-class-odd="'tbl1'" ng-class-even="'tbl2'"> | ||
<form style="display: inline-block"> | ||
<button type="submit" class="btn btn-danger" ng-click="delete(aar)"> | ||
<span class="glyphicon glyphicon-trash" aria-hidden="true" title="Ta bort"></span> | ||
</button> | ||
</form> | ||
|
||
<a ng-href="{{aarUrl(aar)}}" target="_blank">{{ aar.name }}</a> | ||
<small>{{ aar.length * 1000 | date: 'H:mm:ss': 'UTC' }}</small> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<div ng-show="operation" style="padding: 10px;"> | ||
<button class="btn btn-primary" ng-click="search()"> | ||
<span class="glyphicon glyphicon-search"></span> | ||
Lägg till AAR | ||
</button> | ||
</div> | ||
</div> |