initial commit for dash home

This commit is contained in:
Safiyu 2013-11-15 14:03:32 +05:30
parent 9c4fd33ae6
commit 571c443cf1
13 changed files with 443 additions and 16 deletions

View File

@ -1139,7 +1139,7 @@
"label.viewcheckerinbox":"View Checker Inbox",
"label.searchbytransaction":"Search by transaction #",
"label.searchbyuser":"Search by user",
"label.advancesearch":"Advanced Search",
"label.advancesearch":"Advance Search",
"#Translations of Error and Validation messages returned from mifos platform API":"",
"label.error":"Error",
@ -2096,6 +2096,7 @@
"label.chargepaymentmode":"Charge Payment Mode",
"label.pay":"Pay",
"label.enterpaymentdate":"Enter Payment Date",
"label.performancehistory":"Performance History"
"label.performancehistory":"Performance History",
"label.expertsearch":"Expert Search"
}

View File

@ -116,6 +116,8 @@
</div>
<nav>
<ul class="margin-nav nav nav-list ext-sidenav">
<li><a class="bolder black" href="#/expertsearch"><i class="icon-search icon-large"></i>&nbsp;&nbsp;&nbsp;{{ 'label.advancesearch' | translate}}</a></li>
<li class="divider"></li>
<li><a class="bolder black" href="#/nav/offices"><i class="icon-compass icon-large"></i>&nbsp;&nbsp;{{ 'label.navigation' | translate}}</a></li>
<li class="divider"></li>
<li><a class="bolder black" href="#/tasks"><i class="icon-bell-alt icon-large"></i>&nbsp;&nbsp;{{ 'link.tasks' | translate}}</a></li>

View File

