mirror of https://github.com/sipwise/ngcp-csc.git
Change-Id: Ia3ffe13ec7b4e23f70228196f7e201377fe02bb7changes/61/13161/4
parent
6a9e8ce1a6
commit
e9ec6b79b7
@ -1,15 +1,53 @@
|
||||
Ext.define('NgcpCsc.model.Reminder', {
|
||||
extend: 'Ext.data.Model',
|
||||
|
||||
fields: ["reminder_status", "timer", "recurrence"],
|
||||
requires: ['NgcpCsc.proxy.NgcpApi'],
|
||||
|
||||
proxy: {
|
||||
type: 'ajax',
|
||||
url: '/resources/data/reminder.json',
|
||||
autoLoad: true,
|
||||
reader: {
|
||||
type: 'json',
|
||||
rootProperty: 'data'
|
||||
fields: [{
|
||||
name: "_embedded",
|
||||
persist: false
|
||||
}, {
|
||||
name: "_links",
|
||||
persist: false
|
||||
}, {
|
||||
name: "total_count",
|
||||
persist: false
|
||||
}, {
|
||||
name: "id",
|
||||
persist: false
|
||||
}, {
|
||||
name: "recur",
|
||||
mapping: function(data) {
|
||||
return data._embedded['ngcp:reminders'][0].recur;
|
||||
}
|
||||
}, {
|
||||
name: "time",
|
||||
type: "date",
|
||||
dateFormat: 'H:m:s',
|
||||
mapping: function(data) {
|
||||
return data._embedded['ngcp:reminders'][0].time;
|
||||
}
|
||||
}, {
|
||||
name: "reminder_status",
|
||||
mapping: function(data) {
|
||||
return true;
|
||||
}
|
||||
}, {
|
||||
name: "subscriber_id",
|
||||
mapping: function(data) {
|
||||
return data._embedded['ngcp:reminders'][0].subscriber_id;
|
||||
}
|
||||
}],
|
||||
|
||||
// this replace the temprary Model ID in VM links
|
||||
onLoad: function() {
|
||||
this.set("id", this.data._embedded['ngcp:reminders'][0].id);
|
||||
this.commit();
|
||||
},
|
||||
|
||||
proxy: {
|
||||
type: 'ngcp-api',
|
||||
route: 'reminders',
|
||||
params: 'subscriber_id=175'
|
||||
}
|
||||
});
|
||||
|
@ -0,0 +1,47 @@
|
||||
/**
|
||||
Ex. usage in model/store:
|
||||
proxy: {
|
||||
type: 'ngcp-api',
|
||||
route: 'reminders/',
|
||||
autoLoad: true
|
||||
}
|
||||
**/
|
||||
Ext.define('NgcpCsc.proxy.NgcpApi', {
|
||||
extend: 'Ext.data.proxy.Ajax',
|
||||
alias: 'proxy.ngcp-api',
|
||||
/* temporary authentication, should be bound to auth token once implemented*/
|
||||
withCredentials: true,
|
||||
username: 'administrator',
|
||||
password: 'administrator',
|
||||
baseApiUrl: 'https://localhost:1443/api/',
|
||||
autoLoad: true,
|
||||
appendId: false,
|
||||
actionMethods: {
|
||||
read: 'GET',
|
||||
create: 'POST',
|
||||
update: 'PUT',
|
||||
destroy: 'DELETE'
|
||||
},
|
||||
buildUrl: function(request) {
|
||||
var me = this;
|
||||
var action = request._action;
|
||||
var url, records;
|
||||
switch(action){
|
||||
case 'read' :
|
||||
url = Ext.String.format('{0}{1}/?{2}', me.baseApiUrl, me.route, me.params);
|
||||
break;
|
||||
case 'update' :
|
||||
records = request._records;
|
||||
url = Ext.String.format('{0}{1}/{2}', me.baseApiUrl, me.route, records[0].get('id'));
|
||||
break;
|
||||
}
|
||||
request._url = url;
|
||||
return me.callParent(arguments);
|
||||
},
|
||||
reader: {
|
||||
type: 'json'
|
||||
},
|
||||
writer: {
|
||||
writeAllFields: true
|
||||
}
|
||||
});
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"reminder_status": true,
|
||||
"timer": "17:50",
|
||||
"recurrence": "never"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in new issue