UNPKG

unserver-unify

Version:

85 lines (84 loc) 2.27 kB
'use strict'; angular.module('bamboo.mystudy').controller('TasksCtrl', function( ApiService, UserService) { var _self = this; this.tasks = []; var appUrl = ApiService.APPURL; var info = { action: "gettasks", } UserService.UserApi(info, function(result) { console.log(result); var task = result; var _tasks = []; if (!task) { return; } if (task.enroll) { angular.forEach(task.enroll, function(val, key) { console.log('enroll', key); var info = { type: "enroll", color: "red", name: val, // url:appUrl+"/exam/test/exam/"+key+"/", icon: "fa fa-book", content: "You have course to enroll!", state: "index.courses.info", id: key, } _tasks.push(info); }) } if (task.courseexam) { var counter = 0; angular.forEach(task.courseexam, function(val, key) { console.log('exam', key); var info = { type: "courseexam", color: "green", name: val, url: appUrl + "/exam/test/exam/" + key + "/", icon: "fa fa-check-square-o", // state:"index.myspace.assignments.detail", content: "You have exams to take!", // state:"index.myspace.exams", id: key, } _tasks.push(info); }) } if (task.assignment) { var counter = 0; angular.forEach(task.assignment, function(val, key) { console.log('ass', key); var info = { type: "assignment", color: "blue", name: val, icon: "fa fa-tasks", content: "You have assignments to take!", state: "index.myspace.assignments.detail", id: key, } _tasks.push(info); }) } _self.tasks = _tasks; console.log(_tasks); }); this.delete=function(task){ console.log(task); var info={ action:"deletetask", type:task.type, id:task.id, }; UserService.UserApi(info); } this.updateUserTask=function(){ var info={ action:'updateUserTask', } UserService.UserApi(info); } });