@ -18,12 +18,6 @@
resourceFactory.groupNotesResource.getAllNotes({groupId: routeParams.id} , function(data) {
scope.groupNotes = data;
});
scope.deleteGrouppop = function(){
scope.choice = 3;
} ;
scope.delete = function(id){
};
scope.delrole = function(id){
resourceFactory.groupResource.save({groupId: routeParams.id,command: 'unassignRole',roleId:id}, {}, function(data) {
resourceFactory.groupResource.get({groupId: routeParams.id}, function(data){

View File

@ -0,0 +1,104 @@
(function(module) {
mifosX.controllers = _.extend(module, {
ExpertSearchController: function(scope, resourceFactory , localStorageService,$rootScope,location) {
scope.recent = [];
scope.recent=localStorageService.get('Location');
scope.recentEight = [];
scope.frequent = [];
scope.recentArray = [];
scope.uniqueArray = [];
scope.searchParams = [];
scope.recents = [];
//to retrieve last 8 recent activities
for(var rev= scope.recent.length-1;rev>0;rev--){
scope.recentArray.push(scope.recent[rev]);
}
scope.unique = function(array) {
array.forEach(function (value) {
if (scope.uniqueArray.indexOf(value) === -1) {
scope.uniqueArray.push(value);
}
});
}
scope.unique(scope.recentArray);
//recent activities retrieved
//retrieve last 9 recent activities
for(var l=0; l<9;l++){
if(scope.uniqueArray[l]){
scope.recents.push(scope.uniqueArray[l]);
}
}
// 9 recent activities retrieved
//count duplicates
var i = scope.recent.length;
var obj ={};
while (i)
{
obj[scope.recent[--i]] = (obj[scope.recent[i]] || 0) + 1;
}
//count ends here
//to sort based on counts
var sortable = [];
for (var i in obj){
sortable.push([i, obj[i]]);
}
sortable.sort(function(a, b) {return a[1] - b[1]});
//sort end here
//to retrieve the locations from sorted array
var sortedArray =[];
for(var key in sortable) {
sortedArray.push(sortable[key][0]);
}
//retrieving ends here
//retrieve last 8 frequent actions
for(var freq = sortedArray.length-1; freq>sortedArray.length-10;freq--){
if(sortedArray[freq]){
scope.frequent.push(sortedArray[freq]);
}
}
// retrieved 8 frequent actions
scope.searchParams.push('create client');
scope.searchParams.push('clients');
scope.searchParams.push('create group');
scope.searchParams.push('groups');
scope.searchParams.push('centers');
scope.searchParams.push('create center');
scope.searchParams.push('configuration');
scope.searchParams.push('tasks');
scope.search = function(){
switch(this.formData.search){
case 'create client': location.path('/createclient');
break;
case 'clients': location.path('/clients');
break;
case 'create group': location.path('/creategroup');
break;
case 'groups': location.path('/groups');
break;
case 'create center': location.path('/createcenter');
break;
case 'centers': location.path('/centers');
break;
case 'configuration': location.path('/global');
break;
case 'tasks': location.path('/tasks');
break;
default: location.path('/home');
}
}
}
});
mifosX.ng.application.controller('ExpertSearchController', ['$scope', 'ResourceFactory', 'localStorageService','$rootScope','$location', mifosX.controllers.ExpertSearchController]).run(function($log) {
$log.info("ExpertSearchController initialized");
});
}(mifosX.controllers || {}));

View File

@ -1,10 +1,21 @@
(function(module) {
mifosX.controllers = _.extend(module, {
MainController: function(scope, location, sessionManager, translate) {
scope.leftnav = false;
MainController: function(scope, location, sessionManager, translate,$rootScope,localStorageService) {
scope.activity = {};
scope.activityQueue = [];
if(localStorageService.get('Location')){
scope.activityQueue = localStorageService.get('Location');
}
scope.$watch(function() {
return location.path();
}, function() {
scope.activity= location.path();
scope.activityQueue.push(scope.activity);
localStorageService.add('Location',scope.activityQueue);
});
scope.$on("UserAuthenticationSuccessEvent", function(event, data) {
scope.leftnav = false;
scope.$on("UserAuthenticationSuccessEvent", function(event, data) {
scope.currentSession = sessionManager.get(data);
location.path('/home').replace();
});
@ -77,6 +88,8 @@
'$location',
'SessionManager',
'$translate',
'$rootScope',
'localStorageService',
mifosX.controllers.MainController
]).run(function($log) {
$log.info("MainController initialized");

View File

@ -24,7 +24,8 @@
'configurations':'../scripts/modules/configurations',
'angularFileUpload':'../bower_components/angularjs-file-upload/angular-file-upload',
'ngSanitize': '../bower_components/angular-sanitize/angular-sanitize',
'ckEditor': '../bower_components/ckeditor/ckeditor'
'ckEditor': '../bower_components/ckeditor/ckeditor',
'LocalStorageModule':'../scripts/modules/localstorage'
},
shim: {
'angular': { exports: 'angular' },
@ -44,6 +45,7 @@
'modified.datepicker':{deps: ['angular']},
'ngSanitize':{deps:['angular'],exports:'ngSanitize'},
'ckEditor':{deps:['jquery']},
'LocalStorageModule':{deps:['angular']},
'mifosX': {
deps: [
'angular',
@ -61,7 +63,8 @@
'modified.datepicker',
'ngSanitize',
'ckEditor',
'configurations'
'configurations',
'LocalStorageModule'
],
exports: 'mifosX'
}

View File

@ -2,7 +2,7 @@ var mifosX = (function(module) {
module.ng = {
config : angular.module('config_params' , ['configurations']),
services: angular.module('MifosX_Services', ['ngResource']),
application: angular.module('MifosX_Application', ['MifosX_Services', 'config_params', 'webStorageModule', 'ui.bootstrap' , 'pascalprecht.translate','nvd3ChartDirectives','notificationWidget', 'angularFileUpload','modified.datepicker','ngSanitize'])
application: angular.module('MifosX_Application', ['MifosX_Services', 'config_params', 'webStorageModule', 'ui.bootstrap' , 'pascalprecht.translate','nvd3ChartDirectives','notificationWidget', 'angularFileUpload','modified.datepicker','ngSanitize','LocalStorageModule'])
};
return module;
}(mifosX || {}));

View File

@ -153,7 +153,8 @@ define(['underscore', 'mifosX'], function() {
'template/EditTemplateController',
'loanAccount/GuarantorController',
'loanAccount/EditGuarantorController',
'main/ViewCheckerinboxController'
'main/ViewCheckerinboxController',
'main/ExpertSearchController'
],
filters: [
'StatusLookup',

View File

@ -0,0 +1,270 @@
(function() {
/* Start angularLocalStorage */
var angularLocalStorage = angular.module('LocalStorageModule', []);
// You should set a prefix to avoid overwriting any local storage variables from the rest of your app
// e.g. angularLocalStorage.constant('prefix', 'youAppName');
angularLocalStorage.value('prefix', 'ls');
// Cookie options (usually in case of fallback)
// expiry = Number of days before cookies expire // 0 = Does not expire
// path = The web path the cookie represents
angularLocalStorage.constant('cookie', { expiry:30, path: '/'});
angularLocalStorage.constant('notify', { setItem: true, removeItem: false} );
angularLocalStorage.service('localStorageService', [
'$rootScope',
'prefix',
'cookie',
'notify',
function($rootScope, prefix, cookie, notify) {
// If there is a prefix set in the config lets use that with an appended period for readability
//var prefix = angularLocalStorage.constant;
if (prefix.substr(-1)!=='.') {
prefix = !!prefix ? prefix + '.' : '';
}
// Checks the browser to see if local storage is supported
var browserSupportsLocalStorage = function () {
try {
return ('localStorage' in window && window['localStorage'] !== null);
} catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return false;
}
};
// Directly adds a value to local storage
// If local storage is not available in the browser use cookies
// Example use: localStorageService.add('library','angular');
var addToLocalStorage = function (key, value) {
// If this browser does not support local storage use cookies
if (!browserSupportsLocalStorage()) {
$rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');
if (notify.setItem) {
$rootScope.$broadcast('LocalStorageModule.notification.setitem', {key: key, newvalue: value, storageType: 'cookie'});
}
return addToCookies(key, value);
}
// Let's convert undefined values to null to get the value consistent
if (typeof value == "undefined") {
value = null;
}
try {
if (angular.isObject(value) || angular.isArray(value)) {
value = angular.toJson(value);
}
localStorage.setItem(prefix+key, value);
if (notify.setItem) {
$rootScope.$broadcast('LocalStorageModule.notification.setitem', {key: key, newvalue: value, storageType: 'localStorage'});
}
} catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return addToCookies(key, value);
}
return true;
};
// Directly get a value from local storage
// Example use: localStorageService.get('library'); // returns 'angular'
var getFromLocalStorage = function (key) {
if (!browserSupportsLocalStorage()) {
$rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');
return getFromCookies(key);
}
var item = localStorage.getItem(prefix+key);
// angular.toJson will convert null to 'null', so a proper conversion is needed
// FIXME not a perfect solution, since a valid 'null' string can't be stored
if (!item || item === 'null') return null;
if (item.charAt(0) === "{" || item.charAt(0) === "[") {
return angular.fromJson(item);
}
return item;
};
// Remove an item from local storage
// Example use: localStorageService.remove('library'); // removes the key/value pair of library='angular'
var removeFromLocalStorage = function (key) {
if (!browserSupportsLocalStorage()) {
$rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');
if (notify.removeItem) {
$rootScope.$broadcast('LocalStorageModule.notification.removeitem', {key: key, storageType: 'cookie'});
}
return removeFromCookies(key);
}
try {
localStorage.removeItem(prefix+key);
if (notify.removeItem) {
$rootScope.$broadcast('LocalStorageModule.notification.removeitem', {key: key, storageType: 'localStorage'});
}
} catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return removeFromCookies(key);
}
return true;
};
// Return array of keys for local storage
// Example use: var keys = localStorageService.keys()
var getKeysForLocalStorage = function () {
if (!browserSupportsLocalStorage()) {
$rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');
return false;
}
var prefixLength = prefix.length;
var keys = [];
for (var key in localStorage) {
// Only return keys that are for this app
if (key.substr(0,prefixLength) === prefix) {
try {
keys.push(key.substr(prefixLength));
} catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.Description);
return [];
}
}
}
return keys;
};
// Remove all data for this app from local storage
// Example use: localStorageService.clearAll();
// Should be used mostly for development purposes
var clearAllFromLocalStorage = function () {
if (!browserSupportsLocalStorage()) {
$rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');
return clearAllFromCookies();
}
var prefixLength = prefix.length;
for (var key in localStorage) {
// Only remove items that are for this app
if (key.substr(0,prefixLength) === prefix) {
try {
removeFromLocalStorage(key.substr(prefixLength));
} catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return clearAllFromCookies();
}
}
}
return true;
};
// Checks the browser to see if cookies are supported
var browserSupportsCookies = function() {
try {
return navigator.cookieEnabled ||
("cookie" in document && (document.cookie.length > 0 ||
(document.cookie = "test").indexOf.call(document.cookie, "test") > -1));
} catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return false;
}
};
// Directly adds a value to cookies
// Typically used as a fallback is local storage is not available in the browser
// Example use: localStorageService.cookie.add('library','angular');
var addToCookies = function (key, value) {
if (typeof value == "undefined") {
return false;
}
if (!browserSupportsCookies()) {
$rootScope.$broadcast('LocalStorageModule.notification.error','COOKIES_NOT_SUPPORTED');
return false;
}
try {
var expiry = '', expiryDate = new Date();
if (value === null) {
// Mark that the cookie has expired one day ago
expiryDate.setTime(expiryDate.getTime() + (-1 * 24*60*60*1000));
expiry = "; expires="+expiryDate.toGMTString();
value = '';
} else if (cookie.expiry !== 0) {
expiryDate.setTime(expiryDate.getTime() + (cookie.expiry*24*60*60*1000));
expiry = "; expires="+expiryDate.toGMTString();
}
if (!!key) {
document.cookie = prefix + key + "=" + encodeURIComponent(value) + expiry + "; path="+cookie.path;
}
} catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return false;
}
return true;
};
// Directly get a value from a cookie
// Example use: localStorageService.cookie.get('library'); // returns 'angular'
var getFromCookies = function (key) {
if (!browserSupportsCookies()) {
$rootScope.$broadcast('LocalStorageModule.notification.error','COOKIES_NOT_SUPPORTED');
return false;
}
var cookies = document.cookie.split(';');
for(var i=0;i < cookies.length;i++) {
var thisCookie = cookies[i];
while (thisCookie.charAt(0)==' ') {
thisCookie = thisCookie.substring(1,thisCookie.length);
}
if (thisCookie.indexOf(prefix+key+'=') === 0) {
return decodeURIComponent(thisCookie.substring(prefix.length+key.length+1,thisCookie.length));
}
}
return null;
};
var removeFromCookies = function (key) {
addToCookies(key,null);
};
var clearAllFromCookies = function () {
var thisCookie = null, thisKey = null;
var prefixLength = prefix.length;
var cookies = document.cookie.split(';');
for(var i=0;i < cookies.length;i++) {
thisCookie = cookies[i];
while (thisCookie.charAt(0)==' ') {
thisCookie = thisCookie.substring(1,thisCookie.length);
}
key = thisCookie.substring(prefixLength,thisCookie.indexOf('='));
removeFromCookies(key);
}
};
return {
isSupported: browserSupportsLocalStorage,
set: addToLocalStorage,
add: addToLocalStorage, //DEPRECATED
get: getFromLocalStorage,
keys: getKeysForLocalStorage,
remove: removeFromLocalStorage,
clearAll: clearAllFromLocalStorage,
cookie: {
set: addToCookies,
add: addToCookies, //DEPRECATED
get: getFromCookies,
remove: removeFromCookies,
clearAll: clearAllFromCookies
}
};
}]);
}).call(this);

View File

@ -457,6 +457,9 @@
})
.when('/editguarantor/:id/:loanId',{
templateUrl: 'views/loans/editguarantor.html'
})
.when('/expertsearch',{
templateUrl: 'views/expertsearch.html'
});
$locationProvider.html5Mode(false);
};

View File

@ -881,3 +881,4 @@ nav:hover:after{

View File

@ -0,0 +1,34 @@
<div id="expertsearch" data-ng-controller="ExpertSearchController">
<h3><strong>MifosX Dash Home</strong></h3>
<input type="text" data-ng-model="formData.search" placeholder="Search" class="span" typeahead-on-select="search()" ng-autofocus="true" typeahead="param as param for param in searchParams | filter:$viewValue | limitTo:8"/>
<hr/>
<br/>
<div class="form-horizontal">
<div class="control-group">
<div class="paddedleft">
<i class="icon-bolt icon-2x"></i><strong>Recent Activities</strong>
</div>
<hr/>
<div class="row span">
<div class="paddedleft120">
<span data-ng-repeat="recent in recents">
<a href="#{{recent}}" class="btn-silver" title="{{recent}}"><i class="icon-4x icon-globe"></i></a>
</span>
</div>
</div>
</div>
<div class="control-group">
<div class="paddedleft">
<br/><br/><i class="icon-laptop icon-2x"></i><strong>Frequent Activities</strong>
</div>
<hr/>
<div class="row span">
<div class="paddedleft120">
<span data-ng-repeat="freq in frequent">
<a href="#{{freq}}" class="btn-silver" title="{{freq}}"><i class="icon-4x icon-globe"></i></a>
</span>
</div>
</div>
</div>
</div>
</div>

View File

@ -55,6 +55,7 @@
<td>{{loandetails.summary.totalOverdue}}</td>
</tr>
</table>
</div>
<div class="row paddedleft">
<hr class="marginbottom"/>
<tabset >