Beispiel #1
0
def Storage(params=None):
    handle_params(params)

    data = []
    with pg_connection(*current_user.get_config()) as (con, cur, err):
        with pg_log_err('list storage query'):
            cur.execute(query('list-storage'))
            data = cur.fetchall()

    display_schemas = params.getlist('schema')
    schemas = set()
    treemap_data = {'name': 'root', 'children': []}
    for (schema_name, table_name, t_size, t_tuples) in data:
        schemas.add(schema_name)
        if schema_name in display_schemas or len(display_schemas) == 0:
            treemap_data['children'].append({'schema_name': schema_name, 'name': table_name,
                                             'size': int(t_size), 'rows': int(t_tuples)})

    p = Page()

    # Header
    p.add_page(Header(title='Storage',
                      js=['static/pages/storage.js',
                          'static/lib/d3/d3.js',
                          'static/lib/d3/lib/colorbrewer/colorbrewer.js'],
                      css=['static/pages/storage.css']))
    p.add_page(Navigation(page='storage'))
    with p.div({'class': 'container-fluid'}):
        with p.div({'class': 'row form-row'}):
            with p.div({'class': 'col-md-10'}):
                with p.form({'id': 'schema-form', 'class': 'form-inline'}):
                    for schema in schemas:
                        with p.label({'class': 'checkbox-inline'}):
                            checked = (schema in display_schemas or len(display_schemas) == 0) and 'checked' or ''
                            with p.input({'type': 'checkbox', 'name': 'schema', 'value': '%s' % schema}, args=[checked]):
                                p.content(schema)

            with p.div({'class': 'col-md-2'}):
                with p.form({'id': 'mode-form', 'class': 'form-inline'}):
                    with p.label({'class': 'radio-inline'}):
                        with p.input({'type': 'radio', 'name': 'mode', 'value': 'size'}, args=['checked']):
                            p.content('Size')
                    with p.label({'class': 'radio-inline'}):
                        with p.input({'type': 'radio', 'name': 'mode', 'value': 'rows'}):
                            p.content('Rows (est.)')

        with p.div({'class': 'row'}):
            with p.div({'class': 'col-md-12'}):
                with p.div({'id': 'treemap-chart'}): pass
                with p.script():
                    p.content('PGUI.STORAGE.mk_treemap_chart(%s);' % json.dumps(treemap_data))

    p.add_page(Footer())

    return p
Beispiel #2
0
    def get(self):
        #import page
        page = Page()

        #airJordan Shoe Instance

        airj = Shoe()
        airj.name = 'Air Jordans'
        airj.price = 180 #$
        airj.limit = 2 #pairs
        airj.img ="http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        #nikeFoampositePro Shoe Instance

        nfp = Shoe()
        nfp.name = 'Nike Foamposite Pro'
        nfp.price = 220 #$
        nfp.limit = 1 #pairs
        nfp.img = "http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        #nikeFoampositeOne Shoe Instance

        nfo = Shoe()
        nfo.name = 'Nike Foamposite One'
        nfo.price = 220 #$
        nfo.limit = 1 #pairs
        nfo.img ="http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        #lebron Shoe Instance

        leb = Shoe()
        leb.name = 'LeBrons'
        leb.price = 200 #$
        leb.limit = 1 #pairs
        leb.img ="http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"


        #kobe Shoe Instance

        kobe = Shoe()
        kobe.name = 'Kobes'
        kobe.price = 120 #$
        kobe.limit = 4 #pairs
        kobe.img ="http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        shoes = [
            airj,nfp,nfo,leb,kobe
        ]

        #HTML
        self.response.write(page.header())
        self.response.write(page.form())
        if self.request.GET:
            heat = (int(self.request.GET['heat']))-1
            print heat
            self.response.write(self.html(shoes[heat]))
        self.response.write(page.footer())
