kopia lustrzana https://github.com/cyoung/stratux
Add messaging pages.
rodzic
f12bdedc4b
commit
1209c01e7f
|
@ -64,6 +64,7 @@
|
|||
<script src="js/j3di-all.min.js"></script>
|
||||
<script src="plates/js/ahrs.js"></script>
|
||||
<script src="plates/js/gps.js"></script>
|
||||
<script src="plates/js/messaging.js"></script>
|
||||
</head>
|
||||
|
||||
<body ng-app="stratux" ng-controller="MainCtrl" ui-prevent-touchmove-defaults>
|
||||
|
@ -83,6 +84,7 @@
|
|||
<a class="list-group-item" href="#/towers"><i class="fa fa-signal"></i> Towers <i class="fa fa-chevron-right pull-right"></i></a>
|
||||
<a class="list-group-item" href="#/logs"><i class="fa fa-file-text-o"></i> Logs <i class="fa fa-chevron-right pull-right"></i></a>
|
||||
<a class="list-group-item" href="#/settings"><i class="fa fa-gear"></i> Settings <i class="fa fa-chevron-right pull-right"></i></a>
|
||||
<a class="list-group-item" href="#/messaging"><i class="fa fa-share"></i> Messaging <i class="fa fa-chevron-right pull-right"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,6 +9,7 @@ var URL_SATELLITES_GET = "http://" + URL_HOST_BASE + "/getSatellites"
|
|||
var URL_STATUS_WS = "ws://" + URL_HOST_BASE + "/status"
|
||||
var URL_TRAFFIC_WS = "ws://" + URL_HOST_BASE + "/traffic";
|
||||
var URL_WEATHER_WS = "ws://" + URL_HOST_BASE + "/weather";
|
||||
var URL_MESSAGING_WS = "ws://" + URL_HOST_BASE + "/iridium";
|
||||
var URL_UPDATE_UPLOAD = "http://" + URL_HOST_BASE + "/updateUpload";
|
||||
var URL_REBOOT = "http://" + URL_HOST_BASE + "/reboot";
|
||||
var URL_SHUTDOWN = "http://" + URL_HOST_BASE + "/shutdown";
|
||||
|
@ -62,7 +63,14 @@ app.config(function ($stateProvider, $urlRouterProvider) {
|
|||
templateUrl: 'plates/settings.html',
|
||||
controller: 'SettingsCtrl',
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.state('messaging', {
|
||||
url: '/messaging',
|
||||
templateUrl: 'plates/messaging.html',
|
||||
controller: 'MessagingCtrl',
|
||||
reloadOnSearch: false
|
||||
});
|
||||
|
||||
$urlRouterProvider.otherwise('/');
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
angular.module('appControllers').controller('MessagingCtrl', MessagingCtrl); // get the main module contollers set
|
||||
MessagingCtrl.$inject = ['$rootScope', '$scope', '$state', '$http', '$interval']; // Inject my dependencies
|
||||
|
||||
// create our controller function with all necessary logic
|
||||
function MessagingCtrl($rootScope, $scope, $state, $http, $interval) {
|
||||
|
||||
$scope.$parent.helppage = 'plates/messaging-help.html';
|
||||
$scope.message_list = [];
|
||||
|
||||
function connect($scope) {
|
||||
if (($scope === undefined) || ($scope === null))
|
||||
return; // we are getting called once after clicking away from the status page
|
||||
|
||||
if (($scope.socket === undefined) || ($scope.socket === null)) {
|
||||
socket = new WebSocket(URL_MESSAGING_WS);
|
||||
$scope.socket = socket; // store socket in scope for enter/exit usage
|
||||
}
|
||||
|
||||
$scope.ConnectState = "Disconnected";
|
||||
|
||||
socket.onopen = function (msg) {
|
||||
$scope.ConnectState = "Connected";
|
||||
};
|
||||
|
||||
socket.onclose = function (msg) {
|
||||
$scope.ConnectState = "Disconnected";
|
||||
$scope.$apply();
|
||||
setTimeout(connect, 1000);
|
||||
};
|
||||
|
||||
socket.onerror = function (msg) {
|
||||
$scope.ConnectState = "Problem";
|
||||
$scope.$apply();
|
||||
};
|
||||
|
||||
socket.onmessage = function (msg) {
|
||||
console.log('Received message update.')
|
||||
|
||||
var message = JSON.parse(msg.data);
|
||||
|
||||
$scope.message_list.unshift(message);
|
||||
|
||||
$scope.$apply();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
$scope.sendData = function() {
|
||||
var t = "";
|
||||
if ($scope.DataInput !== undefined)
|
||||
t = $scope.DataInput;
|
||||
|
||||
sendMsg = {
|
||||
"Command": "send",
|
||||
"Data": t
|
||||
};
|
||||
j = angular.toJson(sendMsg);
|
||||
console.log("heyoo" + j + "\n");
|
||||
$scope.socket.send(j);
|
||||
};
|
||||
|
||||
$state.get('messaging').onExit = function () {
|
||||
// disconnect from the socket
|
||||
if (($scope.socket !== undefined) && ($scope.socket !== null)) {
|
||||
$scope.socket.close();
|
||||
$scope.socket = null;
|
||||
}
|
||||
};
|
||||
|
||||
// Messaging controller tasks.
|
||||
connect($scope); // connect - opens a socket and listens for messages
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
<div class="section text-left help-page">
|
||||
<p>The <strong>Messaging</strong> page provides a method to interface with an Iridium modem to send and receive messages.</p>
|
||||
<p>For each message, the list includes the following details:</p>
|
||||
<ul class="list-simple">
|
||||
<li><strong>Time</strong> - Stratux timestamp for the notification (UTC real time if a GPS is connected)</li>
|
||||
<li><strong>Command</strong> - send/recv/confirm-sent</li>
|
||||
<li><strong>Result</strong> - Queued/Success</li>
|
||||
<li><strong>Data</strong> - Information contained in the message</li>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,59 @@
|
|||
<div class="col-sm-12">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Send</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group reset-flow">
|
||||
<label class="control-label col-xs-1">Data</label>
|
||||
<input class="col-xs-9" type="string" required ng-model="DataInput" placeholder="Text to send" />
|
||||
<div class="col-xs-1">
|
||||
<button class="btn btn-primary btn-block" ui-turn-on="modalSend">Send</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-heading">
|
||||
<span class="panel_label">Messaging</span>
|
||||
<span ng-show="ConnectState == 'Connected'" class="label label-success">{{ConnectState}}</span>
|
||||
<span ng-hide="ConnectState == 'Connected'" class="label label-danger">{{ConnectState}}</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<span class="col-xs-2">Time</span>
|
||||
<span class="col-xs-2">Command</span>
|
||||
<span class="col-xs-2">Result</span>
|
||||
<span class="col-xs-4">Data</span>
|
||||
</div>
|
||||
|
||||
<div class="row" ng-repeat="message in message_list | orderBy: received">
|
||||
<div class="separator"></div>
|
||||
<span class="col-xs-2">{{message.Time}}</span>
|
||||
<span class="col-xs-2">{{message.Command}}</span>
|
||||
<span class="col-xs-2">{{message.Result}}</span>
|
||||
<span class="col-xs-4">{{message.Data}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ui-content-for="modals">
|
||||
<div class="modal" ui-if="modalSend" ui-state="modalSend">
|
||||
<div class="modal-overlay "></div>
|
||||
<div class="vertical-alignment-helper center-block">
|
||||
<div class="modal-dialog vertical-align-center">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button class="close"
|
||||
ui-turn-off="modalSend"></button>
|
||||
<h4 class="modal-title">Are you really sure?</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Do you wish to send this message?</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a ui-turn-off="modalSend" class="btn btn-default">Cancel</a>
|
||||
<a ng-click="sendData()" ui-turn-off="modalSend" class="btn btn-primary">Send</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Ładowanie…
Reference in New Issue