|
| 1 | +/* global angular */ |
| 2 | +'use strict'; |
| 3 | + |
| 4 | +angular.module('testApp', ['streamApi']) |
| 5 | +.controller('testController', ['streamApiService', function(streamApiService) { |
| 6 | + this.doLogin = function() { |
| 7 | + var self = this; |
| 8 | + self.loginData = {}; |
| 9 | + try { |
| 10 | + var streamApi = streamApiService.getInstance({url: self.host, version:'5.0'}); |
| 11 | + } catch(e) { |
| 12 | + self.loginData = e.message; |
| 13 | + } |
| 14 | + |
| 15 | + streamApi.login(self.username, self.password) |
| 16 | + .then(function(response) { |
| 17 | + self.loginData.loginData = response.data; |
| 18 | + var params = {}; |
| 19 | + params['name'] = 'task ^&%$#@!~`'; |
| 20 | + // params['status' + streamApi.Constants.MOD] = streamApi.Constants.Operators.NOTEQUAL; |
| 21 | + params[streamApi.Constants.LIMIT] = 1; |
| 22 | + return streamApi.search('task', params, 'ID'); |
| 23 | + }) |
| 24 | + .then(function(response) { |
| 25 | + self.loginData.searchedTask = response.data; |
| 26 | + var params = {}; |
| 27 | + params['status'] = 'NEW'; |
| 28 | + // params['status' + streamApi.Constants.MOD] = streamApi.Constants.Operators.NOTEQUAL; |
| 29 | + params[streamApi.Constants.LIMIT] = 1; |
| 30 | + return streamApi.search('project', params, 'ID'); |
| 31 | + }) |
| 32 | + .then(function(response) { |
| 33 | + self.loginData.projectData = response.data; |
| 34 | + var data = { |
| 35 | + name: 'Task created by angular-stream-api', |
| 36 | + projectID: response.data.data[0].ID |
| 37 | + }; |
| 38 | + return streamApi.create('task', data); |
| 39 | + }) |
| 40 | + .then(function(response) { |
| 41 | + self.loginData.createdTask = response.data; |
| 42 | + var actionArgs = { |
| 43 | + userIDs: [streamApi.Constants.WildCards.USER], |
| 44 | + roleIDs: [] |
| 45 | + }; |
| 46 | + return streamApi.execute('task', response.data.data.ID, 'assignMultiple', actionArgs); |
| 47 | + }) |
| 48 | + .then(function(response) { |
| 49 | + self.loginData.assignedTask = response.data; |
| 50 | + return streamApi.execute('task', response.data.data.ID, 'markDone'); |
| 51 | + }) |
| 52 | + .then(function(response) { |
| 53 | + self.loginData.doneTask = response.data; |
| 54 | + }) |
| 55 | + .catch(function(error) { |
| 56 | + self.loginData.error = error; |
| 57 | + }); |
| 58 | + }; |
| 59 | +}]); |
0 commit comments