Beispiel #3
0
    def get(self):
        #import page
        page = Page()
        #Grape Fruit Instance

        gfruit = List()
        gfruit.name = 'Grape Fruit'
        gfruit.price =  1.26#$
        gfruit.need = 1 #bag
        gfruit.img ="http://upload.wikimedia.org/wikipedia/en/e/e6/PT-Test.jpg"

        #Protein Powder Instance

        proteinp = List()
        proteinp.name = 'Protein Powder'
        proteinp.price = 15 #$
        proteinp.need = 1 #Container
        proteinp.img = "http://upload.wikimedia.org/wikipedia/en/e/e6/PT-Test.jpg"

        #Whole Wheat Bread Instance

        wwb = List()
        wwb.name = 'Whole Wheat Bread'
        wwb.price = 1.50 #$
        wwb.need = 2 #loaf
        wwb.img ="http://upload.wikimedia.org/wikipedia/en/e/e6/PT-Test.jpg"

        #Eggs Instance

        eggs = List()
        eggs.name = 'Eggs'
        eggs.price = 1 #$
        eggs.need = 1 #carton
        eggs.img ="http://upload.wikimedia.org/wikipedia/en/e/e6/PT-Test.jpg"

         #Water Instance

        water = List()
        water.name = 'Water'
        water.price =  5 #$
        water.need = 1 #cases 24 pack
        water.img ="http://upload.wikimedia.org/wikipedia/en/e/e6/PT-Test.jpg"

         #Grocery List Items Array
        glist = [
            gfruit,proteinp,wwb,eggs,water
        ]

        #HTML
        self.response.write(page.header())
        self.response.write(page.form())
        if self.request.GET:
            shop = (int(self.request.GET['shop']))-1
            print shop
            self.response.write(self.html(glist[shop]))
        self.response.write(page.footer())
Beispiel #4
0
    def get(self):
        p = Page()

        ji = FamilyMember()
        ji.name = "Jason"
        ji.status = "father"
        ji.water_morning = 50
        ji.water_afternoon = 30
        ji.water_evening = 30

        ka = FamilyMember()
        ka.name = "Katie"
        ka.status = "mother"
        ka.water_morning = 30
        ka.water_afternoon = 30
        ka.water_evening = 20

        ij = FamilyMember()
        ij.name = "Isaac"
        ij.status = "son"
        ij.water_morning = 20
        ij.water_afternoon = 20
        ij.water_evening = 40

        ea = FamilyMember()
        ea.name = "Ella"
        ea.status = "daughter"
        ea.water_morning = 10
        ea.water_afternoon = 20
        ea.water_evening = 20

        ch = FamilyMember()
        ch.name = "Chewie"
        ch.status = "dog1"
        ch.water_morning = 3
        ch.water_afternoon = 4
        ch.water_evening = 2

        ot = FamilyMember()
        ot.name = "Otis"
        ot.status = "dog2"
        ot.water_morning = 4
        ot.water_afternoon = 4
        ot.water_evening = 3

        members = [ji, ka, ij, ea, ch, ot]

        self.response.write(p.header())
        self.response.write(p.form())

        if self.request.GET:
            member = (int(self.request.GET['member']))-1
            print member
            self.response.write(self.html(members[member]))
        self.response.write(p.footer())
Beispiel #5
0
    def get(self):
        #import page
        page = Page()

        #airJordan Shoe Instance

        airj = Shoe()
        airj.name = 'Air Jordans'
        airj.price = 180  #$
        airj.limit = 2  #pairs
        airj.img = "http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        #nikeFoampositePro Shoe Instance

        nfp = Shoe()
        nfp.name = 'Nike Foamposite Pro'
        nfp.price = 220  #$
        nfp.limit = 1  #pairs
        nfp.img = "http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        #nikeFoampositeOne Shoe Instance

        nfo = Shoe()
        nfo.name = 'Nike Foamposite One'
        nfo.price = 220  #$
        nfo.limit = 1  #pairs
        nfo.img = "http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        #lebron Shoe Instance

        leb = Shoe()
        leb.name = 'LeBrons'
        leb.price = 200  #$
        leb.limit = 1  #pairs
        leb.img = "http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        #kobe Shoe Instance

        kobe = Shoe()
        kobe.name = 'Kobes'
        kobe.price = 120  #$
        kobe.limit = 4  #pairs
        kobe.img = "http://upload.wikimedia.org/wikipedia/en/3/37/Jumpman_logo.svg"

        shoes = [airj, nfp, nfo, leb, kobe]

        #HTML
        self.response.write(page.header())
        self.response.write(page.form())
        if self.request.GET:
            heat = (int(self.request.GET['heat'])) - 1
            print heat
            self.response.write(self.html(shoes[heat]))
        self.response.write(page.footer())
