mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-08 08:26:15 +00:00
Centralize JS router URL generation
This commit is contained in:
parent
71eac57907
commit
f70fc2c080
@ -104,16 +104,20 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
$scope.selectedContact = {};
|
$scope.selectedContact = {};
|
||||||
$scope.lastSearch = '';
|
$scope.lastSearch = '';
|
||||||
|
|
||||||
|
$scope.generateUrl = function (endpoint) {
|
||||||
|
return OC.generateUrl('/apps/ocsms' + endpoint);
|
||||||
|
};
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
$scope.sendCountry = function () {
|
$scope.sendCountry = function () {
|
||||||
$.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()});
|
$.post($scope.generateUrl('/set/country'),{'country': $('select[name=intl_phone]').val()});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setMessageLimit = function () {
|
$scope.setMessageLimit = function () {
|
||||||
if ($scope.setting_msgLimit === null || $scope.setting_msgLimit === undefined) {
|
if ($scope.setting_msgLimit === null || $scope.setting_msgLimit === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.post(OC.generateUrl('/apps/ocsms/set/msglimit'),{'limit': $scope.setting_msgLimit});
|
$.post($scope.generateUrl('/set/msglimit'),{'limit': $scope.setting_msgLimit});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setNotificationSetting = function () {
|
$scope.setNotificationSetting = function () {
|
||||||
@ -121,11 +125,11 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
$scope.setting_enableNotifications = 0;
|
$scope.setting_enableNotifications = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.post(OC.generateUrl('/apps/ocsms/set/notification_state'),{'notification': $scope.setting_enableNotifications});
|
$.post($scope.generateUrl('/set/notification_state'),{'notification': $scope.setting_enableNotifications});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setContactOrderSetting = function () {
|
$scope.setContactOrderSetting = function () {
|
||||||
$.post(OC.generateUrl('/apps/ocsms/set/contact_order'),
|
$.post($scope.generateUrl('/set/contact_order'),
|
||||||
{
|
{
|
||||||
'attribute': $scope.setting_contactOrder,
|
'attribute': $scope.setting_contactOrder,
|
||||||
'reverse': $scope.setting_contactOrderReverse
|
'reverse': $scope.setting_contactOrderReverse
|
||||||
@ -154,7 +158,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
$scope.messages = [];
|
$scope.messages = [];
|
||||||
$scope.lastConvMessageDate = 0;
|
$scope.lastConvMessageDate = 0;
|
||||||
|
|
||||||
$.getJSON(OC.generateUrl('/apps/ocsms/front-api/v1/conversation'), {'phoneNumber': $scope.selectedContact.nav},
|
$.getJSON($scope.generateUrl('/front-api/v1/conversation'), {'phoneNumber': $scope.selectedContact.nav},
|
||||||
function(jsondata, status) {
|
function(jsondata, status) {
|
||||||
var phoneNumberLabel = $scope.selectedContact.nav;
|
var phoneNumberLabel = $scope.selectedContact.nav;
|
||||||
|
|
||||||
@ -185,7 +189,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
$scope.refreshConversation = function() {
|
$scope.refreshConversation = function() {
|
||||||
$.getJSON(OC.generateUrl('/apps/ocsms/front-api/v1/conversation'),
|
$.getJSON($scope.generateUrl('/ocsms/front-api/v1/conversation'),
|
||||||
{
|
{
|
||||||
'phoneNumber': $scope.selectedContact.nav,
|
'phoneNumber': $scope.selectedContact.nav,
|
||||||
"lastDate": $scope.lastConvMessageDate
|
"lastDate": $scope.lastConvMessageDate
|
||||||
@ -210,7 +214,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
};
|
};
|
||||||
$scope.checkNewMessages = function() {
|
$scope.checkNewMessages = function() {
|
||||||
g_unreadCountAllConv = 0;
|
g_unreadCountAllConv = 0;
|
||||||
$.getJSON(OC.generateUrl('/apps/ocsms/front-api/v1/new_messages'),
|
$.getJSON($scope.generateUrl('/front-api/v1/new_messages'),
|
||||||
{ 'lastDate': $scope.lastContactListMsgDate },
|
{ 'lastDate': $scope.lastContactListMsgDate },
|
||||||
function(jsondata, status) {
|
function(jsondata, status) {
|
||||||
var bufferedContacts = [];
|
var bufferedContacts = [];
|
||||||
@ -280,7 +284,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.removeConversation = function() {
|
$scope.removeConversation = function() {
|
||||||
$.post(OC.generateUrl('/apps/ocsms/delete/conversation'), {"contact": $scope.selectedContact.label}, function(data) {
|
$.post($scope.generateUrl('/delete/conversation'), {"contact": $scope.selectedContact.label}, function(data) {
|
||||||
// Reinit main window
|
// Reinit main window
|
||||||
$scope.selectedContact.label = "";
|
$scope.selectedContact.label = "";
|
||||||
$scope.selectedContact.opt_numbers = "";
|
$scope.selectedContact.opt_numbers = "";
|
||||||
@ -355,7 +359,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
for (var i=0; i < len; i++) {
|
for (var i=0; i < len; i++) {
|
||||||
var curMsg = $scope.messages[i];
|
var curMsg = $scope.messages[i];
|
||||||
if (curMsg['id'] == msgId) {
|
if (curMsg['id'] == msgId) {
|
||||||
$.post(OC.generateUrl('/apps/ocsms/delete/message'),
|
$.post($scope.generateUrl('/delete/message'),
|
||||||
{"messageId": msgId, "phoneNumber": $scope.selectedContact.label}, function(data) {
|
{"messageId": msgId, "phoneNumber": $scope.selectedContact.label}, function(data) {
|
||||||
$scope.$apply(function () {
|
$scope.$apply(function () {
|
||||||
$scope.messages.splice(i, 1);
|
$scope.messages.splice(i, 1);
|
||||||
@ -367,7 +371,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.fetchInitialSettings = function () {
|
$scope.fetchInitialSettings = function () {
|
||||||
$.getJSON(OC.generateUrl('/apps/ocsms/front-api/v1/settings'), function(jsondata, status) {
|
$.getJSON($scope.generateUrl('/front-api/v1/settings'), function(jsondata, status) {
|
||||||
if (jsondata['status'] == true) {
|
if (jsondata['status'] == true) {
|
||||||
$('#sel_intl_phone').val(jsondata["country"]);
|
$('#sel_intl_phone').val(jsondata["country"]);
|
||||||
|
|
||||||
@ -506,7 +510,7 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
|
|||||||
g_originalTitle = document.title;
|
g_originalTitle = document.title;
|
||||||
|
|
||||||
// Now bind the events when we click on the phone number
|
// Now bind the events when we click on the phone number
|
||||||
$.getJSON(OC.generateUrl('/apps/ocsms/front-api/v1/peerlist'), function(jsondata, status) {
|
$.getJSON($scope.generateUrl('/front-api/v1/peerlist'), function(jsondata, status) {
|
||||||
$scope.fetchInitialPeerList(jsondata);
|
$scope.fetchInitialPeerList(jsondata);
|
||||||
|
|
||||||
var pnParam = $.urlParam('phonenumber');
|
var pnParam = $.urlParam('phonenumber');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user