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']) ...@@ -152,7 +152,7 @@ angular.module('ulakbus.crud', ['schemaForm', 'ulakbus.formService'])
* *
* @returns {object} * @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.$on('reload_cmd', function(event, data){
$scope.reload_cmd = data; $scope.reload_cmd = data;
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
<td ng-repeat="field in object.fields track by $index"> <td ng-repeat="field in object.fields track by $index">
<a role="button" ng-if="field.type==='link'" <a role="button" ng-if="field.type==='link'"
ng-click="do_action(object.key, field)">{{field.content}}</a> ng-click="do_action(object.key, field)" ng-bind-html="field.content"></a>
<span ng-if="field.type==='str'">{{field.content}}</span> <span ng-if="field.type==='str'" ng-bind-html="field.content"></span>
</td> </td>
<td> <td>
......
This diff is collapsed.
...@@ -479,7 +479,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -479,7 +479,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
var generate_fields = { var generate_fields = {
button: {default: _buttons}, button: {default: _buttons},
submit: {default: _buttons}, submit: {default: _buttons},
file: {default: function (scope, v, k) { file: {
default: function (scope, v, k) {
scope.form[scope.form.indexOf(k)] = { scope.form[scope.form.indexOf(k)] = {
type: "template", type: "template",
title: v.title, title: v.title,
...@@ -493,8 +494,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -493,8 +494,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
avatar: k === 'avatar' avatar: k === 'avatar'
}; };
v.type = 'string'; v.type = 'string';
}}, }
select: {default: function (scope, v, k) { },
select: {
default: function (scope, v, k) {
scope.form[scope.form.indexOf(k)] = { scope.form[scope.form.indexOf(k)] = {
type: "template", type: "template",
title: v.title, title: v.title,
...@@ -503,8 +506,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -503,8 +506,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
key: k, key: k,
titleMap: v.titleMap titleMap: v.titleMap
}; };
}}, }
date: {default: function (scope, v, k) { },
date: {
default: function (scope, v, k) {
$log.debug('date:', scope.model[k]); $log.debug('date:', scope.model[k]);
scope.model[k] = generator.dateformatter(scope.model[k]); scope.model[k] = generator.dateformatter(scope.model[k]);
scope.form[scope.form.indexOf(k)] = { scope.form[scope.form.indexOf(k)] = {
...@@ -547,38 +552,47 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -547,38 +552,47 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
scope.model[k] = angular.copy(generator.dateformatter(scope.model[k])); scope.model[k] = angular.copy(generator.dateformatter(scope.model[k]));
} }
}; };
}}, }
},
int: {default: _numbers}, int: {default: _numbers},
boolean: {default: function () {}}, boolean: {
string: {default: function () {}}, default: function () {
typeahead: {default: function (scope, v, k) { }
scope.form[scope.form.indexOf(k)] = { },
type: "template", string: {
title: v.title, default: function () {
titleMap: v.titleMap, }
templateUrl: "shared/templates/typeahead.html", },
name: k, typeahead: {
key: k, default: function (scope, v, k) {
onDropdownSelect: function (item, inputname) { scope.form[scope.form.indexOf(k)] = {
scope.model[k] = item.value; type: "template",
$timeout(function () { title: v.title,
document.querySelector('input[name=' + inputname + ']').value = item.name; titleMap: v.titleMap,
}); templateUrl: "shared/templates/typeahead.html",
} name: k,
}; key: k,
v.type = 'string'; onDropdownSelect: function (item, inputname) {
}}, scope.model[k] = item.value;
$timeout(function () {
document.querySelector('input[name=' + inputname + ']').value = item.name;
});
}
};
v.type = 'string';
}
},
text_general: { text_general: {
default: default: function (scope, v, k) {
function (scope, v, k) { v.type = 'string',
v.type = 'string',
v["x-schema-form"] = { v["x-schema-form"] = {
"type": "textarea" "type": "textarea"
} }
} }
}, },
float: {default: _numbers}, float: {default: _numbers},
model: {default: function (scope, v, k) { model: {
default: function (scope, v, k) {
var formitem = scope.form[scope.form.indexOf(k)]; var formitem = scope.form[scope.form.indexOf(k)];
var modelScope = { var modelScope = {
...@@ -675,7 +689,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -675,7 +689,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
scope.form[scope.form.indexOf(k)] = formitem; scope.form[scope.form.indexOf(k)] = formitem;
}}, }
},
Node: { Node: {
default: _node_default, default: _node_default,
filter_interface: _node_filter_interface filter_interface: _node_filter_interface
...@@ -796,7 +811,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -796,7 +811,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
//generator.button_switch(false);
return $http return $http
.post(generator.makeUrl(scope), scope.form_params) .post(generator.makeUrl(scope), scope.form_params)
.then(function (res) { .then(function (res) {
...@@ -813,7 +827,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -813,7 +827,6 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*} * @returns {*}
*/ */
generator.get_list = function (scope) { generator.get_list = function (scope) {
//generator.button_switch(false);
return $http return $http
.post(generator.makeUrl(scope), scope.form_params) .post(generator.makeUrl(scope), scope.form_params)
.then(function (res) { .then(function (res) {
...@@ -831,11 +844,14 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -831,11 +844,14 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*} * @returns {*}
*/ */
generator.get_wf = function (scope) { 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 return $http
.post(generator.makeUrl(scope), scope.form_params) .post(generator.makeUrl(scope), scope.form_params)
.then(function (res) { .then(function (res) {
//generator.button_switch(true);
return generator.pathDecider(res.data.client_cmd, scope, res.data); return generator.pathDecider(res.data.client_cmd, scope, res.data);
}); });
}; };
...@@ -1065,6 +1081,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1065,6 +1081,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
"query": $scope.form_params.query "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) return $http.post(generator.makeUrl($scope), data)
.success(function (data, status, headers) { .success(function (data, status, headers) {
if (headers('content-type') === "application/pdf") { if (headers('content-type') === "application/pdf") {
......
...@@ -14,10 +14,17 @@ angular.module('ulakbus') ...@@ -14,10 +14,17 @@ angular.module('ulakbus')
.service('WSUri', function () { .service('WSUri', function () {
return {url: 'ws://localhost:9001/ws'} 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 * WSOps operates all websocket interactions
*/ */
.service('WSOps', function (WSUri, $log) { .factory('WSOps', function (WSUri, $q, $log) {
var websocket = new WebSocket(WSUri.url); var websocket = new WebSocket(WSUri.url);
websocket.onopen = function (evt) { websocket.onopen = function (evt) {
wsOps.onOpen(evt) wsOps.onOpen(evt)
...@@ -39,15 +46,42 @@ angular.module('ulakbus') ...@@ -39,15 +46,42 @@ angular.module('ulakbus')
wsOps.onClose = function(event) { wsOps.onClose = function(event) {
$log.info("DISCONNEDTED", event); $log.info("DISCONNEDTED", event);
}; };
// two types of data can be come from websocket: with / without callback
//
wsOps.callbacks = {};
wsOps.onMessage = function(event) { 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); $log.info("MESSAGE:", event.data);
}; };
wsOps.onError = function(evt) { wsOps.onError = function(evt) {
$log.error("Error :: " + evt); $log.error("ERROR :: " + evt);
}; };
wsOps.doSend = function(data) { wsOps.doSend = function(data) {
websocket.send(data); websocket.send(data);
$log.info('SENT:', 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; return wsOps;
}); });
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -32,6 +32,13 @@ body { ...@@ -32,6 +32,13 @@ body {
background-color:#999; background-color:#999;
} }
.tooltip {
font-family:'robotolight';
font-size:13px;
letter-spacing:0.3px;
padding:15px;
}
.badge { .badge {
border-radius: 100%; border-radius: 100%;
width: 22px; width: 22px;
...@@ -1584,6 +1591,225 @@ table.dataTable thead .sorting:after { ...@@ -1584,6 +1591,225 @@ table.dataTable thead .sorting:after {
/* END OF SIDEBAR COLLAPSE */ /* 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 */ /* Responsive: Portrait tablets and up */
@media screen and (min-width: 768px) { @media screen and (min-width: 768px) {
/* Remove the padding we set earlier */ /* 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