Beispiel #6
0
def Login(params=None, title=None):
    """
    Renders the login page.

    There is no separate login for the application, this is passed to
    the database!
    """
    p = Page()
    p.content('<!DOCTYPE html>')
    with p.html():
        with p.head():
            with p.title():
                p.content('pgui - Login')
            with p.link({'href': 'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css', 'rel': 'stylesheet'}): pass
            with p.link({'href': 'static/login.css', 'rel': 'stylesheet'}): pass

        with p.body():

            with p.div({'class': 'container'}):
                with p.form({'method': 'POST', 'class': 'login'}):
                    with p.h2({'class': 'login-header'}):
                        p.content('Connect to a postgres database server')

                    with p.label({'for': 'name', 'class': 'sr-only'}):
                        p.content('User name')
                    with p.input({'type': 'input', 'id': 'name', 'name': 'name', 'class': 'form-control', 'placeholder': 'User name'}): pass

                    with p.label({'for': 'password', 'class': 'sr-only'}):
                        p.content('Password')
                    with p.input({'type': 'password', 'id': 'password', 'name': 'password', 'class': 'form-control', 'placeholder': 'Password'}): pass

                    with p.label({'for': 'host', 'class': 'sr-only'}):
                        p.control('Host')
                    with p.input({'type': 'input', 'id': 'host', 'name': 'host', 'class': 'form-control', 'value': 'localhost'}): pass

                    with p.label({'for': 'port', 'class': 'sr-only'}):
                        p.content('Port')
                    with p.input({'type': 'input', 'id': 'port', 'name': 'port', 'class': 'form-control', 'value': '5432'}): pass

                    with p.button({'class': 'btn btn-lg btn-success btn-block', 'type': 'submit'}, args=['autofocus']):
                        p.content('Connect')


                with p.div({'class': 'login'}):
                    if 'err' in params and params['err']:
                        for err in params['err']:
                            with p.code():
                                p.content(err)

    return p
Beispiel #7
0
    def get(self):
        page = Page(
        )  # creates an instance of the Page function which is defined at library.py

        mike = Person(5555)  # Password for his/her voicemail
        mike.name = "Mike Taatgen"  # Name of the user
        mike.text = 45  #Amount of text send
        mike.minutes = 300  # Amount of minutes talked on the phone
        mike.internet = 2  # Amount of GB used for data

        anthony = Person(5235)  # Password for his/her voicemail
        anthony.name = "Anthony Kluba"  # Name of the user
        anthony.text = 25  #Amount of text send
        anthony.minutes = 325  # Amount of minutes talked on the phone
        anthony.internet = 7.2  # Amount of GB used for data

        nate = Person(1821)  # Password for his/her voicemail
        nate.name = "Nathan Dickison"  # Name of the user
        nate.text = 75  #Amount of text send
        nate.minutes = 290  # Amount of minutes talked on the phone
        nate.internet = 3.2  # Amount of GB used for data

        jairo = Person(8371)  # Password for his/her voicemail
        jairo.name = "Jairo Jurado"  # Name of the user
        jairo.text = 25  #Amount of text send
        jairo.minutes = 400  # Amount of minutes talked on the phone
        jairo.internet = 6  # Amount of GB used for data

        rebecca = Person(9213)  # Password for his/her voicemail
        rebecca.name = "Rebecca Carroll"  # Name of the user
        rebecca.text = 49  #Amount of text send
        rebecca.minutes = 280  # Amount of minutes talked on the phone
        rebecca.internet = 4  # Amount of GB used for data

        players = [mike, anthony, nate, jairo,
                   rebecca]  #array with all the players

        self.response.write(page.header())  # Creates the HTML attributes
        self.response.write(page.form())
        if self.request.GET:
            player = int(
                self.request.GET['person']) - 1  #because index start at 0
            self.response.write(self.html(players[player]))
        self.response.write(page.footer())
