Skip to content

Commit

Permalink
Merge pull request #74 from tomvantilburg/master
Browse files Browse the repository at this point in the history
merge from Tom
  • Loading branch information
tomvantilburg committed Mar 12, 2014
2 parents 99651f6 + a739e81 commit cdb2751
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 113 deletions.
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<link rel="stylesheet" href="lib/diff/font-awesome-4.0.3/css/font-awesome.min.css">
<link rel="stylesheet" href="css/app.css">
<script src="./lib/cow/lib/dbjs/db.js"></script>
<!-- signalR ready-->
<script type="text/javascript" src="./lib/cow/lib/jquery-1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="./lib/cow/lib/jquery.signalR/jquery.signalR-2.0.2.js"></script>
<script type="text/javascript" src="https://srvcis/cow/signalr/hubs"></script> <!-- CHANGE THIS TO CORRECT SIGNALR SERVER URL -->

<script type="text/javascript" src="./lib/cow/lib/underscore/underscore-min.js" ></script>
<script type="text/javascript" src="./lib/cow/src/cow2.utils.js" ></script>
<script type="text/javascript" src="./lib/cow/src/cow2.record.js" ></script>
Expand All @@ -18,7 +23,8 @@
<script type="text/javascript" src="./lib/cow/src/cow2.group.js" ></script>
<script type="text/javascript" src="./lib/cow/src/cow2.item.js" ></script>
<script type="text/javascript" src="./lib/cow/src/cow2.project.js" ></script>
<script type="text/javascript" src="./lib/cow/src/cow2.websocket.js" ></script>
<!--<script type="text/javascript" src="./lib/cow/src/cow2.websocket.js" ></script>-->
<script type="text/javascript" src="./lib/cow/src/cow2.signalR.js" ></script>
<script type="text/javascript" src="./lib/cow/src/cow2.core.js" ></script>
<script type="text/javascript" src="./lib/cow/lib/polyfill-promise/promise-0.1.1.min.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion lib/cow
Submodule cow updated 36 files
+5 −1 README.md
+9,046 −0 lib/jquery-1.6.4/jquery-1.6.4.js
+2,694 −0 lib/jquery.signalR/jquery.signalR-2.0.2.js
+11 −34 server/node/cash.js
+22 −0 server/signalr/CowSignalR.sln
+51 −0 server/signalr/CowSignalR/CowHub.cs
+148 −0 server/signalr/CowSignalR/CowSignalR.csproj
+35 −0 server/signalr/CowSignalR/Properties/AssemblyInfo.cs
+23 −0 server/signalr/CowSignalR/Properties/PublishProfiles/cow.pubxml
+17 −0 server/signalr/CowSignalR/Properties/PublishProfiles/file.pubxml
+7,024 −0 server/signalr/CowSignalR/Scripts/jquery-1.6.4-vsdoc.js
+9,046 −0 server/signalr/CowSignalR/Scripts/jquery-1.6.4.js
+4 −0 server/signalr/CowSignalR/Scripts/jquery-1.6.4.min.js
+2,694 −0 server/signalr/CowSignalR/Scripts/jquery.signalR-2.0.2.js
+8 −0 server/signalr/CowSignalR/Scripts/jquery.signalR-2.0.2.min.js
+487 −0 server/signalr/CowSignalR/Scripts/json2.js
+1 −0 server/signalr/CowSignalR/Scripts/json2.min.js
+18 −0 server/signalr/CowSignalR/Startup.cs
+30 −0 server/signalr/CowSignalR/Web.Debug.config
+31 −0 server/signalr/CowSignalR/Web.Release.config
+23 −0 server/signalr/CowSignalR/Web.config
+49 −0 server/signalr/CowSignalR/cowhub.html
+16 −0 server/signalr/CowSignalR/packages.config
+1 −1 src/cow2.core.js
+2 −2 src/cow2.group.js
+1 −1 src/cow2.item.js
+1 −1 src/cow2.js
+26 −5 src/cow2.peer.js
+18 −2 src/cow2.project.js
+15 −3 src/cow2.record.js
+444 −0 src/cow2.signalR.js
+1 −4 src/cow2.syncstore.js
+5 −1 src/cow2.user.js
+7 −6 src/cow2.websocket.js
+2 −2 test/cow.testsuite.js
+8 −3 test/index.html
222 changes: 123 additions & 99 deletions src/controllers/leafletCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ icm.controller('LeafletController', [ '$scope','$http','$timeout','Core', 'Utils
}
var core = Core;

/** Some time functionality **/
$scope.chronos = false;
$scope.timeDisplay = 'none';
$scope.mytime = new Date();
$scope.hstep = 1;
$scope.mstep = 15;
$scope.ismeridian = true;
$scope.time = Date.now();
$scope.timechanged = function () {
console.log('Time changed to: ' + $scope.mytime);
$scope.time = new Date($scope.mytime).getTime();
populateFeatures();
};
$scope.setNow = function() {
var d = new Date();
$scope.mytime = d;
$scope.timechanged();
};
$scope.toggleChronos = function(){
populateFeatures();
};
/** end of time **/

$scope.core = core; //DEBUG
tmp = $scope; //DEBUG
var controls= {};
Expand Down Expand Up @@ -84,90 +107,94 @@ icm.controller('LeafletController', [ '$scope','$http','$timeout','Core', 'Utils
});

var editmenu = function(feat,container, element, event){
var menu = new Cow_utils.menu(feat,event, container, element, {
menuconfig: Cow_utils.menuconfig
});
/* Menu listeners */
menu.on('delete', function(d){
if (confirm('Verwijderen?')) {
var key = d.fid;
Core.project().items(key).deleted('true').sync();
} else {
// Do nothing!
}
});
menu.on('edit.geom', function(d){
drawControl.options.edit.featureGroup.addData(d.layer);
controls.editcontrol.enable();
});
menu.on('edit.text', function(d){
var feat = d.layer;
var fid = d.fid;
var item = $scope.core.project().items(fid);
var entity = d.obj;
var bbox = entity.getBBox();
var fe = d3.select('.leaflet-popup-pane')
.attr('draggable',"true")
.append('div')
.classed('popup panel panel-primary',true)
.style('position', 'absolute')
.style('left', function(){return bbox.x + 35 + 'px';})
.style('top', function(){return bbox.y + 35 + 'px';})
.style("width", '400px')
//.style("height", '200px')
.on('click', function(){
//d3.event.stopPropagation();//Prevent the map from firing click event as well
});
if ($scope.chronos){
return null;
}
else {
var menu = new Cow_utils.menu(feat,event, container, element, {
menuconfig: Cow_utils.menuconfig
});
/* Menu listeners */
menu.on('delete', function(d){
if (confirm('Verwijderen?')) {
var key = d.fid;
Core.project().items(key).deleted('true').sync();
} else {
// Do nothing!
}
});
menu.on('edit.geom', function(d){
drawControl.options.edit.featureGroup.addData(d.layer);
controls.editcontrol.enable();
});
menu.on('edit.text', function(d){
var feat = d.layer;
var fid = d.fid;
var item = $scope.core.project().items(fid);
var entity = d.obj;
var bbox = entity.getBBox();
var fe = d3.select('.leaflet-popup-pane')
.attr('draggable',"true")
.append('div')
.classed('popup panel panel-primary',true)
.style('position', 'absolute')
.style('left', function(){return bbox.x + 35 + 'px';})
.style('top', function(){return bbox.y + 35 + 'px';})
.style("width", '400px')
//.style("height", '200px')
.on('click', function(){
d3.event.stopPropagation();//Prevent the map from firing click event as well
});

var desc = feat.properties.desc || "";
var name = feat.properties.name || "";
var creator = feat.properties.creator || "";
var owner = feat.properties.owner || "";
var created = new Date(item.created()).toLocaleString();
var updated = new Date(item.timestamp()).toLocaleString();
desc = desc.replace(/\r\n?|\n/g, '<br />');

var desc = feat.properties.desc || "";
var name = feat.properties.name || "";
var creator = feat.properties.creator || "";
var owner = feat.properties.owner || "";
var created = new Date(item.created()).toLocaleString();
var updated = new Date(item.timestamp()).toLocaleString();
desc = desc.replace(/\r\n?|\n/g, '<br />');


var sheader = fe.append('div')
.classed('panel-heading', true)
.attr('contenteditable','true')
.html(name);

var scontent = fe.append('div')
.classed('panel-body', true);


var editdiv = scontent.append('div')
.attr('contenteditable','true')
.attr('id','descfield')
.classed('well well-sm', true)
.style('height','80px')
.html(desc);
var html = '<small>Gemaakt door: ' + creator + ' op ' + created + '<br> Bewerkt door: ' + owner + ' op ' + updated + '</small>';
scontent.append('div').html(html);
scontent.append('span')
.html('Opslaan')
.classed('btn btn-success', true)
.on('click',function(z){
feat.properties.name = sheader.html();
feat.properties.desc = editdiv.html();
$scope.core.project().items(fid).data('feature',feat).sync();
fe.remove();
});
scontent.append('span')
.html('Annuleren')
.classed('btn btn-danger pull-right', true)
.on('click',function(z){
fe.remove();
});
});


var sheader = fe.append('div')
.classed('panel-heading', true)
.attr('contenteditable','true')
.html(name);

var scontent = fe.append('div')
.classed('panel-body', true);


var editdiv = scontent.append('div')
.attr('contenteditable','true')
.attr('id','descfield')
.classed('well well-sm', true)
.style('height','80px')
.html(desc);
var html = '<small>Gemaakt door: ' + creator + ' op ' + created + '<br> Bewerkt door: ' + owner + ' op ' + updated + '</small>';
scontent.append('div').html(html);
scontent.append('span')
.html('Opslaan')
.classed('btn btn-success', true)
.on('click',function(z){
feat.properties.name = sheader.html();
feat.properties.desc = editdiv.html();
$scope.core.project().items(fid).data('feature',feat).sync();
fe.remove();
});
scontent.append('span')
.html('Annuleren')
.classed('btn btn-danger pull-right', true)
.on('click',function(z){
fe.remove();
});
});
}
};

var featureLayer = new L.GeoJSON.d3(dummyCollection, {
//core: Core,
onClick: editmenu,
onMouseover: Cow_utils.textbox,
//onMouseover: Cow_utils.textbox,
labels: true,
labelconfig: {
field: "name",
Expand All @@ -183,7 +210,7 @@ icm.controller('LeafletController', [ '$scope','$http','$timeout','Core', 'Utils
opacity: 0.5
}
});

$scope.featureLayer = featureLayer;

/* Initiate the marker icons */
//$http({method: 'POST', url: './images/mapicons/imoov_list_subset.js'}).
Expand Down Expand Up @@ -254,7 +281,7 @@ icm.controller('LeafletController', [ '$scope','$http','$timeout','Core', 'Utils
handleNewExtent(e.leafletEvent);
});
$scope.$on('leafletDirectiveMap.click', function(event,e){
//d3.selectAll('.popup').remove();//Remove all popups on map
d3.selectAll('.popup').remove();//Remove all popups on map
controls.editcontrol.save();
controls.editcontrol.disable();
identify(e);
Expand Down Expand Up @@ -305,12 +332,16 @@ icm.controller('LeafletController', [ '$scope','$http','$timeout','Core', 'Utils
var viewCollection = {"type":"FeatureCollection","features":[]};
for (i=0;i<items.length;i++){
var item = items[i];
var feature = item.data('feature');
if(feature === undefined) {
console.warn('old item type');
return false;
}
else{
var t;
if ($scope.chronos){
t = $scope.time;
}
else {
t = Date.now();
}
//var feature = item.data('feature');
if(item.data_on(t) && item.data_on(t).feature) {
var feature = item.data_on(t).feature;
//Add feature
var opacity = 1;
feature.id = item.id();
Expand Down Expand Up @@ -498,24 +529,17 @@ icm.controller('LeafletController', [ '$scope','$http','$timeout','Core', 'Utils
.data('feature', feature)
//TODO: add permissions here
.sync();
//populateFeatures();

});

/** Bind layer reload on storechanged **/
var itemstore = core.project().itemStore();
var peerstore = core.peerStore();
//itemstore.off('datachange');
itemstore.on('datachange',function() {
populateFeatures();
});
// peerstore.off('datachange');
peerstore.on('datachange',function() {
populatePeers();
});

var center = $scope.leafletService.center();
//map.setView([center.lat, center.lng],center.zoom);


itemstore.off('datachange',populateFeatures);
itemstore.on('datachange',populateFeatures);
peerstore.off('datachange',populatePeers);
peerstore.on('datachange',populatePeers);

//Initialize first time features
populateFeatures();
Expand Down
3 changes: 2 additions & 1 deletion src/factories.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ icm.factory('Beelden', ['$rootScope', function( $rootScope ) {
icm.factory('Core', ['$rootScope', function($rootScope) {

var cow = new Cow.core({
wsUrl: 'wss://websocket.geodan.nl:443/icms'
//wsUrl: 'wss://websocket.geodan.nl:443/icms'
wsUrl: 'https://srvcis/cow/signalr'
});
cow.userStore().loaded.then(function(){
if (!cow.users('1')){
Expand Down
4 changes: 2 additions & 2 deletions src/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ icm.factory('LeafletService',['$rootScope','Core',function($rootScope, Core) {
instance.layers = {};
instance.center = function(center){
if (!center){
console.log('Getting center: ', instance._center);
//console.log('Getting center: ', instance._center);
}
else{
console.log('setting center: ', center);
//console.log('setting center: ', center);
}
return instance._center = center || instance._center;
};
Expand Down
13 changes: 4 additions & 9 deletions src/state.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
var icm = angular.module('icm', ["ui.router",'ui.bootstrap',"leaflet-directive",'ngSanitize', 'textAngular'])
.run(
[ '$rootScope', '$state', '$stateParams',
function ($rootScope, $state, $stateParams) {
[ '$rootScope', '$state', '$stateParams','Utils',
function ($rootScope, $state, $stateParams, Utils) {

// It's very handy to add references to $state and $stateParams to the $rootScope
// so that you can access them from any scope within your applications.For example,
// <li ui-sref-active="active }"> will set the <li> // to active whenever
// 'contacts.list' or one of its decendents is active.
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;

}])
.config(
[ '$stateProvider', '$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {
['$stateProvider', '$urlRouterProvider',function ($stateProvider, $urlRouterProvider) {


$urlRouterProvider


//bij foute url stuur naar het begin
//bij foute url stuur naar het begin
.otherwise("/");

$stateProvider

// Hier moet IAAA stuff komen, maar voorlopig moet je een username invullen voor
// COW
.state("login", {
Expand Down
7 changes: 7 additions & 0 deletions templates/kaart.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ <h3>Lagen</h3>
</li>
</ul>
</span>
<button type="button" class="btn btn-primary" ng-model="chronos" ng-change="toggleChronos()" btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false">
Chronologie
</button>
<span ng-model="mytime" ng-change="timechanged()" ng-show="chronos" style="display:inline-block;">
<timepicker hour-step="hstep" minute-step="mstep" show-meridian="ismeridian"></timepicker>
</span>
<button class="btn btn-default" ng-click="setNow()" ng-show="chronos">Huidig</button>
<leaflet center="initcenter" defaults="defaults" height="800px" width="100%" markers="markers" paths='paths' layers="layers" events="events"></leaflet>
</div>
</div>
Expand Down

0 comments on commit cdb2751

Please sign in to comment.