Beispiel #1
1
 /**
  * Получение меню
  * @return array
  */
 public function getData($active)
 {
     if ($active != null) {
         self::$data['menu']['active'] = $active;
     }
     // Берем список проектов пользователя
     if (\Yii::$app->cache->exists('project:user:'******'project:user:'******'staff_id' => \Yii::$app->user->id])->all();
         \Yii::$app->cache->set('project:user:'******'id');
     // Получение списка профайлеров по проектам
     $command = new ListProfiler\command\GetProfilerList();
     $command->setClassModel('app\\models\\amop\\models\\ListProfiler');
     $profiler = $command->setData($idProject)->execute();
     // Формирование списка профайлеров для меню
     foreach ($profiler as $valueProfiler) {
         $profilerMenu = ['label' => $valueProfiler['message'], 'name' => "profiler_" . $valueProfiler['id'], 'class' => "profiler_" . $valueProfiler['id'], 'icon_class' => 'fa fa-cube', 'badges' => ['class' => "label pull-right bg-red"], 'url' => '/profiler/detail/' . $valueProfiler['id']];
         self::$data['menu']['item'][1]['item'][] = $profilerMenu;
     }
     // Формирование списка проектов для меню
     foreach ($project as $value) {
         self::$data['menu']['item'][0]['item'][] = ['label' => $value->title, 'name' => "project_" . $value->id, 'icon_class' => 'fa fa-cube', 'url' => '/project/detail/' . $value->id];
     }
     self::$data['user']['data']['avatar'] = \Yii::$app->user->getIdentity()->avatar;
     self::$data['user']['data']['name'] = \Yii::$app->user->getIdentity()->name;
     self::$data['user']['data']['surname'] = \Yii::$app->user->getIdentity()->surname;
     return self::$data;
 }
Beispiel #2
0
 /**
  * todo Сделать ограничение на частоту добавления с одного проекта
  * @return array
  * @throws HttpException
  */
 public function actionAdd()
 {
     $json = file_get_contents('php://input');
     $data = json_decode($json);
     if ($this->generateSecretKey($data->projectId . '-' . $data->projectKey) != $data->secretKey) {
         throw new HttpException(400, 'Secret_key is incorrect');
     }
     $project = Project::find()->where(['id' => $data->projectId, 'secret_key' => $data->projectKey])->one();
     if (!$project) {
         throw new HttpException(400, 'Project not found or project_key is incorrect');
     }
     foreach ($data->data as $object) {
         $message = $object;
         $message->date_create = $data->dateCreate;
         $message->project_id = $data->projectId;
         $result = \Yii::$app->gearman->getDispatcher()->background('AddProfiler', new JobWorkload(['params' => ['data' => $message]]));
     }
     return ['status' => 200, 'message' => 'Success'];
 }
Beispiel #3
0
 /**
  * @return array
  */
 public function actionCount()
 {
     $result = ['profiler' => ['total' => false, 'item' => []]];
     // Берем список проектов пользователя
     if (\Yii::$app->cache->exists('project:user:'******'project:user:'******'staff_id' => \Yii::$app->user->id])->all();
         \Yii::$app->cache->set('project:user:'******'id');
     // Получение списка профайлеров по проектам
     $command = new ListProfiler\command\GetProfilerList();
     $command->setClassModel('app\\models\\amop\\models\\ListProfiler');
     $profiler = $command->setData($idProject)->execute();
     $idProfiler = ArrayHelper::getColumn($profiler, 'id');
     // Получаем список новых элементов для профайлеров
     $countProfiler = CountData::getModel(CountData::TYPE_PROFILER)->setData(function () use($idProfiler) {
         return LastActiveDate::getModel(LastActiveDate::TYPE_PROFILER)->setData($idProfiler)->setUserId(\Yii::$app->user->id)->get();
     })->getCount();
     $result['profiler']['item'] = $countProfiler;
     $countProfiler ? $result['profiler']['total'] = 'new' : ($result['profiler']['total'] = false);
     return ['status' => 200, 'result' => $result];
 }
Beispiel #4
0
 /**
  * Список проектов пользователя
  * @return string
  */
 public function actionIndex()
 {
     $cache = false;
     $query = Project::find()->where(['staff_id' => Yii::$app->user->id])->with('staff');
     $data = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => self::PAGE_SIZE], 'sort' => false]);
     if (Yii::$app->request->get('page') == '' or Yii::$app->request->get('page') == 1) {
         $cache = true;
     }
     return $this->render('index.tpl', ['data' => $data, 'cache' => $cache, 'cacheTime' => self::CACHE_TIME_LIST_PROJECT]);
 }