Beispiel #8
0
	def get(self):
		page = Page() # creates an instance of the Page function which is defined at library.py

		mike = Person(5555) # Password for his/her voicemail
		mike.name = "Mike Taatgen" # Name of the user
		mike.text = 45 #Amount of text send
		mike.minutes = 300 # Amount of minutes talked on the phone
		mike.internet =  2 # Amount of GB used for data

		anthony = Person(5235) # Password for his/her voicemail
		anthony.name = "Anthony Kluba" # Name of the user
		anthony.text = 25 #Amount of text send
		anthony.minutes = 325 # Amount of minutes talked on the phone
		anthony.internet = 7.2 # Amount of GB used for data

		nate = Person(1821) # Password for his/her voicemail
		nate.name = "Nathan Dickison" # Name of the user
		nate.text = 75 #Amount of text send
		nate.minutes = 290 # Amount of minutes talked on the phone
		nate.internet = 3.2 # Amount of GB used for data

		jairo = Person(8371) # Password for his/her voicemail
		jairo.name = "Jairo Jurado" # Name of the user
		jairo.text = 25 #Amount of text send
		jairo.minutes = 400 # Amount of minutes talked on the phone
		jairo.internet =  6 # Amount of GB used for data

		rebecca = Person(9213) # Password for his/her voicemail
		rebecca.name = "Rebecca Carroll" # Name of the user
		rebecca.text = 49 #Amount of text send
		rebecca.minutes = 280 # Amount of minutes talked on the phone
		rebecca.internet = 4 # Amount of GB used for data

		players = [mike,anthony,nate,jairo,rebecca]	#array with all the players

		self.response.write(page.header()) # Creates the HTML attributes
		self.response.write(page.form())
		if self.request.GET:
			player = int(self.request.GET['person'])-1 #because index start at 0 
			self.response.write(self.html(players[player]))
		self.response.write(page.footer())
Beispiel #9
0
    def get(self):
        page = Page()# Instantiate Page()

        dog = Canis()# creating instance of dog sub class
        dog.name = 'Yorkshire Terrier'

        horse = Equus()#creating an instance of horse sub class
        horse.name = 'Horse'

        raccoon = Procyon()#creating an instance of raccoon sub class
        raccoon.name = 'Raccoon'

        animals = [dog, horse, raccoon]#array of animals

        #displays the html page and displays the appropriate info for the requested animal
        self.response.write(page.header())
        self.response.write(page.form())
        if self.request.GET:
            animal = (int(self.request.GET['animal']))-1
            print animal
            self.response.write(page.template(animals[animal]))
        self.response.write(page.footer())
