Пример #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Add 10000 values to the first Chart in the database.
     $first = Chart::find(1);
     $date = Carbon::now();
     for ($i = 0; $i < 10000; $i++) {
         DB::table('chart_values')->insert(['timestamp' => $date, 'value' => $this->purebell(10, 35, 3, 0.5), 'chart_id' => $first->id]);
         $date = Carbon::parse($date)->addSecond($first->refresh_time_seconds);
     }
     // Add 5000 values to 2nd table
     $second = Chart::find(2);
     $date = Carbon::now();
     for ($i = 0; $i < 5000; $i++) {
         DB::table('chart_values')->insert(['timestamp' => $date, 'value' => $this->purebell(40, 50, 2, 0.5), 'chart_id' => $second->id]);
         $date = Carbon::parse($date)->addSecond($second->refresh_time_seconds);
     }
     // 1000 values to 3rd table
     $third = Chart::find(3);
     $date = Carbon::now();
     for ($i = 0; $i < 1000; $i++) {
         DB::table('chart_values')->insert(['timestamp' => $date, 'value' => $this->purebell(300, 400, 1, 0.5), 'chart_id' => $third->id]);
         $date = Carbon::parse($date)->addSecond($third->refresh_time_seconds);
     }
     // Adds 1000 values from last year to 4th table
     $fourth = Chart::find(4);
     $date = Carbon::now()->subYear(1);
     for ($i = 0; $i < 1000; $i++) {
         DB::table('chart_values')->insert(['timestamp' => $date, 'value' => $this->purebell(24, 27, 2, 0.5), 'chart_id' => $fourth->id]);
         $date = Carbon::parse($date)->addSecond($third->refresh_time_seconds);
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::transaction(function () {
         DB::statement("create temporary table unique_entities (select e.id as orig_id, e.name as name, (select min(id) from entities where entities.name=e.name) as uniq_id from entities as e);");
         $pairs = DB::select("select orig_id, uniq_id from unique_entities where orig_id != uniq_id;");
         $oldToUnique = [];
         foreach ($pairs as $pair) {
             $oldToUnique[$pair->orig_id] = $pair->uniq_id;
         }
         $charts = Chart::all();
         foreach ($charts as $chart) {
             $config = json_decode($chart->config);
             $countries = $config->{'selected-countries'};
             if (empty($countries)) {
                 continue;
             }
             foreach ($countries as $country) {
                 if (array_key_exists($country->id, $oldToUnique)) {
                     echo "Updating chart config for " . $chart->id . " changing entity id from " . $country->id . " to " . $oldToUnique[$country->id] . "\n";
                     $country->id = $oldToUnique[$country->id];
                 }
             }
             $chart->config = json_encode($config);
             $chart->save();
         }
         DB::statement("update data_values as dv inner join unique_entities as e on e.orig_id=dv.fk_ent_id set dv.fk_ent_id=e.uniq_id;");
         DB::statement("delete from entities where entities.id in (select orig_id from unique_entities where orig_id != uniq_id);");
         DB::statement("drop table unique_entities;");
     });
     Schema::table("entities", function ($table) {
         $table->unique('name');
     });
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $chart = Chart::find($id);
     if ($chart) {
         $data = new \StdClass();
         $logoUrl = Setting::where('meta_name', 'logoUrl')->first();
         $data->logoUrl = !empty($logoUrl) ? url('/') . '/' . $logoUrl->meta_value : '';
         return view('view.show', compact('chart', 'data'));
     } else {
         return 'No chart found to view';
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('charts', function ($table) {
         $table->dropForeign('charts_updated_by_foreign');
         $table->renameColumn('updated_by', 'last_edited_by');
         $table->foreign('last_edited_by')->references('name')->on('users');
         $table->timestamp('last_edited_at');
     });
     foreach (Chart::all() as $chart) {
         $chart->last_edited_at = $chart->updated_at;
         $chart->save();
     }
 }
Пример #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Seeds the database with locations, chart types, chart units, and charts.
     Location::create(['name' => 'Stofa 101']);
     Location::create(['name' => 'Stofa 202']);
     DB::table('chart_types')->insert(array(array('type' => 'line'), array('type' => 'spline'), array('type' => 'area'), array('type' => 'areaspline')));
     DB::table('chart_units')->insert(array(array('unit' => 'Hitastig', 'symbol' => '°C', 'icon_path' => 'icon_temperature.png'), array('unit' => 'Rakastig', 'symbol' => '%', 'icon_path' => 'icon_humidity.png'), array('unit' => 'Koltvíoxíð', 'symbol' => 'ppm', 'icon_path' => 'icon_pollution.png')));
     Chart::create(['name' => 'Hitastig', 'location_id' => 1, 'type_id' => 1, 'unit_id' => 1, 'auth' => str_random(6)]);
     Chart::create(['name' => 'Rakastig', 'location_id' => 1, 'type_id' => 1, 'unit_id' => 2, 'auth' => str_random(6)]);
     Chart::create(['name' => 'Loftgæði', 'location_id' => 1, 'type_id' => 1, 'unit_id' => 3, 'auth' => str_random(6)]);
     Chart::create(['name' => 'Stofa 202 Hiti', 'location_id' => 2, 'type_id' => 2, 'unit_id' => 1, 'refresh_time_seconds' => 500, 'auth' => str_random(6)]);
     Chart::create(['name' => '202 Raki', 'location_id' => 2, 'type_id' => 3, 'unit_id' => 2, 'visible' => true, 'auth' => str_random(6)]);
     // Seed the users table
     User::create(['name' => 'Admin', 'email' => '*****@*****.**', 'password' => bcrypt('timeseries')]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('charts', function ($table) {
         $table->text('slug');
     });
     $charts = Chart::all();
     foreach ($charts as $chart) {
         $s = strtolower($chart->name);
         $s = preg_replace('/\\s*\\*.+\\*/', '', $s);
         $s = preg_replace('/[^\\w- ]+/', '', $s);
         $s = preg_replace('/ +/', '-', trim($s));
         $chart->slug = $s;
         $chart->save();
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::transaction(function () {
         $charts = Chart::all();
         foreach ($charts as $chart) {
             $config = json_decode($chart->config);
             if (!isset($config->{'map-config'})) {
                 continue;
             }
             $interval = $config->{'map-config'}->timeInterval;
             if ($interval && $interval != 1) {
                 $timeRanges = [array("startYear" => "first", "endYear" => "last", "interval" => $interval)];
                 var_dump($timeRanges);
                 $config->{'map-config'}->timeRanges = $timeRanges;
             }
             $chart->config = json_encode($config);
             $chart->save();
         }
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::transaction(function () {
         DataValue::where('fk_ent_id', 341)->update(array('fk_ent_id' => 355));
         Entity::where('id', 341)->delete();
         $charts = Chart::all();
         foreach ($charts as $chart) {
             $config = json_decode($chart->config);
             $countries = $config->{'selected-countries'};
             if (empty($countries)) {
                 continue;
             }
             foreach ($countries as $country) {
                 if ($country->id == "341") {
                     echo "Updating chart config for " . $chart->id . "\n";
                     $country->id = "355";
                     $country->name = "World";
                 }
             }
             $chart->config = json_encode($config);
             $chart->save();
         }
     });
 }
 public function dimensions(Request $request)
 {
     set_time_limit(10);
     ini_set('memory_limit', '256M');
     //check we have everything we should have
     if (!Input::has('dimensions')) {
         //we don't have necessary info, bail out
         return ['success' => false];
     }
     //filtering by entities?
     $selectedCountriesIds = Input::get("selectedCountries");
     $selectedCountriesIdsString = !empty($selectedCountriesIds) && count($selectedCountriesIds) > 0 ? implode(",", $selectedCountriesIds) : "";
     //filtering by time?
     $chartTime = Input::get("chartTime");
     if (Input::has('chartId')) {
         //caching - construct key with selected countries as well
         $key = 'chart-dimensions-' . Input::get('chartId') . '-countries-' . $selectedCountriesIdsString;
         //if there's something in cache and not exporting
         if (Cache::has($key) && !Input::has('export') && (Input::has('cache') && Input::get('cache') === "true")) {
             //return Cache::get( $key );
         }
     }
     $data = array();
     //extra array for storing values for export
     $times = array();
     $datasourcesIdsArr = array();
     $dimensionsInput = Input::get('dimensions');
     $dimensions = json_decode($dimensionsInput);
     //isn't it just empty object
     if (empty($dimensions)) {
         return ['success' => false];
     }
     $chartType = Input::get('chartType');
     //there's special setting for linechart
     $isLineChart = $chartType == "1" || $chartType == "4" || $chartType == "5" || $chartType == "6" ? true : false;
     //find out how many variables we have
     $groupByEntity = Input::get('groupByVariables') == 'false' ? true : false;
     //special case for linechart with multiple variables
     $multiVariantByEntity = false;
     if ($groupByEntity && $isLineChart && count($dimensions) > 1) {
         //make sure they're all
         foreach ($dimensions as $dimension) {
             if ($dimension->property !== "y") {
                 $multiVariantByEntity = false;
                 break;
             }
             $multiVariantByEntity = true;
         }
     }
     $timeType = '';
     if ($groupByEntity) {
         $entities = array();
         $dataByEntity = array();
         $dataByEntityTime = array();
     } else {
         $variables = array();
         $dataByVariable = array();
         $dataByVariableTime = array();
     }
     /**
      * 1) get data into variable
      **/
     //store the longest variable, will be used as main one
     $dimensionsByKey = [];
     $minDataLength = false;
     $mainDimId = false;
     $otherDimIds = [];
     //for edge cases for legend, we need to store entityname
     $entityName = "";
     //categorical data
     $categoricalData = array();
     $categoricalData["color"] = array();
     $categoricalData["shape"] = array();
     $categoricalDimensions = array();
     foreach ($dimensions as $dimension) {
         $id = $dimension->variableId;
         //use query builder instead of eloquent
         $variableQuery = DB::table('data_values')->select('data_values.*', 'times.*', 'entities.name as name', 'variables.name as variable_name')->join('entities', 'data_values.fk_ent_id', '=', 'entities.id')->join('variables', 'data_values.fk_var_id', '=', 'variables.id')->join('times', 'data_values.fk_time_id', '=', 'times.id')->where('data_values.fk_var_id', $id);
         //are we filtering based on entity selection?
         if (!empty($selectedCountriesIds) && count($selectedCountriesIds) > 0) {
             $variableQuery->whereIn('data_values.fk_ent_id', $selectedCountriesIds);
         }
         //are we filtering based on time selection?
         if (!empty($chartTime) && count($chartTime) > 1) {
             //exclude categorical properties from time filtering
             if ($dimension->property !== "color" && $dimension->property !== "shape") {
                 $minTime = $chartTime[0];
                 $maxTime = $chartTime[1];
                 $variableQuery->where('times.startDate', '>=', $minTime);
                 //$variableQuery->where( 'times.date', '>=', $minTime );
                 $variableQuery->where('times.endDate', '<=', $maxTime);
                 //$variableQuery->where( 'times.date', '<=', $maxTime );
             }
         }
         $variableData = $variableQuery->get();
         //insert data into existing variable
         $dimension->data = $variableData;
         //is shortes variable? cannot be color/shape variable
         $dataLen = count($variableData);
         if (($dataLen > $minDataLength || !$minDataLength) && ($dimension->property != "color" && $dimension->property != "shape")) {
             $minDataLength = $dataLen;
             $mainDimId = $id;
         }
         //is categorical data
         if ($dimension->property === "color" || $dimension->property === "shape") {
             //store it for later processing
             $categoricalDimensions[] = $dimension;
         }
     }
     /**
      * 2) assign data to entities
      **/
     foreach ($dimensions as $dimension) {
         $id = $dimension->variableId;
         $property = $dimension->property;
         $variableData = $dimension->data;
         //store in array for step 3
         $dimensionsByKey[$id] = $dimension;
         if ($id != $mainDimId) {
             $otherDimIds[] = $id;
         }
         //selectedCountries
         if ($groupByEntity) {
             //group variable data by entities
             //$i = 0;
             $oldEntityId = -1;
             foreach ($variableData as $datum) {
                 //$entityId = $datum->fk_ent_id;
                 $entityId = !$multiVariantByEntity ? $datum->fk_ent_id : $datum->fk_ent_id . "-" . $datum->fk_var_id;
                 //check if new entity and we need to reset cycle
                 if ($oldEntityId != $entityId) {
                     //$i = 0;
                 }
                 $oldEntityId = $entityId;
                 //do we have already object for that entity
                 if (!array_key_exists($entityId, $dataByEntity)) {
                     $key = !$multiVariantByEntity ? $datum->name : $datum->name . " - " . $datum->variable_name;
                     $dataByEntity[$entityId] = array("id" => $entityId, "key" => $key, "entity" => $datum->name, "values" => []);
                 }
                 //is it first property being saved for given property
                 if (!array_key_exists($property, $dataByEntity[$entityId]["values"])) {
                     $dataByEntity[$entityId]["values"][$property] = [];
                 }
                 //store value
                 //AMMEND HERE - store as startYear-endYear?
                 $timeId = $datum->fk_ttype_id !== "6" ? floatval($datum->date) : floatval($datum->startDate) . "-" . floatval($datum->endDate);
                 $dataByEntity[$entityId]["values"][$property][$timeId] = $property != "color" && $property != "shape" && $property != "map" ? floatval($datum->value) : $datum->value;
                 //need to store dimension variablename, dimensions are returned
                 if (!array_key_exists("variableName", $dimension)) {
                     $dimension->variableName = $datum->variable_name;
                 }
                 //if is linechart, store time into x axis
                 /*if( $isLineChart ) {
                 			$dataByEntity[ $entityId ][ "values" ][ $i ][ "x" ] = floatval( $datum->date );
                 		}
                 		$i++;*/
                 //store time type if not stored
                 if (empty($timeType)) {
                     $timeType = TimeType::find($datum->fk_ttype_id)->name;
                 }
                 //store for the need of export
                 if (!array_key_exists($entityId, $dataByEntityTime)) {
                     $dataByEntityTime[$entityId] = [];
                     $entities[$entityId] = $datum->name;
                 }
                 $dataByEntityTime[$entityId][$datum->label] = $datum->value;
                 //AMMEND HERE - store simply as a string?
                 $times[floatval($datum->date)] = true;
                 $datasourcesIdsArr[$datum->fk_dsr_id] = true;
             }
         } else {
             //multivariables
             //get variable names
             $variable = Variable::find($dimension->variableId);
             $key = !empty($variable) && isset($variable->name) ? $variable->name : "";
             //could have display name
             if (!empty($dimension) && !empty($dimension->displayName)) {
                 $key = $dimension->displayName;
             }
             $dataByVariable["id-" . $id] = array("id" => $id, "key" => $key, "values" => []);
             //store variable name to dimension info (useful for stack bar chart)
             $dimensionsByKey[$id]->variableName = $key;
             foreach ($variableData as $datum) {
                 //store entity name for legend purposes
                 $entityName = $datum->name;
                 $dataByVariable["id-" . $id]["values"][] = array("x" => floatval($datum->date), "y" => floatval($datum->value));
                 $times[$datum->label] = true;
                 $datasourcesIdsArr[$datum->fk_dsr_id] = true;
                 //store time type if not stored
                 if (empty($timeType)) {
                     $timeType = TimeType::find($datum->fk_ttype_id)->name;
                 }
                 //store for the need of export
                 if (!array_key_exists($dimension->variableId, $dataByVariableTime)) {
                     $dataByVariableTime[$dimension->variableId] = [];
                     $variables[$dimension->variableId] = $datum->fk_var_id;
                 }
                 $dataByVariableTime[$dimension->variableId][$datum->label] = $datum->value;
             }
         }
     }
     /**
      * 3) prepare array for different chart types
      **/
     //$normalizedData = [];
     $mainDimension = $dimensionsByKey[$mainDimId];
     if ($groupByEntity) {
         $normalizedData = Chart::formatDataForChartType($chartType, $dataByEntity, $dimensionsByKey, $times, false, $mainDimension, $otherDimIds);
     } else {
         //grouping by variable, for linechart, we already have what we need
         if ($chartType !== '1' && $chartType !== '2') {
             $dataByVariable = Chart::formatDataForChartType($chartType, $dataByVariableTime, $dimensionsByKey, $times, true, $mainDimension, $otherDimIds, $entityName);
         }
     }
     if ($chartType == '9999') {
         //if getting dimensions for map, don't need info bellow, just send of the data
         $data = [];
         foreach ($normalizedData as $entityData) {
             $data[] = $entityData;
         }
         $result = ['success' => true, 'data' => $data];
         //TODO - put to cache
         //store into cache - there is no cache
         /*if( !empty( $key ) ) {
         			$minutes = 60*24;
         			Cache::put( $key, $result, $minutes );
         		}*/
         return $result;
     }
     if ($groupByEntity) {
         //convert to array
         foreach ($normalizedData as $entityData) {
             //TODO better check for this?
             if ($entityData['values']) {
                 //here we add any possible categorical data
                 foreach ($categoricalDimensions as $catDimension) {
                     $entityId = $entityData['id'];
                     //is there data for specific property
                     if (array_key_exists('values', $dataByEntity[$entityId]) && array_key_exists($catDimension->property, $dataByEntity[$entityId]['values'])) {
                         //get value - http://stackoverflow.com/questions/1028668/get-first-key-in-a-possibly-associative-array
                         $value = reset($dataByEntity[$entityId]['values'][$catDimension->property]);
                         $catValue = Chart::getValueForCategory($catDimension->property, $categoricalData, $value);
                         //color is assinged to whole entity, shape is assigned to individual data entries
                         if ($catDimension->property === "color") {
                             $entityData[$catDimension->property] = $catValue;
                         } else {
                             if ($catDimension->property === "shape") {
                                 foreach ($entityData["values"] as &$entityValue) {
                                     $entityValue[$catDimension->property] = $catValue;
                                 }
                             }
                         }
                     }
                 }
                 $data[] = $entityData;
             }
         }
     } else {
         //convert to array
         foreach ($dataByVariable as $varData) {
             $data[] = $varData;
         }
     }
     /**
      *	4) fetch all the other necessary data
      **/
     //get all necessary info for datasources
     $datasources = array();
     $prevDimension = "";
     $sourcesByNameDim = array();
     foreach ($dimensions as $dimension) {
         $datasource = new \stdClass();
         //special dimension header for linechart
         $dsr = Variable::getSource($dimension->variableId)->first();
         if ($isLineChart) {
             $dimension = false;
         }
         $currDimension = !empty($dimension) && isset($dimension->name) ? $dimension->name : "undefined";
         $datasource->description = !empty($dsr) ? $this->createSourceDescription($dimension, $dsr, $currDimension === $prevDimension) : '';
         $datasource->name = !empty($dsr) && !empty($dsr->name) ? $dsr->name : '';
         $datasource->link = !empty($dsr) && !empty($dsr->name) ? $dsr->link : '';
         //make sure we don't repeat for the same name and dimension
         $nameDimKey = $currDimension . "-" . $datasource->name;
         if (!isset($sourcesByNameDim[$nameDimKey])) {
             $datasources[] = $datasource;
             $sourcesByNameDim[$nameDimKey] = true;
         }
         //store curr dimension so we don't have to repeat title for next if it's same
         $prevDimension = !empty($dimension) && isset($dimension->name) ? $dimension->name : "";
     }
     /*$datasourcesIds = array_keys( $datasourcesIdsArr );
     		$datasourcesSources = Variable::getSources( $datasourcesIds )->get();//Datasource::findMany( $datasourcesIds );
     		$datasources = array();
     
     		//format datasources info (create generated tables)
     		foreach( $datasourcesSources as $datasourceSource ) {
     			$datasource = new \stdClass();
     			$dimension = $this->findDimensionForVarId( $dimensions, $datasourceSource->var_id );
     			//special dimension header for linechart
     			if( $isLineChart ) {
     				$dimension = false;
     			}
     			$datasource->description = $this->createSourceDescription( $dimension, $datasourceSource );
     			$datasource->name = $datasourceSource->name;
     			$datasource->link = $datasourceSource->link;
     			//$datasource->description = $datasourceSource->description;
     			$datasources[] = $datasource;
     		}*/
     //process data to csv friendly format
     $timeKeys = array_keys($times);
     //sort timeKeys by time
     //AMMEND HERE - what is intervals
     usort($timeKeys, function ($a, $b) {
         if ($a == $b) {
             return 0;
         } else {
             return $a > $b ? 1 : -1;
         }
     });
     //get all the licence information
     $license = License::find(1)->first();
     if ($request->ajax()) {
         $result = ['success' => true, 'data' => $data, 'dimensions' => $dimensions, 'datasources' => $datasources, 'timeType' => $timeType, 'license' => $license];
         //store into cache - there is no cache
         if (!empty($key)) {
             $minutes = 60 * 24;
             Cache::put($key, $result, $minutes);
         }
         return $result;
     } else {
         //export is now happening in front-end
         if (Input::has('export') && Input::get('export') == 'csv') {
             //http://localhost:8888/oxford/our-world-in-data-chart-builder/public/data/dimensions?dimensions=%5B%7B%22variableId%22%3A%221%22%2C%22property%22%3A%22y%22%2C%22name%22%3A%22Y+axis%22%7D%5D
             //return $data;
             //return $this->downloadCsv( $exportData );
         } else {
             //not ajax request, nor csv export, just spit out whatever is in data
             return $data;
         }
     }
 }
 public static function getSingleTimeValue($dimension, $time, $values)
 {
     //do we have value for exact time
     if (array_key_exists($time, $values)) {
         if ($dimension->mode === "latest" && isset($dimension->maximumAge)) {
             //for latest, we a have to check the latest avaiable data is not too old
             $nowTime = date("Y");
             $oldestAllowedTime = $nowTime - $dimension->maximumAge;
             if ($time < $oldestAllowedTime) {
                 //latest available time is too old, bail
                 return;
             }
         }
         $value = $values[$time];
     } else {
         //no we don't, try to around in recent years
         if ($dimension->mode !== "latest") {
             $value = Chart::lookAround($dimension, $time, $values);
         }
     }
     return $value;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Chart $chart)
 {
     $chart->delete();
     Cache::flush();
     return redirect()->route('charts.index')->with('message', 'Chart deleted.');
 }
 public function showChart(Chart $chart)
 {
     $referer_s = \Request::header('referer');
     if ($referer_s) {
         $root = parse_url(\Request::root());
         $referer = parse_url($referer_s);
         if ($root['host'] == $referer['host'] && strlen($referer['path']) > 1 && !str_contains($referer_s, ".html") && !str_contains($referer_s, "wp-admin") && !str_contains($referer_s, "preview=true") && !str_contains($referer_s, "how-to") && !str_contains($referer_s, "grapher") && !str_contains($referer_s, "about") && !str_contains($referer_s, "roser/")) {
             $chart->origin_url = "https://" . $root['host'] . $referer['path'];
             $chart->save();
         }
     }
     if ($chart) {
         $config = Chart::getConfigWithUrl($chart);
         $data = new \StdClass();
         $logoUrl = Setting::where('meta_name', 'logoUrl')->first();
         $data->logoUrl = !empty($logoUrl) ? url('/') . '/' . $logoUrl->meta_value : '';
         $canonicalUrl = URL::to($chart->slug);
         // Make metadata for twitter embed cards!
         $chartMeta = new \StdClass();
         // Replace the chart title placeholders with generic equivalents for now
         $title = $config->{"chart-name"};
         $title = preg_replace("/, \\*time\\*/", " over time", $title);
         $title = preg_replace("/\\*time\\*/", "over time", $title);
         $chartMeta->title = $title;
         // Description is required by twitter
         if (isset($config->{"chart-subname"})) {
             $chartMeta->description = $config->{"chart-subname"};
         } else {
             $chartMeta->description = "An interactive visualization from Our World In Data.";
         }
         $query = $_SERVER['QUERY_STRING'];
         $baseUrl = \Request::root() . "/" . $chart->slug;
         $canonicalUrl = $baseUrl;
         $imageUrl = $baseUrl . ".png";
         if ($query != '') {
             $canonicalUrl .= "?" . $query;
             $imageUrl .= "?" . $query;
         }
         $chartMeta->imageUrl = $imageUrl;
         $chartMeta->canonicalUrl = $canonicalUrl;
         // Give the image exporter a head start on the request for imageUrl
         if (!str_contains(\Request::path(), ".export")) {
             Chart::exportPNGAsync($chart->slug, $_SERVER['QUERY_STRING'] . "&size=1000x700", 1000, 700);
         }
         return view('view.show', compact('chart', 'config', 'data', 'canonicalUrl', 'chartMeta'));
     } else {
         return 'No chart found to view';
     }
 }
Пример #13
0
 public function update($id)
 {
     $input = Input::except('_method', '_token');
     $input['visible'] = Input::has('visible') ? 1 : 0;
     $chart = Chart::findOrFail($id);
     $chart->update($input);
     Log::info('Chart edited', ['chart' => $chart]);
     Session::flash('success', true);
     Session::flash('message', 'Aðgerð tókst: Uppfærsla á grafi');
     return Redirect::back();
 }
Пример #14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $chart = Chart::find($id);
     $id = $chart['project_id'];
     $chart->delete();
     return redirect()->action('ProjectsController@show', $id);
 }
Пример #15
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CreateProjectRequest $request)
 {
     //dd($request->input('users'));
     $input = Request::all();
     if ($input['target_mandays'] >= 60 or $input['budget'] >= 2000000) {
         $importance = "MAJOR";
     } else {
         $importance = "MINOR";
     }
     $id = Auth::user()->id;
     $pm = Auth::user()->name;
     Project::create(['cac' => $input['cac'], 'title' => $input['title'], 'user_id' => $id, 'pm' => $pm, 'status' => 'Not Yet Started', 'color' => 'Green', 'percent' => 0, 'target_start' => $input['target_start'], 'target_end' => $input['target_end'], 'actual_start' => '0000-00-00', 'actual_end' => '0000-00-00', 'budget' => $input['budget'], 'target_mandays' => $input['target_mandays'], 'actual_mandays' => '0', 'hardware' => $input['hardware'], 'software' => $input['software'], 'importance' => $importance, 'applicability' => $input['applicability'], 'confidentiality' => $input['confidentiality']]);
     $project = Project::all()->last();
     $project->users()->attach($request->input('users'));
     Chart::create(['project_id' => $project['id'], 'project_manager' => $project['pm']]);
     /* Upon creation of new project, checklist of deliverables are also created */
     $deliverables = [];
     $deliverables = ['Project Approval', 'Product Sign-off', 'Conceptual Solution Architecture Document', 'Risk and Issue Log', 'Project Definition Report', 'Project Repository', 'Project Kick-off Package', 'Proejct Organization Structure', 'Roles and Responsibilities', 'Project Timeline', 'Minutes of Project Kick-off Meeting', 'QM Classification Matrix', 'User Requirement Matrix', 'Business Process Re-engineering Document', 'Functional Specifications Document', 'Functional Specifications Sign-off', 'Conversion Plan', 'Solution Architecture Document (Logical)', 'Solution Architecture Document (Physical)', 'Technical Specifications Document', 'Technical Specifications Sign-off', 'Logical Technology Model', 'Physical Technology Model', 'Vendor System Delivery Sign-off', 'SCA Report', 'High Level SIT Plan', 'SIT Test Scripts and Cases', 'SIT Test Results', 'SIT Sign-off', 'SIT Test Probem Plan', 'High Level UAT Plan', 'Penetration Test', 'Performance Test', 'UAT Test Scripts and Results', 'UAT Test Results', 'UAT Sign-off', 'UAT Test Problem Form', 'Functional Specifications Document (Addendum)', 'Functional Specifications Change Request Form', 'Implementation Plan', 'System Documentation', 'High Level Live Test Plan', 'Training Plan', 'Training Materials', 'Preliminary Assessment for Load Test', 'Risk Management Sign-off', 'Data Governance Sign-off', 'IT Security Sign-off', 'Compliance Sign-off', 'Audit Sign-off', 'Minutes of Meeting (Pre-CRM)', 'Minutes of Meeting (CRM/PIM)', 'Data Validation Sign-off', 'Live Test Sign-off', 'Fact Gathering Feedback', 'Survey Questionnaire', 'PIA Report', 'Minutes of Meeting (PIAM/PMM)', 'Regulatory Clearance/Sign-off/Approval/Notification', 'Project Risk Assessment'];
     $i = 0;
     $required = [];
     if ($input['applicability'] == 'New or Replacement of IT Solution') {
         $required = ['M', 'O', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'O', 'M', 'M', 'O', 'M', 'M', 'M', 'M', 'O', 'O', 'O', 'N/A', 'M', 'M', 'M', 'M', 'O', 'M', 'O', 'O', 'M', 'M', 'M', 'O', 'O', 'O', 'M', 'M', 'O', 'O', 'O', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'O', 'O', 'M', 'M', 'M', 'M', 'O', 'O'];
     } elseif ($input['applicability'] == 'Enhancement or Application System Upgrade') {
         $required = ['M', 'O', '-', '-', '-', 'M', 'M', 'M', 'M', 'M', 'M', 'M', '-', 'O', 'M', 'M', 'O', '-', '-', 'M', 'M', 'O', 'O', 'O', 'N/A', 'M', 'M', 'M', 'M', 'O', 'M', 'O', 'O', 'M', 'M', 'M', 'O', 'O', 'O', 'M', 'M', 'O', 'O', 'O', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'M', 'O', 'O', 'O', 'O', 'O', 'M', 'O', 'O'];
     } elseif ($input['applicability'] == 'IT Infrastructure') {
         $required = ['M', '-', '-', '-', '-', 'M', 'M', 'M', 'M', 'M', 'M', 'M', '-', '-', '-', '-', '-', '-', 'M', 'M', 'M', 'O', 'O', 'O', 'N/A', 'M', 'M', 'M', 'M', 'O', 'M', 'O', 'O', 'M', 'M', 'M', 'O', '-', '-', 'M', 'M', 'O', 'O', 'O', 'M', '-', '-', 'M', '-', 'M', 'M', 'M', '-', 'O', 'O', 'O', 'O', 'M', 'O', 'O'];
     }
     foreach ($deliverables as $deliverable) {
         Deliverable::create(['project_id' => $project['id'], 'deliverable' => $deliverable, 'required' => $required[$i]]);
         $i = $i + 1;
     }
     flash()->success('Your new project has been created!');
     return redirect('/');
 }