Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>belajar vue</title>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.4/css/bootstrap.min.css">
</head>
<body>

      <div id="app">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-6">
                    <div class="card">
                            <div class="card-header">
                                <h4>location</h4>
                            </div>
                            <div class="card-body" style="padding:20px;">
                                <form action="" >
                                    <div class="form-group">
                                        <label for="site">Site</label>
                                        <select class="form-control" v-model ="selectedLocation" >
                                            <option disabled value="">Please select one</option>
                                            <option v-for="siteTable in SiteTables" v-bind:value="siteTable.siteLocation">
                                                {{ siteTable.siteLocation }}
                                            </option>
                                        </select>
                                    </div>

                                    <div class="form-group">
                                        <label for="application">Application 1</label>
                                        <select class="form-control" v-model ="application1" >
                                            <option disabled value="">Please select one</option>
                                            <option v-for="typesOfApplication in TypesOfApplications" v-bind:value="typesOfApplication.name">
                                                {{ typesOfApplication.name }}
                                            </option>
                                           
                                        </select>
                                    </div>

                                    <div class="form-group">
                                        <label for="application">Application 2</label>
                                        <select class="form-control" v-model ="application2" >
                                            <option disabled value="">Please select one</option>
                                            <option v-for="typesOfApplication in TypesOfApplications" v-bind:value="typesOfApplication.name">
                                                {{ typesOfApplication.name }}
                                            </option>
                                           
                                        </select>
                                    </div>

                                    <div class="form-group">
                                        <label for="application">Application 3</label>
                                        <select class="form-control" v-model ="application3" >
                                            <option disabled value="">Please select one</option>
                                            <option v-for="typesOfApplication in TypesOfApplications" v-bind:value="typesOfApplication.name">
                                                {{ typesOfApplication.name }}
                                            </option>
                                        </select>
                                    </div>

                                    <div class="form-group">
                                        <label for="numberofuser"> Number Of Users</label>
                                        <select class="form-control" v-model ="selectedNoOfUsers" >
                                            <option disabled value="">Please select one</option>
                                            <option v-for="numberOfUser in NumberOfUsers" v-bind:value="numberOfUser.value">
                                                {{ numberOfUser.value }}
                                            </option>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <button type="submit" class="btn btn-block btn-primary" value="submit" @click="addform">Show</button>
                                    </div>
                                </form>
                            </div>
                    </div>

                    <br>
                    <table class="table" v-if="showResult" >
                        <thead>
                        <tr>
                          <th>Site</th>
                          <th>RecommendedMPLS</th>
                          <th>Cloud Hopoff</th>

                          <th>Application Type</th>
                          <th>Routing</th>
                          <th>Routing Offset </th>
                          <th>Relative Performance</th>

                          <th>Application Type 2</th>
                          <th>Routing 2</th>
                          <th>Routing Offset 2</th>
                          <th>Relative Performance 2</th>

                          <th>Application Type 3</th>
                          <th>Routing 3</th>
                          <th>Routing Offset 3</th>
                          <th>Relative Performance 3</th>
                          <th>AverageRelativePerformance</th>

                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                          <td>
                            {{ Output.Site }}
                          </td>
                          <td>
                            {{ Output.RecommendedMPLS }}
                          </td>
                          <td>
                            {{ Output.CloudHopOff }}
                          </td>
                          <td>
                            {{ Output.Application1.ApplicationType}}
                          </td>
                          <td>
                            {{ Output.Application1.Routing }}
                          </td>
                          <td>
                            {{ Output.Application1.RoutingOffset }} 
                          </td>
                          <td>
                            {{ Output.Application1.RelativePerformance }}%
                          </td>

                          <td>
                            {{ Output.Application2.ApplicationType}}
                          </td>
                          <td>
                            {{ Output.Application2.Routing }}
                          </td>
                          <td>
                            {{ Output.Application2.RoutingOffset }} 
                          </td>
                          <td>
                            {{ Output.Application2.RelativePerformance }}%
                          </td>

                          <td>
                            {{ Output.Application3.ApplicationType}}
                          </td>
                          <td>
                            {{ Output.Application3.Routing }}
                          </td>
                          <td>
                            {{ Output.Application3.RoutingOffset }} 
                          </td>
                          <td>
                            {{ Output.Application3.RelativePerformance }}%
                          </td>
                          <td>
                              {{Output.AverageRelativePerformance}}%
                          </td>
                        </tr>
                        </tbody>
                      </table>
                </div>
            </div>
        </div>
    </div> 


    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>
   
    <script>
 
      var vm = new Vue({
  el: '#app',
  data: {
	selectedLocation: '',
    SiteTables: [
		{ siteLocation: 'Auckland', cloudLocalHopOff: 'Melbourne', List: 1 },
		{ siteLocation: 'Hong Kong', cloudLocalHopOff: 'Hong Kong', List: 2 },
		{ siteLocation: 'Jakarta', cloudLocalHopOff: 'Singapore', List: 3 },
		{ siteLocation: 'London', cloudLocalHopOff: 'Melbourne', List: 4 },
		{ siteLocation: 'Los Angeles', cloudLocalHopOff: 'Hong Kong', List: 5 },
		{ siteLocation: 'Melbourne', cloudLocalHopOff: 'London', List: 6 },
		{ siteLocation: 'New York', cloudLocalHopOff: 'New York', List: 7 },
		{ siteLocation: 'Shanghai', cloudLocalHopOff: 'Los Angeles', List: 8 },
		{ siteLocation: 'Singapure', cloudLocalHopOff: 'Melbourne', List: 9 },
		],
		
		TypesOfApplications: [
			{ name: 'AWS', type: 'Cloud' },
			{ name: 'Salesforce', type: 'Cloud' },
			{ name: 'Azure', type: 'Cloud' },
			{ name: 'Office 365', type: 'Cloud' },
			{ name: 'Voice', type: 'Standard' },
			{ name: 'Video', type: 'Standard' },
			{ name: 'File Stores within Company', type: 'Standard' },
			{ name: 'ERP - Services within company in Melbourne ', type: 'Standard' }
		],

		NumberOfUsers: [
			{value: 5},
			{value: 10},
			{value: 15},
			{value: 20},
			{value: 30},
			{value: 50},
			{value: 100},

		],

		LatencyData: [
			{ siteLocation : 'Auckland', values: [5,51,44,1,13,-29,0,18,-13]},
			{ siteLocation : 'Hong Kong', values: [51,5,42,3,3,35,10,81,-13]},
			{ siteLocation : 'Jakarta', values: [44,42,5,17,0,59,0,-7,-44 ]},
			{ siteLocation : 'London', values: [0,3,17,5,-5,-1,-5,26,-10]},
			{ siteLocation : 'Los Angeles', values: [13,3,0,-5,5,-1,1,-18,2]},
			{ siteLocation : 'Melbourne', values: [-31,26,59,-1,-2,5,-2,36,-30]},
			{ siteLocation : 'New York', values: [0,10,0,-5,1,-2,5,-16,2]},
			{ siteLocation : 'Shanghai', values: [17,81,-8,17,-18,35,-12,5,72]},
			{ siteLocation : 'Singapore', values: [-15,-13,-49,-17,2,-29,2,72,5]},
		],

		application1: '',
		application2: '',
		application3: '',
		averageRelativePerformance : '',
		selectedNoOfUsers:'',
		showResult: false,

		Output: {
			Site: '',
			RecommendedMPLS: 0,
			CloudHopOff: '',
			Application1: {
				ApplicationType: '',
				Routing: '',
				RoutingOffset:0,
				RelativePerformance: 0
			},
			Application2: {
				ApplicationType: '',
				Routing: '',
				RoutingOffset:0,
				RelativePerformance: 0
			},
			Application3: {
				ApplicationType: '',
				Routing: '',
				RoutingOffset:0,
				RelativePerformance: 0
			},
			AverageRelativePerformance: 0
		}

  },
  methods: {
  	addform:function(event){
		 this.showResult = true;
		  event.preventDefault();
		  
			//Site
			var _selectedLocation = this.selectedLocation;
			this.Output.Site =_selectedLocation;

			// RecommendedMPLS

			var selectedNoOfUsers = parseInt(this.selectedNoOfUsers);
			this.Output.RecommendedMPLS = (selectedNoOfUsers*400*2*0.5*0.5*1.2)/1000;

			var selectedSiteTable = null;

			this.SiteTables.forEach(function(siteTable, key){

				if(siteTable.siteLocation === _selectedLocation){
					selectedSiteTable = siteTable;
				}
			});

			this.Output.CloudHopOff = selectedSiteTable.cloudLocalHopOff;


			const typesOfApplicationList = this.TypesOfApplications;
			const siteTablesList = this.SiteTables;
			const latencyDataList = this.LatencyData;

			Populate(this.Output.Application1, this.application1);
			Populate(this.Output.Application2, this.application2);
			Populate(this.Output.Application3, this.application3);


		
			const sumavarage = [this.Output.Application1.RelativePerformance,
			this.Output.Application2.RelativePerformance,
			this.Output.Application3.RelativePerformance];
			
			let avarage;
			let sum = 0;
			for (let i = 0; i < sumavarage.length; i++){
				sum += sumavarage[i];
			}
			
			// sum avarage
			avarage = sum/sumavarage.length;
			
			
			

			console.log(sumavarage.length);
			this.Output.AverageRelativePerformance = avarage;

			console.log(this.Output.Application1.RelativePerformance);
			//function application1,2,3
			function Populate(applicationOutput, application){
				
				// Application Type
				// let selectedTypesOfApplications = null;
				let selectedApplication = application;

				typesOfApplicationList.forEach(function( typesOfApplication,key){
					if(typesOfApplication.name === selectedApplication){
						selectedApplication = typesOfApplication;
					}
				});
			
				applicationOutput.ApplicationType = selectedApplication.type;

				//Routing
				let routing = selectedSiteTable.cloudLocalHopOff;
				if(selectedApplication.type == "Standard"){
					routing = "Melbourne";
				}
				applicationOutput.Routing = routing;

				//Routing Offset
				let routingOffset;
				siteTablesList.forEach(function(siteTable, key){
					if(siteTable.siteLocation === routing){
						routingOffset = siteTable.List;
					}
				});
				applicationOutput.RoutingOffset = routingOffset;
				

				// RelativePerformance
				let relativePerformance;
				latencyDataList.forEach(function(latencyData ,key){
					if (latencyData.siteLocation === _selectedLocation){
						relativePerformance = latencyData.values[(routingOffset - 1)];
					}
				});
				applicationOutput.RelativePerformance = relativePerformance;

			}
  		return false;
  	}
  }
})
      
      
  </script>
   
</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console