Commit 253cf050 by Uros Spasojevic

added login

added conditional stuff

TODO: edit entry in grid
parent 72845748
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -165,10 +165,15 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', { ...@@ -165,10 +165,15 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
performers: perf, performers: perf,
lat: marker.lat, lat: marker.lat,
lng: marker.lng, lng: marker.lng,
animation: google.maps.Animation.DROP, animation: google.maps.Animation.DROP
access: marker.access
}; };
if((marker.saved != undefined) && (marker.saved == false)) {
newMarker.access = dbref.ref().child('data').push().key
} else {
newMarker.access = marker.access;
}
var updates = {}; var updates = {};
updates['/data/' + newMarker.access] = newMarker; updates['/data/' + newMarker.access] = newMarker;
...@@ -212,15 +217,10 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', { ...@@ -212,15 +217,10 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
title: "", title: "",
description: "", description: "",
performers: [], performers: [],
animation: google.maps.Animation.DROP animation: google.maps.Animation.DROP,
saved: false
}; };
var updates = {};
updates['/data/' + key] = marker;
dbref.ref().update(updates);
markers.push(map.addMarker(marker)); markers.push(map.addMarker(marker));
}, },
mapready: function () { mapready: function () {
...@@ -229,30 +229,82 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', { ...@@ -229,30 +229,82 @@ Ext.define('Evoksi.view.evoksi.EvoksiController', {
google.maps.event.addListener(map.gmap, 'click', function (e) { google.maps.event.addListener(map.gmap, 'click', function (e) {
map.fireEvent('click', e); map.fireEvent('click', e);
}); });
}
}
}
}
},
Ext.Ajax.request({ showLogin: function() {
url: dataURL, var me = this,
scope: this, map = me.getView();
success: function (data) { var loginWindow = Ext.create('Ext.panel.Panel', {
var info = Ext.decode(data.responseText); floating: true,
centered: true,
title: 'Login',
modal: true,
width: 300,
height: 400,
draggable: false,
maximizable: false,
items: [
{
xtype: 'textfield',
fieldLabel: 'Username'
},
{
xtype: 'textfield',
inputType: 'password',
fieldLabel: 'Password'
}
],
buttons: [
{
text: 'Login',
formBind: true,
handler: function() {
var username = loginWindow.items.items[0].value;
var password = loginWindow.items.items[1].value;
if (info != null) { if(username == 'admin' && password == 'cpAdmin01') {
Ext.Object.each(info, function (obj, index) { Ext.Ajax.request({
markers.push(map.addMarker(index)); url: dataURL,
}); scope: this,
success: function (data) {
var info = Ext.decode(data.responseText);
if (info != null) {
Ext.Object.each(info, function (obj, index) {
markers.push(map.addMarker(index));
});
}
} }
} });
}); loginWindow.hide();
} else {
}
} }
} }
} ]
} }).show();
}, },
logout: function() { logout: function() {
console.log('logout'); var i = markers.length;
while(i) {
i--;
markers[i].setMap(null);
}
markers = [];
this.showLogin();
}, },
init: function () { init: function () {
var me = this, var me = this,
map = me.getView(); map = me.getView();
this.showLogin();
} }
}); });
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment