From c60496e207e7e3cb61551716c46f7a357f07d6e9 Mon Sep 17 00:00:00 2001 From: "Heekyoung, Oh" Date: Tue, 25 Apr 2017 11:58:55 +0900 Subject: [PATCH] [TIC-Web] Update the Job Section - Add the array initilization for the JobModelList - Add the user name when job created Change-Id: I5784e8d07012db3d1e72a7e44880fc87bdf8e8a0 Signed-off-by: Heekyoung, Oh --- controller/dbquery.js | 28 ++++++++++++++++++++++++---- public/src/js/page/job.js | 2 ++ public/src/js/page/login.js | 12 ++++++++---- public/src/js/page/package.js | 22 +++++++++++++++++++--- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/controller/dbquery.js b/controller/dbquery.js index 58b214a..ad88c8d 100644 --- a/controller/dbquery.js +++ b/controller/dbquery.js @@ -41,8 +41,23 @@ var mariadb = {}; mariadb.queries = { 'addJob': [ 'insert into tic_job ', - '(job_status, job_deleted, job_hasksfile, job_updater, job_uptime, job_register, job_regtime) ', - 'values ("READY", false, false, "tic", now(), "tic", now());' + '(', + 'job_status, ', + 'job_deleted, ', + 'job_hasksfile, ', + 'job_updater, ', + 'job_uptime, ', + 'job_register, ', + 'job_regtime', + ') ', + 'values (', + '"READY", ', + 'false, ', + 'false, ', + '"<%= strUpdater %>", ', + 'now(), ', + '"<%= strRegister %>", ', + 'now());' ], 'getJobById': [ 'select tic_job.job_id job_id, ', @@ -219,7 +234,9 @@ mariadb.editJob = function editJob(req, res) { * Add The New Job */ mariadb.addJob = function addJob(req, res) { - var queryString; + var queryString, strUser; + + strUser = req.body.user; function onSuccess(rows) { logger.info('addJob.success: {job_id: ' + rows.result.info.insertId + '}'); @@ -228,7 +245,10 @@ mariadb.addJob = function addJob(req, res) { }); } - queryString = _.join(this.queries['addJob'], ''); + queryString = _.template(_.join(this.queries['addJob'], ''))({ + strUpdater: strUser, + strRegister: strUser + }); logger.info('addJob: query = ' + queryString); diff --git a/public/src/js/page/job.js b/public/src/js/page/job.js index ac0995b..80bf81a 100644 --- a/public/src/js/page/job.js +++ b/public/src/js/page/job.js @@ -154,6 +154,8 @@ define([ function _updateDataModel(result) { logger.info('_updateDataModel'); return new Promise(function (resolve, reject) { + ModelJobList = []; + // model _.forEach(result, function (jobItem) { var item; diff --git a/public/src/js/page/login.js b/public/src/js/page/login.js index db833bd..2141b2a 100644 --- a/public/src/js/page/login.js +++ b/public/src/js/page/login.js @@ -20,14 +20,16 @@ define([ 'js/util', 'js/logger', 'js/page/job', - 'js/page/image' + 'js/page/image', + 'js/page/package', ], function ( $, BootstrapValidator, Util, Logger, Job, - Image + Image, + Package ) { 'use strict'; @@ -123,13 +125,15 @@ define([ /** * Permission control in packages page */ - function _updatePackagePage(group) { + function _updatePackagePage(user) { + var group = user.group; // Image Creation Button if (group === 'GUEST') { $('#tic-package-create').toggleClass('hidden', true); } else { $('#tic-package-create').toggleClass('hidden', false); } + Package.updateUserInfo(user); } /** @@ -153,7 +157,7 @@ define([ Util.GET('api/session') .then(function (user) { _updateLogin(user); - _updatePackagePage(user.group); + _updatePackagePage(user); _updateJobPage(user); _updateImagePage(user); }); diff --git a/public/src/js/page/package.js b/public/src/js/page/package.js index a9448e2..2a00b47 100644 --- a/public/src/js/page/package.js +++ b/public/src/js/page/package.js @@ -65,6 +65,9 @@ define([ // AppConfig var AppConfig = null; + // User + var UserInfo; + function onClickHandlerForImgCreationBtn() { logger.info('onClickHandlerForImgCreationBtn'); @@ -165,9 +168,12 @@ define([ return Util.POST(AppConfig.EVENT.JOB.JOB_GET_BYID + jobId); } - function addJob(cnt) { + function addJob() { logger.info('onClickHandlerForImgCreationBtn.addJob'); - return Util.POST(AppConfig.EVENT.JOB.JOB_ADD_ONE); + var msgObj = { + user: UserInfo.email + }; + return Util.POST(AppConfig.EVENT.JOB.JOB_ADD_ONE, msgObj); } // confirm dialog @@ -1580,6 +1586,11 @@ define([ }); } + function updateUserInfo(user) { + logger.info('updateUserInfo'); + UserInfo = user; + } + function init() { logger.info('init'); @@ -1622,6 +1633,11 @@ define([ * @method getCheckedPackages * @return {array} array of objects */ - getCheckedPackages: _getChecked + getCheckedPackages: _getChecked, + + /** + * Update the user information + */ + updateUserInfo: updateUserInfo } }); -- 2.7.4