Beispiel #10
0
def Storage(params=None):
    handle_params(params)

    data = []
    with pg_connection(*current_user.get_config()) as (con, cur, err):
        with pg_log_err('list storage query'):
            cur.execute(query('list-storage'))
            data = cur.fetchall()

    display_schemas = params.getlist('schema')
    schemas = set()
    treemap_data = {'name': 'root', 'children': []}
    for (schema_name, table_name, t_size, t_tuples) in data:
        schemas.add(schema_name)
        if schema_name in display_schemas or len(display_schemas) == 0:
            treemap_data['children'].append({
                'schema_name': schema_name,
                'name': table_name,
                'size': int(t_size),
                'rows': int(t_tuples)
            })

    p = Page()

    # Header
    p.add_page(
        Header(title='Storage',
               js=[
                   'static/pages/storage.js', 'static/lib/d3/d3.js',
                   'static/lib/d3/lib/colorbrewer/colorbrewer.js'
               ],
               css=['static/pages/storage.css']))
    p.add_page(Navigation(page='storage'))
    with p.div({'class': 'container-fluid'}):
        with p.div({'class': 'row form-row'}):
            with p.div({'class': 'col-md-10'}):
                with p.form({'id': 'schema-form', 'class': 'form-inline'}):
                    for schema in schemas:
                        with p.label({'class': 'checkbox-inline'}):
                            checked = (schema in display_schemas
                                       or len(display_schemas)
                                       == 0) and 'checked' or ''
                            with p.input(
                                {
                                    'type': 'checkbox',
                                    'name': 'schema',
                                    'value': '%s' % schema
                                },
                                    args=[checked]):
                                p.content(schema)

            with p.div({'class': 'col-md-2'}):
                with p.form({'id': 'mode-form', 'class': 'form-inline'}):
                    with p.label({'class': 'radio-inline'}):
                        with p.input(
                            {
                                'type': 'radio',
                                'name': 'mode',
                                'value': 'size'
                            },
                                args=['checked']):
                            p.content('Size')
                    with p.label({'class': 'radio-inline'}):
                        with p.input({
                                'type': 'radio',
                                'name': 'mode',
                                'value': 'rows'
                        }):
                            p.content('Rows (est.)')

        with p.div({'class': 'row'}):
            with p.div({'class': 'col-md-12'}):
                with p.div({'id': 'treemap-chart'}):
                    pass
                with p.script():
                    p.content('PGUI.STORAGE.mk_treemap_chart(%s);' %
                              json.dumps(treemap_data))

    p.add_page(Footer())

    return p
Beispiel #11
0
def Login(params=None, title=None):
    """
    Renders the login page.

    There is no separate login for the application, this is passed to
    the database!
    """
    p = Page()
    p.content('<!DOCTYPE html>')
    with p.html():
        with p.head():
            with p.title():
                p.content('pgui - Login')
            with p.link({
                    'href':
                    'static/lib/bootstrap/bootstrap-3.3.4-dist/css/bootstrap.css',
                    'rel': 'stylesheet'
            }):
                pass
            with p.link({'href': 'static/login.css', 'rel': 'stylesheet'}):
                pass

        with p.body():

            with p.div({'class': 'container'}):
                with p.form({'method': 'POST', 'class': 'login'}):
                    with p.h2({'class': 'login-header'}):
                        p.content('Connect to a postgres database server')

                    with p.label({'for': 'name', 'class': 'sr-only'}):
                        p.content('User name')
                    with p.input({
                            'type': 'input',
                            'id': 'name',
                            'name': 'name',
                            'class': 'form-control',
                            'placeholder': 'User name'
                    }):
                        pass

                    with p.label({'for': 'password', 'class': 'sr-only'}):
                        p.content('Password')
                    with p.input({
                            'type': 'password',
                            'id': 'password',
                            'name': 'password',
                            'class': 'form-control',
                            'placeholder': 'Password'
                    }):
                        pass

                    with p.label({'for': 'host', 'class': 'sr-only'}):
                        p.control('Host')
                    with p.input({
                            'type': 'input',
                            'id': 'host',
                            'name': 'host',
                            'class': 'form-control',
                            'value': 'localhost'
                    }):
                        pass

                    with p.label({'for': 'port', 'class': 'sr-only'}):
                        p.content('Port')
                    with p.input({
                            'type': 'input',
                            'id': 'port',
                            'name': 'port',
                            'class': 'form-control',
                            'value': '5432'
                    }):
                        pass

                    with p.button(
                        {
                            'class': 'btn btn-lg btn-success btn-block',
                            'type': 'submit'
                        },
                            args=['autofocus']):
                        p.content('Connect')

                with p.div({'class': 'login'}):
                    if 'err' in params and params['err']:
                        for err in params['err']:
                            with p.code():
                                p.content(err)

    return p