Commit 167e8688 authored by Evren Kutar's avatar Evren Kutar

ADD socket.js req/resp reactor

REFACTOR dashboard type htmls in user-templates directory
rref #5120
rfix #5183
fixes GH-90
fixes zetaops/ulakbusGH-207
parent 6fea70a1
......@@ -152,7 +152,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ulakbus.formService'])
*
* @returns {object}
*/
.controller('CRUDListFormController', function ($scope, $rootScope, $location, $http, $log, $uibModal, $timeout, Generator, $routeParams, CrudUtility) {
.controller('CRUDListFormController', function ($scope, $rootScope, $location, $sce, $http, $log, $uibModal, $timeout, Generator, $routeParams, CrudUtility) {
$scope.$on('reload_cmd', function(event, data){
$scope.reload_cmd = data;
......
......@@ -34,8 +34,8 @@
<td ng-repeat="field in object.fields track by $index">
<a role="button" ng-if="field.type==='link'"
ng-click="do_action(object.key, field)">{{field.content}}</a>
<span ng-if="field.type==='str'">{{field.content}}</span>
ng-click="do_action(object.key, field)" ng-bind-html="field.content"></a>
<span ng-if="field.type==='str'" ng-bind-html="field.content"></span>
</td>
<td>
......
This diff is collapsed.
......@@ -479,7 +479,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
var generate_fields = {
button: {default: _buttons},
submit: {default: _buttons},
file: {default: function (scope, v, k) {
file: {
default: function (scope, v, k) {
scope.form[scope.form.indexOf(k)] = {
type: "template",
title: v.title,
......@@ -493,8 +494,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
avatar: k === 'avatar'
};
v.type = 'string';
}},
select: {default: function (scope, v, k) {
}
},
select: {
default: function (scope, v, k) {
scope.form[scope.form.indexOf(k)] = {
type: "template",
title: v.title,
......@@ -503,8 +506,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
key: k,
titleMap: v.titleMap
};
}},
date: {default: function (scope, v, k) {
}
},
date: {
default: function (scope, v, k) {
$log.debug('date:', scope.model[k]);
scope.model[k] = generator.dateformatter(scope.model[k]);
scope.form[scope.form.indexOf(k)] = {
......@@ -547,38 +552,47 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
scope.model[k] = angular.copy(generator.dateformatter(scope.model[k]));
}
};
}},
}
},
int: {default: _numbers},
boolean: {default: function () {}},
string: {default: function () {}},
typeahead: {default: function (scope, v, k) {
scope.form[scope.form.indexOf(k)] = {
type: "template",
title: v.title,
titleMap: v.titleMap,
templateUrl: "shared/templates/typeahead.html",
name: k,
key: k,
onDropdownSelect: function (item, inputname) {
scope.model[k] = item.value;
$timeout(function () {
document.querySelector('input[name=' + inputname + ']').value = item.name;
});
}
};
v.type = 'string';
}},
boolean: {
default: function () {
}
},
string: {
default: function () {
}
},
typeahead: {
default: function (scope, v, k) {
scope.form[scope.form.indexOf(k)] = {
type: "template",
title: v.title,
titleMap: v.titleMap,
templateUrl: "shared/templates/typeahead.html",
name: k,
key: k,
onDropdownSelect: function (item, inputname) {
scope.model[k] = item.value;
$timeout(function () {
document.querySelector('input[name=' + inputname + ']').value = item.name;
});
}
};
v.type = 'string';
}
},
text_general: {
default:
function (scope, v, k) {
v.type = 'string',
default: function (scope, v, k) {
v.type = 'string',
v["x-schema-form"] = {
"type": "textarea"
}
}
}
},
float: {default: _numbers},
model: {default: function (scope, v, k) {
model: {
default: function (scope, v, k) {
var formitem = scope.form[scope.form.indexOf(k)];
var modelScope = {
......@@ -675,7 +689,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
};
scope.form[scope.form.indexOf(k)] = formitem;
}},
}
},
Node: {
default: _node_default,
filter_interface: _node_filter_interface
......@@ -796,7 +811,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*}
*/
generator.get_form = function (scope) {
//generator.button_switch(false);
return $http
.post(generator.makeUrl(scope), scope.form_params)
.then(function (res) {
......@@ -813,7 +827,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*}
*/
generator.get_list = function (scope) {
//generator.button_switch(false);
return $http
.post(generator.makeUrl(scope), scope.form_params)
.then(function (res) {
......@@ -831,11 +844,14 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*}
*/
generator.get_wf = function (scope) {
//generator.button_switch(false);
//WSOps.request(scope.form_params)
// .then(function (data) {
// return generator.pathDecider(data.client_cmd, scope, data);
// });
return $http
.post(generator.makeUrl(scope), scope.form_params)
.then(function (res) {
//generator.button_switch(true);
return generator.pathDecider(res.data.client_cmd, scope, res.data);
});
};
......@@ -1065,6 +1081,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
"query": $scope.form_params.query
};
//WSOps.request(scope.form_params)
// .then(function (data) {
// return generator.pathDecider(data.client_cmd, $scope, data);
// });
return $http.post(generator.makeUrl($scope), data)
.success(function (data, status, headers) {
if (headers('content-type') === "application/pdf") {
......
......@@ -14,10 +14,17 @@ angular.module('ulakbus')
.service('WSUri', function () {
return {url: 'ws://localhost:9001/ws'}
})
/**
* websocket with callbackId
* use when need to retrieve special data
*/
.service('WSWithCallback', function () {
return {"cbs": []};
})
/**
* WSOps operates all websocket interactions
*/
.service('WSOps', function (WSUri, $log) {
.factory('WSOps', function (WSUri, $q, $log) {
var websocket = new WebSocket(WSUri.url);
websocket.onopen = function (evt) {
wsOps.onOpen(evt)
......@@ -39,15 +46,42 @@ angular.module('ulakbus')
wsOps.onClose = function(event) {
$log.info("DISCONNEDTED", event);
};
// two types of data can be come from websocket: with / without callback
//
wsOps.callbacks = {};
wsOps.onMessage = function(event) {
var data = angular.fromJson(event.data);
if (angular.isDefined(callbacks[data.request_id])) {
var callback = callbacks[data.request_id];
delete callbacks[data.request_id];
callback.resolve(data);
} else {
$log.info("Data without callback: %o", data);
}
$log.info("MESSAGE:", event.data);
};
wsOps.onError = function(evt) {
$log.error("Error :: " + evt);
$log.error("ERROR :: " + evt);
};
wsOps.doSend = function(data) {
websocket.send(data);
$log.info('SENT:', data);
};
// reactor with promise
wsOps.request = function(data) {
var request = {
request_id: Math.random().toString(36).substring(7),
data: data
};
var deferred = $q.defer();
wsOps.callbacks[request.request_id] = deferred;
websocket.send(angular.toJson(request));
return deferred.promise.then(function(response) {
request.response = response;
return response;
});
};
return wsOps;
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -32,6 +32,13 @@ body {
background-color:#999;
}
.tooltip {
font-family:'robotolight';
font-size:13px;
letter-spacing:0.3px;
padding:15px;
}
.badge {
border-radius: 100%;
width: 22px;
......@@ -1584,6 +1591,225 @@ table.dataTable thead .sorting:after {
/* END OF SIDEBAR COLLAPSE */
/* STUDENT DASHBOARD */
.student-dashboard a:hover {
text-decoration:none;
background-color:#f9f9f9;
}
.student-dashboard .panel-body ul,
.student-dashboard .panel-body {
padding:0;
margin:0;
}
.student-dashboard .panel-body ul li {
list-style: none;
border-bottom: 1px solid #f5f5f5;
font-size:16px;
}
.student-dashboard .panel-body ul li a {
padding:25px;
display:block;
color:#333;
}
.student-dashboard .panel-body ul li:last-child {
border:none;
}
.student-course-list .panel-body,
.student-assignment-list .panel-body {
height:437px;
overflow-y:auto;
}
.student-course-list .panel-body ul li span {
margin-right:15px;
}
.student-assignment-list .assignment-status {
width:35px;
float:left;
}
.student-assignment-list .assignment-status .assignment-circle {
width:10px;
height:10px;
border-radius:100%;
margin-top: 7px;
margin-left: 3px;
}
.student-assignment-list .urgent-assignment .assignment-circle {
background-color:#D4244B;
}
.student-assignment-list .urgent-assignment .assignment-due-date {
color:#D4244B;
}
.student-assignment-list .approaching-assignment .assignment-circle {
background-color:#F7941E;
}
.student-assignment-list .approaching-assignment .assignment-due-date {
color:#F7941E;
}
.student-assignment-list .non-urgent-assignment .assignment-circle {
background-color:#01AEEE;
}
.student-assignment-list .non-urgent-assignment .assignment-due-date {
color:#01AEEE;
}
.student-assignment-list .assignment-title {
width:calc(100% - 100px);
float:left;
}
.student-assignment-list .assignment-title {
font-family:'robotomedium';
}
.student-assignment-list .assignment-title div:nth-child(1) {
font-family:'robotomedium';
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
padding-right: 15px;
}
.student-assignment-list .assignment-title div:nth-child(2) {
font-size:15px;
font-family:'robotolight';
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
padding-right: 15px;
}
.student-assignment-list .assignment-due-date {
width:65px;
float:left;
font-family:'robotolight';
position:relative;
}
.student-assignment-list .assignment-due-date div:nth-child(1) {
width:65px;
font-size:22px;
position:absolute;
text-align:center;
}
.student-assignment-list .assignment-due-date div:nth-child(2) {
width:65px;
font-size:13px;
position:absolute;
margin-top:25px;
text-align:center;
}
.student-assignment-list .last-assignment .assignment-status div {
width:3px;
height:47px;
background-color: #00A650;
margin-left: 6px;
}
.student-assignment-list .last-assignment .panel-title {
background-color: #fff;
border-color: #F2F2F2;
font-family: 'robotolight';
color: rgb(95, 95, 95);
padding: 12px 0 0;
font-size: 18px;
}
.student-assignment-list .last-assignment .assignment-due-date i {
color:#01A550;
margin-top: 16px;
}
.student-announcement-list .announcement-date {
float:left;
font-family:'robotolight';
margin-right:25px;
width:30px;
}
.student-announcement-list .announcement-text {
float:left;
width:calc(100% - 55px);
margin-top:3px;
}
.student-announcement-list .announcement-date div:first-child {
font-size: 22px;
text-align: center;
}
.student-announcement-list .announcement-date div:last-child {
font-size: 13px;
text-align: center;
}
.student-message-list .profile-pic {
width: 65px;
display: block;
margin-right: 20px;
float: left;
}
.student-message-list .profile-pic img {
width: 100%;
border-radius: 100%;
}
.student-message-list .message-content {
width: calc(100% - 200px);
float: left;
}
.student-message-list .message-content div:first-child {
margin-top:7px;
font-family:'robotomedium';
font-size:18px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.student-message-list .message-content div:last-child {
margin-top: 5px;
color: #848484;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.student-message-list .message-time {
width: 100px;
float: right;
text-align:right;
padding-top: 21px;
color: #B3B3B3;
font-size: 14px;
}
/* END OF STUDENT DASHBOARD */
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) {
/* Remove the padding we set earlier */
......
This diff is collapsed.
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